Calculate Exponetial Moving Covariance

11 vues (au cours des 30 derniers jours)
Tommaso Delicato
Tommaso Delicato le 18 Fév 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

Réponse acceptée

Jeff Miller
Jeff Miller le 18 Fév 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)]

Plus de réponses (0)

Catégories

En savoir plus sur Descriptive Statistics dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by