How to do a moving regression
5 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (2 件)
Image Analyst
2016 年 5 月 30 日
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 件のコメント
Star Strider
2016 年 5 月 30 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Linear and Nonlinear Regression についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!