search for: rolling_corr

Displaying 1 result from an estimated 1 matches for "rolling_corr".

2017 Oct 18
1
Problem with tq_mutate_xy() from the tidyquant package
...dyquant) # Loads tidyverse, tidyquant, financial pkgs, xts/zoo library(xts) dtV <- as.Date("2017-01-01") + 1:100 locL <- list( foo=xts(rnorm(100), order.by=dtV), bar=xts(rnorm(100), order.by=dtV) ) fullXts <- do.call(merge,locL) smallXts <- fullXts["2017-02-01::"] rolling_corrOnePair <- function( aXts, col1, col2, window ) { #window = window size in days tbl <- timetk::tk_tbl( aXts[,c(col1,col2)], rename_index="date" ) colnames(tbl) <- c("date","x","y") naV <- sapply(1:nrow(tbl), function(i) any(is.na(tbl[i,]))...