Loop for lagged regression
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
We are supposed to run a total of 60 regressions with a dependent variable of stock returns and an independent variable as the lagged variable of the dependent variable(first regression use the first lag of dependent variable as the independent variable and so on. R(t) = α(h) + β(h)*R(t−h) where R(t-h) is the return in month t-h for h=0,1,2...60). As this will take a lot of time to do manually, is it possible to run a loop for the regressions in order to easier acquire the necessary coefficient estimates and the t-statistics? If this is the case, could you provide some examples of how to proceed with the calculation of the 60 regressions?
I created a matrix (:,61) for the return Dependent variable and each lagged return variable XLag=lagmatrix(monthly_returns.logExcRet,0:60); and delete the NAN XLag=XLag(~isnan(XLag(:,61)),:);
The function I try to run for the loop is for h=1:60 w(h)=fitlm(y,XLag(:,2:end)); end
Error using classreg.regr.FitObject/selectVariables (line 333) Response variable must be a numeric vector.
Error in classreg.regr.TermsRegression/selectVariables (line 258) model = selectVariables@classreg.regr.ParametricRegression(model);
0 Commenti
Risposte (0)
Vedere anche
Categorie
Scopri di più su Descriptive Statistics in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!