How to do a moving regression
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a set of returns which I want to regress in a loop, rolling window loop that will regress the first 12 returns against a variable called inn_liq.
I want to be able to generate several betas, b(i), the first beta regresses the first twelve observations, the second beta regresses twelve observations from the first to the thirteenth observations and so forth. The third beta regresses from the second till the fourteenth observations.
For each beta, I would like to plot the 95% confidence intervals of each beta, together with the beta, in order to determine if each beta is statistically different from zero.
Kindly help me in solving my problem.
0 commentaires
Réponses (2)
Image Analyst
le 30 Mai 2016
I don't know what you mean by you want to "generate several betas", but to filter a signal with a moving window by fitting/regressing the data in the window to a polynomial, you use a Savitzky-Golay filter, done by sgolayfilt() in the Signal Processing Toolbox. You can specify both the window width and the order of the polynomial that you want to use to do the regression. I attach a demo.
0 commentaires
Star Strider
le 30 Mai 2016
If I understand correctly what you want to do, and your ‘betas’ are the slopes of the individual segments, you will probably have to do this with a loop using polyfit and a 2-degree polynomial, then use the the File Exchange polyparci function to calculate the confidence intervals.
0 commentaires
Voir également
Catégories
En savoir plus sur Linear and Nonlinear Regression dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!