View source: R/lagged_correlations.R
lagged_correlations | R Documentation |
Calculate correlation beetwen two numeric vector x and y for lagged values of x. Both vectors need to have equal length.
lagged_correlations(x, y, max_lag = length(x) - 2, plot = TRUE)
x |
Numeric vector of asset prices or returns (to be lagged) |
y |
Numeric vector of asset prices or returns |
max_lag |
Max number of lags for vector x. Default set to lengt(x) - 2 |
plot |
If TRUE plot correlation for each lag |
Numeric vector of correlations for different time lags.
tickers <- c('wig20', 'mwig40') sapply(tickers ,stooq_download ,destination = 'datasets\\') files <- list.files('datasets\\') close_prices <- df_prices(files = files ,source = 'datasets\\') x <- close_prices[,2] %>% unlist() y <- close_prices[,3] %>% unlist() lagged_correlations(x, y, max_lag = 200)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.