Learn R Programming

PerformanceAnalytics (version 0.9.5)

rollingCorrelation: rolling training period covariance/correlation

Description

This is a wrapper for providing n-period trailing correlations for the data provided.

Usage

rollingCorrelation(Ra, Rj, width, trim = TRUE, na.rm = FALSE, ...)

Arguments

Ra
a vector, matrix, data frame, timeSeries or zoo object of asset returns
Rj
a vector, matrix, data frame, timeSeries or zoo object of asset returns
width
the number of periods over which a function is to be calculated. Use the value zero (0) to roll the statistic from inception
trim
TRUE/FALSE, whether to keep alignment caused by NA's
na.rm
TRUE/FALSE Remove NA's from the returns?
...
any other passthru parameters

Value

  • A data.table of n-period trailing correlations for each column in y.

Details

Example: head(rollingCorrelation(manager.ts@Data[,1],edhec.ts@Data,n=12)) Convertible Arbitrage CTA Global Distressed 2003-11-28 0.2591101 0.2762218 0.7516556 2003-12-31 0.2162078 0.2477113 0.7452179 2004-01-30 0.3918575 0.3489062 0.7562063 2004-02-27 0.5331404 0.3905645 0.7088004 2004-03-31 0.5730389 0.3010877 0.5694478 2004-04-30 0.5146946 0.3762283 0.4374524

See Also

cov

Examples

Run this code
#head(rollingCorrelation(manager.ts@Data[,1],edhec.ts@Data,n=12))

Run the code above in your browser using DataLab