# Dynamic Panel Data
## When Is It a Problem
Model setup:
$$y_{i,t} = \gamma y_{i, t-1} + X_{i,t}' \beta + C_i + \epsilon_{i,t}$$ {#eq-dynamic-panel-1}
Pooled regression is biased and inconsistent. The problem is:
$$Cov( y_{i,t-1}, (C_i + \epsilon_{i,t})) \approx \frac{\sigma_c^2}{(1-\gamma)}$$ {#eq-dynamic-panel-2}
Random effects model is biased and inconsistent, for the same reason
that $y_{i,t-1}$ is necessarily correlated with $C_i$, which is part
of the composite error term in the random effect model.
Fixed effect model setup:
$$ y_{i,t} - \bar y_i = (X_{i,t} - \bar X_i)' \beta + \gamma (y_{i, t-1} - \overline{y_{i,-1}}) + (\epsilon_{i,t} - \bar \epsilon_i)$$ {#eq-dynamic-panel-3}
where $\overline{y_{i,-1}}$ is the unit mean of the *lagged* dependent
variable. This is not exactly $\bar y_i$ (the mean of current $y_{i,t}$). Over
the usable periods the two are $(y_{i2}+\cdots+y_{iT})/(T-1)$ and
$(y_{i1}+\cdots+y_{i,T-1})/(T-1)$, so their difference is exactly
$$\frac{y_{iT}-y_{i1}}{T-1},$$ {#eq-dynamic-panel-mean-gap}
the endpoints and nothing else. Balance does not make that vanish -- only $T$
growing does, under stability. The distinction is asymptotically negligible and
finite-sample real.
@nickell-1981 shows that [see also @anderson-hsiao-1981]
$$Cov( (y_{i,t-1}- \overline{y_{i,-1}}), (\epsilon_{i,t} - \bar \epsilon_i )) \approx -\frac{\sigma_\epsilon^2}{T (1-\gamma)^2} [\frac{(T-1)-T \gamma + \gamma^T}{T}]$$ {#eq-dynamic-panel-4}
which indicates that the demeaned lagged $y$
is correlated with the demeaned error term. The correlation may be
large if $T$ is small, but when $T$ is big, then the correlation goes
down to near zero. When $T$ is big, we don't have a problem with
fixed effect model.
## How Big Is the Bias
When $T$ is small, which is typically the case in many microeconomic settings, then we say the fixed effect model with a lagged dependent variable is inconsistent. But how bad is it?
The limit of $\hat \gamma - \gamma$ is approximately $-\frac{(1+\gamma)}{T-1}$. When $T=10$ and $\gamma=.5$, the bias is about $-0.167$ which is $1/3$ of the true value.
But a simulation study [@judson-owen-1999] shows that the bias can be as big as $20\%$ of the true coefficient even when $T=30$.
## Anderson and Hsiao estimator
@anderson-hsiao-1981 suggested looking at the first difference estimator:
$$ y_{i,t} - y_{i,t-1} = (X_{i,t} - X_{i,t-1})' \beta + \gamma (y_{i,t-1} - y_{i,t-2}) + (\epsilon_{i,t} - \epsilon_{i,t-1}) $$ {#eq-dynamic-panel-5}
or
$$ \Delta y_{i,t}= \Delta X_{i,t} \beta + \gamma \Delta y_{i,t-1} + \Delta \epsilon_{i,t} $$ {#eq-dynamic-panel-6}
This does not solve the endogeneity problem, since $\Delta y_{i,t-1}$ is still correlated with the error term. AH's idea is to instrument $\Delta y_{i,t-1}$ with the past level $y_{i,t-2}$, or past difference $y_{i,t-2}-y_{i,t-3}$. This estimator is consistent, since neither of these instruments is correlated with $\Delta \epsilon_{i,t}$ -- provided the idiosyncratic error is serially uncorrelated. That proviso carries the argument. If $\epsilon_{i,t}$ follows a moving average of order $q$, the levels $y_{i,t-2-q}$ and older remain valid, so we can reach further back. If instead $\epsilon_{i,t}$ is AR(1), $\epsilon_{i,t} = \rho \epsilon_{i,t-1} + \nu_{i,t}$ with $|\rho|<1$, no finite lag works. For a stationary series with $y_{i,t} = \gamma y_{i,t-1} + \epsilon_{i,t}$, writing $\sigma^2_\epsilon$ for the variance of $\epsilon_{i,t}$, the covariance between the level $s \geq 1$ periods back and the differenced error is
$$
\operatorname{Cov}(y_{i,t-s}, \Delta\epsilon_{i,t}) = \frac{(\rho-1)\rho^{s-1}\sigma^2_\epsilon}{1-\gamma\rho}.
$$ {#eq-dynamic-panel-ar-cov}
To derive it, write $y_{i,t-s} = \sum_{k \geq 0} \gamma^k \epsilon_{i,t-s-k}$ and use $\operatorname{Cov}(\epsilon_{i,t-j}, \epsilon_{i,t}) = \rho^j \sigma^2_\epsilon$. The covariance shrinks with $s$ but is never zero. Older lags are weaker violations, not valid instruments. Under AR errors we need an explicit model of the error process, different moment restrictions, or external instruments.
One implication of the assumption is testable, which is the point of the Arellano-Bond test for serial correlation in the differenced residuals. First-order correlation is expected by construction, since $\Delta \epsilon_{i,t}$ and $\Delta \epsilon_{i,t-1}$ share $\epsilon_{i,t-1}$; it is the *second*-order test that carries information. Rejecting AR(2) says $\epsilon_{i,t}$ is serially correlated, so $y_{i,t-2}$ is not a valid instrument. If the correlation is a short moving average, deeper lags restore validity; if it is autoregressive, they do not.
The other regressors need classifying too, because that is what decides how they are instrumented. Strictly exogenous $X$ can serve as its own instrument. Predetermined $X$ -- correlated with past shocks but not with current or future ones -- is instrumented by its own lags from $t-1$ backwards. Endogenous $X$ is treated like the lagged dependent variable, with lags from $t-2$ backwards. Misclassifying a regressor here is one of the commoner ways a difference-GMM specification goes quietly invalid.
## Arellano-Bond estimator
@arellano-bond-1991 expanded the idea by using additional lags of the dependent variable as instruments. For example, both $y_{i,t-2}$ and $y_{i,t-3}$ can be used as instruments. In fact, as $t$ increases, the number of instruments available also increases. In period 3 only $y_{i,1}$ is available. In period 4 $y_{i,1}$ and $y_{i,2}$ are available. In period 5 $y_{i,1}$ and $y_{i,2}$ and $y_{i,3}$ are available, and so on. In other words, we'll have an instrument matrix with one row for each time period that we are instrumenting:
$$Z_i =
\begin{bmatrix}
y_{i,1} & \ 0 & \ 0 & \ 0
& \ 0 & \ 0 & \ \cdots & \ 0 & \ 0 & \ 0 \\ 0 & \ y_{i,1} & \ y_{i,2} &
\ 0 & \ 0 & \ 0 & \ \cdots & \ 0 & \ 0 & \ 0 \\ 0 & \ 0 & \ 0 & \
y_{i,1} & \ y_{i,2} & \ y_{i,3} & \ \cdots & \ 0 & \ 0 & \ 0 \\ \vdots & \ \vdots & \ \vdots & \ \vdots & \ \vdots & \ \ddots & \ \cdots & \ \vdots & \ \vdots & \ \vdots \\ 0 & \ 0 & \ 0 & \ 0 & \ 0 & \ \cdots & \ 0 & \ y_{i,1} & \ \cdots & \ y_{i,T-2}
\end{bmatrix}
$$ {#eq-dynamic-panel-7}
This is the so called difference GMM estimator.
## Blundell and Bond estimator
AB model has a problem: when the instruments are weak, the estimator is not good. That will happen when $y$ follows random walk or near random walk. In that case the past levels won't be a good predictor of the future changes.
@blundell-bond-1998 add a second set of moment conditions in *levels*. The basic idea
is that lagged differences $\Delta y_{i,t-1}$ are uncorrelated with the
composite error $C_i + \epsilon_{i,t}$ under an additional
initial-condition/stationarity restriction, so they can instrument the
level equation.
This is implemented by so-called *system GMM*, which stacks two
equations and estimates them jointly:
- the **differenced equation** ($\Delta y_{i,t}$), instrumented by
lagged *levels* $y_{i,t-2}, y_{i,t-3}, \dots$ (the Arellano--Bond
moments); and
- the **level equation** ($y_{i,t}$ in levels, keeping $C_i$),
instrumented by lagged *differences* $\Delta y_{i,t-1}$.
The level-equation moments are valid only under the extra assumption
that the initial deviations from the long-run mean are uncorrelated
with $C_i$ (mean stationarity of the process). System GMM is more
efficient than difference GMM when $y$ is persistent (near a random
walk), and the level equation lets time-invariant regressors enter, which
differencing removes altogether. That they appear is not the same as their
coefficients being identified. A time-invariant regressor has no within
variation, so its own lagged differences cannot instrument it. Identification
comes from the level moments, and it requires the regressor to be uncorrelated
with the unit effect $C_i$, or an external instrument for it. For a
time-invariant regressor correlated with $C_i$ and lacking such an instrument,
system GMM reports a coefficient that is not identified. A practical warning:
the instrument count grows with $T^2$, so *instrument proliferation*
can overfit the endogenous regressors and weaken the Hansen $J$ test;
lags should be collapsed or capped in practice.
## Diagnostics in practice
The warning about instrument proliferation is easy to state and easy to ignore. It
is worth seeing what it does to real estimates, and what the standard diagnostics
look like when they are working.
The data are Arellano and Bond's own: an unbalanced panel of 140 UK firms observed
between 1976 and 1984, shipped with `plm` as `EmplUK`. The specification is theirs
too -- log employment on its own first two lags, current and lagged log wages, three
lags of log capital, current and lagged log output, with firm and year effects
removed and two-step weighting. Only the instrument set changes across the three
fits: every available lag of log employment from $t-2$ back, the same capped at
three lags, and then the system-GMM version that adds the level-equation moments.
```{r}
#| label: dynpanel-diagnostics
#| warning: false
#| message: false
library(plm)
data("EmplUK", package = "plm")
dif_full <- pgmm(log(emp) ~ lag(log(emp), 1:2) + lag(log(wage), 0:1) +
lag(log(capital), 0:2) + lag(log(output), 0:1) |
lag(log(emp), 2:99),
data = EmplUK, effect = "twoways", model = "twosteps")
dif_cap <- pgmm(log(emp) ~ lag(log(emp), 1:2) + lag(log(wage), 0:1) +
lag(log(capital), 0:2) + lag(log(output), 0:1) |
lag(log(emp), 2:4),
data = EmplUK, effect = "twoways", model = "twosteps")
sys <- pgmm(log(emp) ~ lag(log(emp), 1:2) + lag(log(wage), 0:1) +
lag(log(capital), 0:2) + lag(log(output), 0:1) |
lag(log(emp), 2:99),
data = EmplUK, effect = "twoways", model = "twosteps",
transformation = "ld")
diag_row <- function(fit, label) {
co <- summary(fit, robust = TRUE)$coefficients
sg <- sargan(fit)
data.frame(specification = label,
moments = ncol(fit$W[[1]]),
lag1 = round(co[1, 1], 3),
se = round(co[1, 2], 3),
lag2 = round(co[2, 1], 3),
max_root = round(max(Mod(polyroot(c(-co[2, 1], -co[1, 1], 1)))), 3),
sargan_p = round(sg$p.value, 3),
AR1_p = round(mtest(fit, order = 1)$p.value, 3),
AR2_p = round(mtest(fit, order = 2)$p.value, 3))
}
rbind(diag_row(dif_full, "difference GMM, lags 2+"),
diag_row(dif_cap, "difference GMM, lags 2-4"),
diag_row(sys, "system GMM"))
```
Read the AR columns first, because they are the ones that can invalidate everything
else. First-order serial correlation in the differenced residuals is expected:
$\Delta \epsilon_{i,t}$ and $\Delta \epsilon_{i,t-1}$ both contain
$\epsilon_{i,t-1}$, so a small AR(1) $p$-value is the normal state of affairs and
says nothing against the specification. The AR(2) test is the informative one, and
none of the three fits shows evidence that the instrumenting lag sits too close.
The Sargan column passes in all three cases, which is exactly where the
instrument-count warning earns its keep. The full difference-GMM fit imposes 40
moment conditions on 15 parameters across 140 firms; the system-GMM fit imposes 55.
A Sargan or Hansen test with many moments and few groups has little power, so a
comfortable $p$-value is weak reassurance rather than strong evidence. The test is
being asked to detect a violation using an instrument set flexible enough to fit
almost anything.
The coefficients show what that costs. Capping the instruments at three lags cuts
the moment conditions from 40 to 30, moves the coefficient on lagged log employment
from about $0.65$ to about $0.44$, and nearly doubles its standard error. That is
the honest trade: fewer, better-behaved instruments give less precision. System GMM
goes the other way and returns a first-lag coefficient above $1$ with a standard
error near $0.05$, which should stop the reader rather than reassure them. With two
lags, the first coefficient alone does not decide whether the process is stable.
Write $\gamma_1$ and $\gamma_2$ for the coefficients on the first and second lags of
log employment. The process is stable when both roots $z$ of
$z^2 - \gamma_1 z - \gamma_2 = 0$ have modulus below one, and `max_root` reports the
larger modulus. A first-lag coefficient of 1.1 with a second-lag coefficient of
$-0.3$, for example, gives roots 0.6 and 0.5, which is stable. For system GMM the
coefficients are 1.114 and $-0.099$ and the larger root is 1.017, so the point
estimate implies an explosive employment process. The tight interval around it
comes from 55 moment conditions on 140 firms. Every diagnostic in the
table passes. The estimate is still not credible.
So what to report: the AR(2) test, the Sargan or Hansen statistic with its degrees
of freedom, the instrument count next to the number of groups, and the estimate
under at least one narrower instrument set. The last of those does most of the
work, because it is the one thing in the list that a flexible instrument set cannot
make look good.
## Summary
A lagged dependent variable is correlated with the unit effect, so pooled OLS and random effects are inconsistent. Fixed effects is inconsistent too when $T$ is small, because the demeaned lag is correlated with the demeaned error. This is the Nickell bias, roughly $-(1+\gamma)/(T-1)$. Anderson-Hsiao first-differences the model and instruments the lagged difference with earlier levels. Arellano-Bond difference GMM uses all available lags as instruments. Blundell-Bond system GMM adds moments in levels, which helps when the series is persistent but needs an initial-condition restriction.
On Arellano and Bond's UK firm data, every diagnostic passes for all three instrument sets. Capping the instruments at three lags moves the employment coefficient from about 0.65 to 0.44 and nearly doubles its standard error. System GMM returns a first-lag coefficient above 1 with a small standard error. With both lags, the larger root of the lag polynomial is 1.017, so the point estimate implies an explosive process, which is not credible. Report the AR(2) test, the Sargan or Hansen statistic with its degrees of freedom, and the instrument count against the number of groups. Also report the estimate under a narrower instrument set.