calc_cor | R Documentation |
Calculate correlation between returns
calc_cor(unwt_ret_df, start_date = NA, end_date = NA, period_name = NULL)
unwt_ret_df |
dataframe containing timeseries returns for each strategy |
start_date |
A Date variable which is the start_date of the period for correlation calculation |
end_date |
A Date variable |
period_name |
optional period_name to attach to the returned correlations |
long form dataframe (see tidyr::gather) containing correlation between returns, and 'period_name“ if provided
unwt_ret <- data.frame(date = as.Date(c("2018-01-02", "2018-01-03", "2018-01-04", "2018-01-05")), long_spx = c(0.015, 0.021, -0.03, 0.01), long_ukx = c(-0.005, 0.03, -0.01, -0.04), long_hsi = c(0.023, 0.001, -0.005, 0.008)) calc_cor(unwt_ret)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.