Calculate rolling correlation between two time series by group
Source:R/analysis_functions.R
rolling_corr.RdThis function calculates the rolling correlation between two time series
Arguments
- dat
data frame with columns that correspond to two time series and grouping variable
- date_var
character string of date column name (should be of class "Date")
- grp_var
character string of column name in dat to be used as grouping variable
- x_var
primary time series (should be a column in dat)
- y_var
secondary time series (should be a column in dat)
- n
the number of time periods over which to calculate rolling correlation