Effacer les filtres
Effacer les filtres

How to create a new table with lag-betas?

1 vue (au cours des 30 derniers jours)
Yoyo
Yoyo le 3 Août 2021
I have a 588 x 196 timetable. The dates in column one is from 31. Jan- 1963 to 31.Dec - 2011. The column names are each stocks identification number with the belonging returns for each month.
I want to run 240 different AR regressions for each stock. So for all columns 1, 2, 3,...,195,196 I want to run the following regressions:
.
.
.
Where return. So there will be 196*240 = 47,040 different regressions.
Then I want to store the betas in a timetable with their respective lagged dates. So for the first regression I want the beta to be stored for 30-Nov-2011, for 31-Oct-2011, for 30-Sep-2011 and so on.

Réponses (1)

William Mueller
William Mueller le 5 Août 2021
If I’m reading this right, you'll want to add one new row at the top of the table for 31-Dec-1962, then a variable for Beta1 following Var1, Beta2 following Var2, etc. The last row in each Beta would be NaN.
LAGMATRIX in Econometrics Toolbox will create lagged versions of all series at all lags in one call. Running the regressions with mldivide would then be a matter of indexing into the appropriate column to obtain each y_lag.
Writing successive betas to the table would be along the lines of Tbl.Betaj(i) = beta(i,j), where the beta(i,j) are the successive regression results.

Community Treasure Hunt

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

Start Hunting!

Translated by