Loop for lagged regression

4 次查看(过去 30 天)
Marius Harsjøen
Marius Harsjøen 2018-3-1
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 个)

类别

Help CenterFile Exchange 中查找有关 Descriptive Statistics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by