How do you implement a Distributed lag model using fitlm?

3 views (last 30 days)
Dear All,
I am trying to predict power production of PV generator using a MLR model but using lagged predictors and lagged dependent variable. Suppose my data table (tbl) is:
data Pac Tmod
____________________ ______ ______
01-Sep-2012 05:00:00 6.3 24.555
01-Sep-2012 06:00:00 27.917 28.338
01-Sep-2012 07:00:00 74.833 36.41
Then I construct lagged Pac and Tmod values using:
laggedPac=lagmatrix(tbl.Pac,[1 2]);
laggedTmod=lagmatrix(tbl.Tmod,[1,2]);
laggedPac=array2table(laggedPac,'VariableNames',{'Pac_lg1','Pac_lg2'});
laggedTmod=array2table(laggedTmod,'VariableNames',{'Tmod_lg1','Tmod_lg2'});
tbl=[tbl ,laggedPac ,laggedTmod];
Then I construct a MLR model using fitlm as follow (eventually using also 'RobustOpts'):
lm = fitlm(tbl,'Pac~Tmod+Pac_lg1+Tmod_lg1')
Is this the correct way to implement such a models?

Answers (0)

Categories

Find more on Descriptive Statistics in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!