Compute rolling window covariance matrix
Posted
by
user1665355
on Stack Overflow
See other posts from Stack Overflow
or by user1665355
Published on 2012-09-13T15:31:47Z
Indexed on
2012/09/13
15:38 UTC
Read the original article
Hit count: 225
r
I am trying to compute a rolling window (shifting by 1 day) covariance matrix for a number of assets.
Say my df looks like this:
df <- data.frame(x = 0:4, y = 5:9,z=1:5,u=4:8)
How would a possible
for
loop look like if I want to calculate a covariance matrix on a rolling basis by shifting the rolling window by 1 day? Or should I use someapply
family function?What time series class would be preferrable if I want to create a time series object for the loop above?
I simply can't get it...
Best Regards
© Stack Overflow or respective owner