Calculate Exponetial Moving Covariance

10 views (last 30 days)
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

Accepted Answer

Jeff Miller
Jeff Miller on 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)]

More Answers (0)

Categories

Find more on Descriptive Statistics in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!