I would like to it a distributed lag model for longitudinal data with three lags:
$$ Y_{it}=\alpha + \sum_{l=0}^{3}\beta_{j}x_{it-3} + \text{other predictors} +\epsilon_{it} $$
To create the lagged variables,R
:
x <- 1:10
lag <- 3
\embed(c(rep(NA, lag), x), lag)
X1 X2 X3
[,1] [,2] [,3]
[1,] NA NA NA
[2,] 1 NA NA
[3,] 2 1 NA
[4,] 3 2 1
[5,] 4 3 2
[6,] 5 4 3
[7,] 6 5 4
[8,] 7 6 5
[9,] 8 7 6
[10,] 9 8 7
[11,] 10 9 8
\now I may run a regression
lm(Y ~ X + X1+X2+X3)
However, such model is going to expirience high degree of multicollinearity. Therefore I would like to use a Polynomial distributed lag:
$$ \beta_{it} = a_{0} + a_{1}i + a_{2}i^2 +\ldots+a_{q}i^q $$ where $q$ is the degree of the polynomial and $i$ the lag length. Another formulation is $$ \beta_{i} = a_{0} + \sum_{j=1}^{q}a_{j}f_{j}(i) $$ Where $f_{j}(i)$ is a polynomial of degree $j$ in the lag length $i$.
I could not find any packages in R
for panel data and Polynomial distributed lags. Is it safely to assume that the data structure for q=3
looks like this:
[,1] [,2] [,3]
[1,] NA NA NA
[2,] 1 NA NA
[3,] 2 1 NA
[4,] 3 4 1
[5,] 4 9 8
[6,] 5 16 27
[7,] 6 25 64
[8,] 7 6 125
[9,] 8 49 6
[10,] 9 64 343
[11,] 10 9 512