lags | R Documentation |
Generates a data frame whose rows correspond to indexes showing the initial and final lag to be used in a regression as finite distributed lag model with two explanatory variables, for example. This function is useful as an intermediate step for constructing lag variables. See details.
lags(p, q, recursive = FALSE)
p |
Integer, maximum lag |
q |
Integer, maximum lag |
recursive |
Logical, |
Condiser the following regression:
y_{i,t} = a_0 + y_{i,t-pstart} + ... + y_{i,t-pend} + x_{i,t-qstart} + ... + x_{i,t-qend} + e_{i,t}
.
lags
constructs a data frame with indexes pstar
, pend
,
qstart
and qend
. This is an intermediate step for obtaining
the variables to estimate a lot of possible models.
If recursive = FALSE
, both pstart
and qstart
are always = 1
and pend
and qend
grows from one to p
and q
, respectively.
If recursive = TRUE
, on the other hand, pstart
and qstart
also grows from one to p
and q
. This last case is
appropriated if one wants to construct variables for
estimating models with more combinations of lags.
The cost of this option is that it is time-consuming in
terms of computation.
Data frame
lags(2, 1, recursive = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.