How do I perform a dynlm regression when I want to included lags of both the dependent and independent variable.
For example with the following data;
a <- 1:10
b <- 5:15
a <- ts(a)
b <- ts(b)
dynlm(a ~ L(a, 1:3) + L(b, 1:2))
What I am trying to obtain is a linear regression of the model where a depends on 3 of its own lags and 2 lags of b. However, I get NA values
I think I do not properly understand how dynlm works. Anyone who can give me some insight to what is going wrong?
With respect to the data shown in the question, the intercept and first lag give a perfect prediction so the other lags are not needed. Note that
resid(dynlm(...))
is all zero.