I'am trying to produce a rolling window to estimate a covariance matrix using a for-loop. I have my returns under the variable returns_sec
and I have 260 observations stored under N_ret
.
I now want to produce a covariance matrix estimate based on ten return series at a time and obtain one big variable with all covariance matrices in it (Top lines: Matrix1
, below Matrix2
and so on).
I could to this by hand by writing:
kov_test=cov(returns_sec(1:10,:));
kov_test2=cov(returns_sec(11:21,:)); ...
and copy all results in one variable. But I think there should also be a more effective and easy way using a for-loop.
Would be great if anyone of you could help me out!