Rolling Covariance
Posted: Mon Jun 25, 2018 7:57 am
Dear Tom,
I have a very simple prolem. When I have two series x and y, how can I calculate a rolling covariance between the two.
For example I want to calculate cov(x(t),y(t)) for t=1,...,20. Then I want to calculate cov(x(t),y(t)) for t=2,...,21 and so on. Then I want to save the covariance for later calculation within each iteration of the loop.
The cross instruction works well for printing the values, but I don't know how to safe the values. My code is
start = some date
end = some date +20
Thank you
best jules
I have a very simple prolem. When I have two series x and y, how can I calculate a rolling covariance between the two.
For example I want to calculate cov(x(t),y(t)) for t=1,...,20. Then I want to calculate cov(x(t),y(t)) for t=2,...,21 and so on. Then I want to save the covariance for later calculation within each iteration of the loop.
The cross instruction works well for printing the values, but I don't know how to safe the values. My code is
start = some date
end = some date +20
Code: Select all
do i = 0, 1813
cross(from=0, to=0,covariances,results=cov) x y start+i end+i
end do ibest jules