Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Is there a shorter way to use Lag Operators in a Regression in R

$
0
0

I am trying to replicate a regression that I saw in an article:

Y_t=a(L) Y_(t-1)

Where L is a polynomial in the lag operator and it said that

“Lag dependent variable [Lags: 1-24] is entered as four-quarter moving average for lags 1, 5, 9, 13, 17 and 21, respectively”.

I saw that I can do something like this:

lm(Y ~ I(lag(Y)) + I(lag(Y, 5)) + I(lag(Y, 9)) + I(lag(Y, 13)) + I(lag(Y, 17)) + I(lag(Y, 21)) + I(lag(Y, 24))

Is there a shorter way?

Thanks in advance.


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>