# Calculate Exponetial Moving Covariance

조회 수: 29(최근 30일)
Tommaso Delicato 18 Feb 2021
답변: Jeff Miller 18 Feb 2021
I should calculate a variance-covariance matrix over a 60-month rolling window, but so that the newer data has more weight than the older data, such as an exponential moving average. Can you give me a hand? thank you in advance

댓글을 달려면 로그인하십시오.

### 채택된 답변

Jeff Miller 18 Feb 2021
Not really a hand, but maybe some hints...Let's say you have variables x and y, and you want the exponentially weighted rolling means, variances, and covariances.
It looks like you can get the means with dsp.MovingAverage (though I haven't done this so am not sure of the details).
To get the variances and covariances, form the new variables x.^2, y.^2, and x.*y. You can also compute the moving averages of these new variables with dsp.MovingAverage.
Finally, at each time point compute the variance as e.g., [rolling average of x.^2 - (rolling average of x)^2] and the covariance as [rolling average of x.*y - (rolling average of x)*(rolling average of y)]

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!