how to create a loop for rolling window returns?
显示 更早的评论
Hi to all,
I do not know the MATLAB environment well, I wanted to ask if someone could tell me how to create a loop with the sample - out sample method. I would like to find the mean and the covariance of returns, as follows:
returns = rand(2013, 30);
I would like to find the mean from 1 to 500, from 21 to 521, etc.
I'll explain better: M1 = mean of RR 1->500; M2 = mean of RR 21->521; M3 = mean of RR 41->541; ...
With a step of 20 positions.I tried to follow these examples but I could not:
https://it.mathworks.com/matlabcentral/answers/247677-how-to-calculate-moving-covariance-in-a-matrix
Thanks for your help.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!