2  Method of Moments and GMM

Readings

Cameron and Trivedi (2005), Ch. 6.1–6.5; B. E. Hansen (2022a), Ch. 12 (instrumental variables) and Ch. 13 (GMM) and 17.36–17.42 (dynamic panels); B. E. Hansen (2022b), Ch. 11 (method of moments); Wooldridge (2010), Ch. 8 and 14. Potential outcomes and weighting (Section 2.9): Imbens and Wooldridge (2009), Sections 1–5; Wooldridge (2010), Ch. 21.1–21.3. Applications discussed in class (exam-relevant, Section 2.10): Arellano and Bond (1991) and Imai and Ratkovic (2014).

Maximum likelihood requires the full distribution of the data. Many economic models deliver less: a set of expectations that should be zero at the true parameter value. The method of moments (MM) and its generalization, the generalized method of moments (GMM), turn such moment conditions directly into estimators. OLS, IV, 2SLS and ML are all special cases, and the GMM framework gives a single recipe for their asymptotic distribution and for efficient estimation when there are more conditions than parameters (L. P. Hansen 1982).

2.1 Moment conditions

Let \(\bw_i\) collect all observed variables for unit \(i\) (outcomes, regressors, instruments) and let \(\btheta\in\Theta\subset\mathbb{R}^k\).

Definition 2.1 (Moment function) A \(q\times1\) vector function \(\bpsi(\bw_i,\btheta)\) with \(q\ge k\) is a moment function if \[ \E\big[\bpsi(\bw_i,\btheta_0)\big]=\bm 0 . \] This equation is a (population) moment condition or moment restriction.

A moment function depends only on the data and the parameters, it has at least as many elements as there are parameters, and its expectation is zero at the true value. Three examples recur throughout the chapter.

Example 2.1 (Familiar estimators as moment estimators)  

  1. Mean. \(\psi(y_i,\mu)=y_i-\mu\). The sample analogue \(\frac1n\sum_i(y_i-\hat\mu)=0\) gives \(\hat\mu=\bar y\).
  2. OLS. In \(y_i=\bx_i'\bbeta+u_i\), the assumption \(\E[u_i\mid\bx_i]=0\) implies the \(k\) conditions \(\E[\bx_i(y_i-\bx_i'\bbeta)]=\bm 0\). Solving the sample analogue gives \(\hat\bbeta=\big(\sum_i\bx_i\bx_i'\big)^{-1}\sum_i\bx_iy_i\).
  3. Maximum likelihood. Under correct specification the score has mean zero (Theorem 1.2). With \(\bpsi(\bw_i,\btheta)=\partial\ln f(y_i\mid\bx_i;\btheta)/\partial\btheta\), the MM estimator is the root of the score, i.e. the MLE.

2.2 The method of moments estimator

Definition 2.2 (Method of moments estimator) If \(q=k\), the MM estimator \(\hat\btheta\) solves the \(k\) sample moment conditions \[ \bar\bg_n(\hat\btheta)\equiv\frac1n\sum_{i=1}^n\bpsi(\bw_i,\hat\btheta)=\bm 0 . \]

MM estimators are consistent whenever a law of large numbers makes the sample moments converge to the population moments and \(\btheta_0\) is the unique solution of \(\E[\bpsi(\bw_i,\btheta)]=\bm 0\). For OLS, \[ \hat\bbeta=\bbeta+\Big(\tfrac1n\textstyle\sum_i\bx_i\bx_i'\Big)^{-1}\tfrac1n\textstyle\sum_i\bx_iu_i\ \cvp\ \bbeta+\E[\bx_i\bx_i']^{-1}\E[\bx_iu_i]=\bbeta, \] provided \(\E[\bx_i\bx_i']\) is nonsingular.

Theorem 2.1 (Asymptotic distribution of the MM estimator) Under regularity conditions and i.i.d. sampling, \[ \sqrt n(\hat\btheta-\btheta_0)\cvd N\big(\bm 0,\ \bA_0^{-1}\bV_0\bA_0^{-1\prime}\big),\qquad \bA_0=\E\Big[\pd{\bpsi(\bw_i,\btheta_0)}{\btheta'}\Big],\quad \bV_0=\E\big[\bpsi(\bw_i,\btheta_0)\bpsi(\bw_i,\btheta_0)'\big]. \]

Sketch. A mean-value expansion of \(\bar\bg_n(\hat\btheta)=\bm 0\) around \(\btheta_0\) gives \(\bm 0=\bar\bg_n(\btheta_0)+\bA_n(\bar\btheta)(\hat\btheta-\btheta_0)\) with \(\bA_n=\frac1n\sum_i\partial\bpsi_i/\partial\btheta'\). Hence \(\sqrt n(\hat\btheta-\btheta_0)=-\bA_n^{-1}\sqrt n\,\bar\bg_n(\btheta_0)\). The LLN gives \(\bA_n\cvp\bA_0\), the CLT gives \(\sqrt n\,\bar\bg_n(\btheta_0)\cvd N(\bm 0,\bV_0)\), and Slutsky does the rest. This is the same argument as for the MLE in Chapter 1; the MLE simply has \(\bA_0=-\mathcal I_1\) and \(\bV_0=\mathcal I_1\).

The variance is estimated by the sandwich \(\hat\bA^{-1}\hat\bV\hat\bA^{-1\prime}\) with \(\hat\bA=\frac1n\sum_i\partial\bpsi_i(\hat\btheta)/\partial\btheta'\) and \(\hat\bV=\frac1n\sum_i\bpsi_i(\hat\btheta)\bpsi_i(\hat\btheta)'\).

Example 2.2 (OLS under heteroskedasticity) With \(\bpsi=\bx_i(y_i-\bx_i'\bbeta)\) we get \(\bA_0=-\E[\bx_i\bx_i']\) and \(\bV_0=\E[u_i^2\bx_i\bx_i']\), so \[ \sqrt n(\hat\bbeta-\bbeta)\cvd N\big(\bm 0,\ \E[\bx_i\bx_i']^{-1}\E[u_i^2\bx_i\bx_i']\E[\bx_i\bx_i']^{-1}\big). \] White’s heteroskedasticity-robust variance estimator is the MM sandwich for OLS. Likewise, the PML sandwich in Section 1.6 is the MM sandwich with the score as moment function.

2.3 The generalized method of moments

When \(q>k\) the model is overidentified: in general no \(\btheta\) sets all \(q\) sample moments to zero at once. GMM instead makes them as small as possible in a quadratic metric.

Example 2.3 (Two sets of conditions for one regression) If, in addition to \(\E[u_i\mid\bx_i]=0\), the errors are conditionally symmetric, then \(\E[u_i^3\mid\bx_i]=0\) and \[ \E\begin{pmatrix}\bx_i(y_i-\bx_i'\bbeta)\\ \bx_i(y_i-\bx_i'\bbeta)^3\end{pmatrix}=\bm 0 , \] which gives \(2k\) conditions for \(k\) parameters.

Definition 2.3 (GMM estimator) Let \(\bW_n\) be a \(q\times q\) symmetric positive definite weighting matrix, possibly data dependent. The GMM estimator is \[ \hat\btheta(\bW_n)=\arg\min_{\btheta\in\Theta}\ Q_n(\btheta),\qquad Q_n(\btheta)=\bar\bg_n(\btheta)'\,\bW_n\,\bar\bg_n(\btheta). \]

The first-order conditions are \[ \bA_n(\hat\btheta)'\,\bW_n\,\bar\bg_n(\hat\btheta)=\bm 0,\qquad \bA_n(\btheta)=\frac1n\sum_{i=1}^n\pd{\bpsi(\bw_i,\btheta)}{\btheta'} , \] i.e. GMM sets \(k\) linear combinations of the \(q\) sample moments to zero. If \(q=k\), \(\bA_n\) is square and (generically) invertible, so the FOC reduce to \(\bar\bg_n(\hat\btheta)=\bm 0\): in the just-identified case GMM is MM, whatever \(\bW_n\).

2.4 Asymptotic properties of GMM

Theorem 2.2 (Consistency and asymptotic normality of GMM) Assume i.i.d. data and

  1. identification: \(\E[\bpsi(\bw_i,\btheta)]=\bm 0\) if and only if \(\btheta=\btheta_0\);

  2. \(\bA_0=\E[\partial\bpsi(\bw_i,\btheta_0)/\partial\btheta']\) is finite with full column rank \(k\);

  3. \(\bW_n\cvp\bW_0\), symmetric positive definite;

  4. \(\sqrt n\,\bar\bg_n(\btheta_0)\cvd N(\bm 0,\bV_0)\), \(\bV_0=\E[\bpsi_i\bpsi_i']\) positive definite;

plus standard regularity conditions (compact \(\Theta\), uniform convergence, smoothness). Then \(\hat\btheta\cvp\btheta_0\) and \[ \sqrt n(\hat\btheta-\btheta_0)\cvd N\Big(\bm 0,\ (\bA_0'\bW_0\bA_0)^{-1}\bA_0'\bW_0\bV_0\bW_0\bA_0(\bA_0'\bW_0\bA_0)^{-1}\Big). \]

The proof follows the MM sketch: expand the FOC around \(\btheta_0\) and solve, \(\sqrt n(\hat\btheta-\btheta_0)\approx-(\bA_0'\bW_0\bA_0)^{-1}\bA_0'\bW_0\sqrt n\,\bar\bg_n(\btheta_0)\). Two features are worth stressing. First, the weighting matrix does not affect consistency, only the asymptotic variance. Second, condition (ii) is the local version of identification: if \(\bA_0\) has deficient rank, the moments do not pin down all parameters, which is the essence of weak or irrelevant instruments.

The variance is estimated by replacing \(\bA_0,\bV_0,\bW_0\) by \(\hat\bA=\bA_n(\hat\btheta)\), \(\hat\bV=\frac1n\sum_i\bpsi_i(\hat\btheta)\bpsi_i(\hat\btheta)'\) and \(\bW_n\), and dividing by \(n\).

2.5 Efficient GMM

Theorem 2.3 (Optimal weighting matrix) Among all choices of \(\bW_0\), \(\bW_0^*=\bV_0^{-1}\) minimizes the asymptotic variance (in the matrix sense of Chapter 1). The minimum is \[ \AVar\big(\hat\btheta(\bV_0^{-1})\big)=\big(\bA_0'\bV_0^{-1}\bA_0\big)^{-1}. \]

Proof. Write \(\bm B=(\bA'\bV^{-1}\bA)^{-1}\bA'\bV^{-1}\) and \(\bm C=(\bA'\bW\bA)^{-1}\bA'\bW-\bm B\) (dropping subscripts). The asymptotic variance with weight \(\bW\) is \((\bm B+\bm C)\bV(\bm B+\bm C)'\). The cross term vanishes because \(\bm C\bV\bm B'=\big[(\bA'\bW\bA)^{-1}\bA'\bW\bA-(\bA'\bV^{-1}\bA)^{-1}\bA'\bV^{-1}\bA\big](\bA'\bV^{-1}\bA)^{-1}=\bm 0\). Hence the variance equals \((\bA'\bV^{-1}\bA)^{-1}+\bm C\bV\bm C'\), and \(\bm C\bV\bm C'\) is positive semidefinite. \(\square\)

A fact that is useful for such comparisons: for symmetric positive definite \(\bm P\) and \(\bm Q\), \(\bm P-\bm Q\) is positive semidefinite if and only if \(\bm Q^{-1}-\bm P^{-1}\) is. Comparing variances is therefore equivalent to comparing information (precision) matrices.

Intuitively, moments that are measured with more noise get less weight. “Optimal” is relative to a given set of moment conditions: poorly chosen moments remain inefficient even with the best weight. Adding valid moment conditions never increases the asymptotic variance of efficient GMM.

\(\bV_0\) is unknown, so efficient GMM is implemented in steps:

  1. Estimate \(\hat\btheta^{(1)}\) with a convenient weight, e.g. \(\bW_n=\bI\) or, in linear IV, \((\bZ'\bZ/n)^{-1}\). It is consistent but inefficient.
  2. Compute \(\hat\bV=\frac1n\sum_i\bpsi_i(\hat\btheta^{(1)})\bpsi_i(\hat\btheta^{(1)})'\) and re-estimate with \(\bW_n=\hat\bV^{-1}\). This two-step GMM estimator is asymptotically efficient.

Repeating step 2 until convergence gives iterated GMM; letting the weight depend on \(\btheta\) inside the objective, \(Q_n(\btheta)=\bar\bg_n(\btheta)'\hat\bV(\btheta)^{-1}\bar\bg_n(\btheta)\), gives the continuously updated estimator (CUE). All three are asymptotically equivalent. In finite samples, estimating \(\bV_0\) introduces bias, especially with many moment conditions (Altonji and Segal 1996), so efficient GMM need not beat a simple one-step estimator in practice.

2.6 Testing overidentifying restrictions

GMM consistency rests on \(\E[\bpsi(\bw_i,\btheta_0)]=\bm 0\). With \(q>k\) there is information left to check it: at the efficient estimate the sample moments should be close to zero.

Theorem 2.4 (Hansen’s J test (L. P. Hansen 1982)) Let \(\hat\btheta\) be the efficient GMM estimator and \(\hat\bV\) a consistent estimator of \(\bV_0\). Under \(H_0:\E[\bpsi(\bw_i,\btheta_0)]=\bm 0\), \[ J=n\,\bar\bg_n(\hat\btheta)'\,\hat\bV^{-1}\,\bar\bg_n(\hat\btheta)\ \cvd\ \chi^2_{q-k}. \]

Three remarks. The factor \(n\) matters: without it the statistic converges to zero. The degrees of freedom are the number of overidentifying restrictions, \(q-k\); in a just-identified model \(J=0\) by construction and nothing can be tested. Finally, the test has power only against violations that cannot be absorbed by \(\btheta\): if all instruments are invalid in the same direction, \(J\) may not reject. A rejection says that some moment conditions fail, not which.

2.7 Conditional moments and optimal instruments

Models are often stated as a conditional restriction \(\E[\rho(\bw_i,\btheta_0)\mid\bz_i]=0\), e.g. \(\rho=y_i-\bx_i'\bbeta\) with exogenous \(\bz_i\). By the law of iterated expectations, any function \(\bm D(\bz_i)\) yields valid unconditional moments \(\E[\bm D(\bz_i)\rho(\bw_i,\btheta_0)]=\bm 0\), so there are infinitely many GMM estimators. The asymptotically best choice, the optimal instrument, is \[ \bm D^*(\bz_i)=\E\Big[\pd{\rho(\bw_i,\btheta_0)}{\btheta}\,\Big|\,\bz_i\Big]\Big/\Var\big(\rho(\bw_i,\btheta_0)\mid\bz_i\big). \] In the linear model with exogenous regressors (\(\bz_i=\bx_i\)) this is \(-\bx_i/\sigma_i^2\): the efficient moment estimator is weighted least squares (GLS). With endogenous regressors it is \(-\E[\bx_i\mid\bz_i]/\sigma_i^2\), which motivates 2SLS: the first stage approximates \(\E[\bx_i\mid\bz_i]\) by a linear projection.

2.8 Linear instrumental variables as GMM

Consider \(y_i=\bx_i'\bbeta+u_i\) with \(\bx_i\) of dimension \(k\) and some regressors correlated with \(u_i\) (omitted variables, measurement error, simultaneity). OLS is inconsistent. Let \(\bz_i\) be an \(l\times1\) vector of instruments, containing the exogenous regressors, with

  • exogeneity: \(\E[\bz_iu_i]=\bm 0\);
  • relevance: \(\operatorname{rank}\E[\bz_i\bx_i']=k\) (requires \(l\ge k\)), and \(\E[\bz_i\bz_i']\) nonsingular.

The moment function is \(\bpsi(\bw_i,\bbeta)=\bz_i(y_i-\bx_i'\bbeta)\), with sample analogue \(\frac1n\bZ'(\by-\bX\bbeta)\) in matrix notation. Minimizing \(\frac1{n^2}(\by-\bX\bbeta)'\bZ\bW_n\bZ'(\by-\bX\bbeta)\) gives the closed form \[ \hat\bbeta(\bW_n)=\big(\bX'\bZ\bW_n\bZ'\bX\big)^{-1}\bX'\bZ\bW_n\bZ'\by . \] Here \(\bA_0=-\E[\bz_i\bx_i']\) and \(\bV_0=\E[u_i^2\bz_i\bz_i']\). The familiar estimators are special cases.

Table 2.1: Linear GMM estimators
Case Weight \(\bW_n\) Estimator
Just identified, \(l=k\) any IV: \(\hat\bbeta_{IV}=(\bZ'\bX)^{-1}\bZ'\by\)
Overidentified \((\bZ'\bZ)^{-1}\) 2SLS: \(\big[\bX'\bZ(\bZ'\bZ)^{-1}\bZ'\bX\big]^{-1}\bX'\bZ(\bZ'\bZ)^{-1}\bZ'\by\)
Overidentified, homoskedastic \((\hat\sigma^2\bZ'\bZ/n)^{-1}\) (optimal) 2SLS
Overidentified, heteroskedastic \(\big(\frac1n\sum_i\hat u_i^2\bz_i\bz_i'\big)^{-1}\) (optimal) two-step efficient GMM

2SLS is the GMM estimator with \(\bW_n=(\bZ'\bZ)^{-1}\); under homoskedasticity, \(\bV_0=\sigma^2\E[\bz_i\bz_i']\) and this weight is optimal. Under heteroskedasticity both 2SLS and two-step GMM are consistent, GMM is more efficient, and 2SLS standard errors must be heteroskedasticity robust: \[ \widehat{\Var}(\hat\bbeta)=\big(\bX'\bZ\bW_n\bZ'\bX\big)^{-1}\bX'\bZ\bW_n\Big(\sum_i\hat u_i^2\bz_i\bz_i'\Big)\bW_n\bZ'\bX\big(\bX'\bZ\bW_n\bZ'\bX\big)^{-1}. \] For two-step GMM this simplifies to \(\big[\bX'\bZ\big(\sum_i\hat u_i^2\bz_i\bz_i'\big)^{-1}\bZ'\bX\big]^{-1}\).

Weak instruments. If the instruments are only weakly correlated with the endogenous regressors, \(\bA_0\) is close to rank deficient. IV and 2SLS are then biased towards OLS and their normal approximation is poor, even in large samples (Staiger and Stock 1997). Always report the first-stage regression and the \(F\) statistic for the excluded instruments; a common rule of thumb flags \(F<10\) as weak.

2.8.1 Illustration: 2SLS versus efficient GMM

The simulation below has one endogenous regressor, three instruments and errors whose variance depends on the first instrument. Both estimators are consistent, but efficient GMM puts less weight on the noisy moment \(\E[z_{1i}u_i]=0\).

set.seed(2027)
one_sample <- function(n = 500) {
  Z <- cbind(1, matrix(rnorm(3 * n), n))              # constant + 3 instruments
  v <- rnorm(n)
  x <- drop(Z[, 2:4] %*% c(0.4, 0.4, 0.4)) + v
  u <- (0.5 * v + sqrt(0.75) * rnorm(n)) * exp(Z[, 2]) # endogenous, heteroskedastic
  y <- 1 + x + u
  X <- cbind(1, x)
  gmm <- function(W) solve(t(X) %*% Z %*% W %*% t(Z) %*% X, t(X) %*% Z %*% W %*% t(Z) %*% y)
  b_2sls <- gmm(solve(crossprod(Z)))                   # step 1: 2SLS
  S      <- crossprod(Z * drop(y - X %*% b_2sls)) / n
  b_gmm  <- gmm(solve(S))                              # step 2: efficient GMM
  e      <- drop(y - X %*% b_gmm)
  gbar   <- colMeans(Z * e)
  J      <- n * drop(t(gbar) %*% solve(crossprod(Z * e) / n) %*% gbar)
  c(b_2sls = b_2sls[2], b_gmm = b_gmm[2], J_reject = J > qchisq(0.95, df = 2))
}
mc <- t(replicate(1000, one_sample()))
round(c(mean_2sls = mean(mc[, 1]), mean_gmm = mean(mc[, 2]),
        sd_2sls = sd(mc[, 1]), sd_gmm = sd(mc[, 2]),
        J_rejection_rate = mean(mc[, 3])), 3)
#>        mean_2sls         mean_gmm          sd_2sls           sd_gmm 
#>            1.016            1.002            0.273            0.199 
#> J_rejection_rate 
#>            0.039

Both estimators are centred on the true slope of one. The standard deviation of efficient GMM is about a quarter smaller than that of 2SLS. The J test, with \(q-k=4-2=2\) degrees of freedom, rejects the true moment conditions at roughly the nominal 5% rate.

2.9 Two-step estimators as joint GMM

Many estimators proceed in two steps: a first step estimates a nuisance parameter \(\balpha\) (a propensity score, a first-stage regression, a selection equation), and a second step estimates the parameter of interest \(\tau\) given \(\hat\balpha\). Treating \(\hat\balpha\) as known in the second step gives wrong standard errors. Stacking both steps into one MM problem gives the correct ones automatically. We first introduce the leading example of this course, the average treatment effect estimated by inverse probability weighting, and then derive the general result.

2.9.1 Background: potential outcomes and the average treatment effect

Potential outcomes. Let \(D_i\in\{0,1\}\) indicate whether unit \(i\) receives a treatment (a training programme, smoking during pregnancy, a policy). Each unit has two potential outcomes: \(Y_{1i}\) if treated and \(Y_{0i}\) if not (Rubin 1974). The individual effect is \(Y_{1i}-Y_{0i}\). We observe only one of the two, \[ Y_i=D_iY_{1i}+(1-D_i)Y_{0i}, \] so individual effects are never observed. We therefore target averages, most often the average treatment effect \[ \tau=\E[Y_{1i}-Y_{0i}]=\mu_1-\mu_0,\qquad \mu_d=\E[Y_{di}], \] or the average treatment effect on the treated, \(\tau_{T}=\E[Y_{1i}-Y_{0i}\mid D_i=1]\). The notation implicitly assumes that a unit’s outcome does not depend on the treatment of other units.

Why a simple comparison fails. The difference in observed means decomposes as \[ \E[Y_i\mid D_i=1]-\E[Y_i\mid D_i=0]=\underbrace{\E[Y_{1i}-Y_{0i}\mid D_i=1]}_{\tau_T}+\underbrace{\E[Y_{0i}\mid D_i=1]-\E[Y_{0i}\mid D_i=0]}_{\text{selection bias}} . \] If treated and untreated units differ in their untreated outcomes, e.g. mothers who smoke also differ in age, education and marital status, the comparison is biased. Under random assignment \(D_i\) is independent of \((Y_{0i},Y_{1i})\), the selection bias is zero and \(\tau_T=\tau\).

Selection on observables. Without randomization, suppose we observe covariates \(\bx_i\) that capture all differences between the groups that are relevant for the potential outcomes:

  • Unconfoundedness: \((Y_{0i},Y_{1i})\perp D_i\mid\bx_i\). Within cells of \(\bx_i\), treatment is as good as random.
  • Overlap: \(0<p(\bx)<1\) for all \(\bx\) in the support, where \(p(\bx_i)=P(D_i=1\mid\bx_i)\) is the propensity score.

Unconfoundedness is an identifying assumption and cannot be tested with the data; overlap can be checked by comparing the estimated propensity scores of treated and controls.

Identification by weighting. Under these two assumptions \[ \mu_1=\E\Big[\frac{D_iY_i}{p(\bx_i)}\Big],\qquad \mu_0=\E\Big[\frac{(1-D_i)Y_i}{1-p(\bx_i)}\Big],\qquad \tau=\E\Big[\frac{D_iY_i}{p(\bx_i)}-\frac{(1-D_i)Y_i}{1-p(\bx_i)}\Big]. \tag{2.1}\] The proof uses \(D_iY_i=D_iY_{1i}\), the law of iterated expectations and unconfoundedness; it is Problem Set 2, Problem 4(a). The intuition: a treated unit with propensity score \(0.2\) represents five units in the population, of which only one was treated. Weighting each treated unit by \(1/p(\bx_i)\) and each control by \(1/(1-p(\bx_i))\) creates a pseudo-population in which treatment no longer depends on \(\bx_i\). This idea goes back to survey sampling (Horvitz and Thompson 1952); Rosenbaum and Rubin (1983) showed that the propensity score is the key balancing score.

Estimation. Replacing expectations by sample means gives the inverse probability weighting (IPW) estimator \[ \hat\tau_{IPW}=\frac1n\sum_{i=1}^n\Big[\frac{D_iY_i}{\hat p(\bx_i)}-\frac{(1-D_i)Y_i}{1-\hat p(\bx_i)}\Big]. \] In finite samples the weights \(D_i/\hat p(\bx_i)\) need not average to one. The normalized version divides by the sum of the weights within each group, \[ \hat\tau_{norm}=\frac{\sum_iD_iY_i/\hat p(\bx_i)}{\sum_iD_i/\hat p(\bx_i)}-\frac{\sum_i(1-D_i)Y_i/\big(1-\hat p(\bx_i)\big)}{\sum_i(1-D_i)/\big(1-\hat p(\bx_i)\big)}, \] and is usually more stable. With limited overlap some \(\hat p(\bx_i)\) are close to 0 or 1, a few observations get very large weights, and both estimators become imprecise. Regression adjustment, \(\tau=\E[\E(Y_i\mid D_i=1,\bx_i)-\E(Y_i\mid D_i=0,\bx_i)]\), and doubly robust estimators that combine both models are the main alternatives; Imbens and Wooldridge (2009) survey them and Chapter 6 discusses them together with matching, instrumental variables and regression discontinuity.

Why this is a two-step problem. The propensity score is unknown. In practice it is modelled parametrically, typically as a logit \(p(\bx_i;\balpha)=\Lambda(\bx_i'\balpha)\), and \(\balpha\) is estimated by ML in a first step. The ML first-order condition is a moment condition (Example 2.1), so both steps are MM problems: \[ \bpsi_1(\bw_i,\balpha)=\big(D_i-\Lambda(\bx_i'\balpha)\big)\bx_i,\qquad \psi_2(\bw_i,\balpha,\tau)=\frac{D_iY_i}{\Lambda(\bx_i'\balpha)}-\frac{(1-D_i)Y_i}{1-\Lambda(\bx_i'\balpha)}-\tau . \] The question is how the estimation error in \(\hat\balpha\) affects the distribution of \(\hat\tau\).

2.9.2 Stacking the two steps

Let \(\bpsi_1(\bw_i,\balpha)\) (\(k_1\) conditions) define the first step and \(\psi_2(\bw_i,\balpha,\tau)\) the second. The stacked moment function \[ \bpsi(\bw_i,\btheta)=\begin{pmatrix}\bpsi_1(\bw_i,\balpha)\\ \psi_2(\bw_i,\balpha,\tau)\end{pmatrix},\qquad \btheta=(\balpha',\tau)', \] is just identified, and \(\bA_0\) is block lower triangular: \[ \bA_0=\begin{pmatrix}\bA_{11}&\bm 0\\ \bA_{21}&A_{22}\end{pmatrix},\quad \bA_{11}=\E\Big[\pd{\bpsi_1}{\balpha'}\Big],\ \bA_{21}=\E\Big[\pd{\psi_2}{\balpha'}\Big],\ A_{22}=\E\Big[\pd{\psi_2}{\tau}\Big]. \] Applying Theorem 2.1 and reading off the last row gives the influence representation \[ \sqrt n(\hat\tau-\tau_0)=-\frac{1}{A_{22}}\frac1{\sqrt n}\sum_{i=1}^n\Big[\psi_{2i}-\bA_{21}\bA_{11}^{-1}\bpsi_{1i}\Big]+o_p(1). \] The term \(\bA_{21}\bA_{11}^{-1}\bpsi_{1i}\) is the correction for the estimated first step. It vanishes only if \(\bA_{21}=\bm 0\), i.e. if the second-step moment does not depend on \(\balpha\) in expectation. Solving the stacked system jointly gives the same point estimates as the sequential procedure, because the first block does not involve \(\tau\); only the standard errors change.

For IPW, \(A_{22}=-1\) and \(\bA_{21}\neq\bm 0\). A surprising but general feature: when the first step is efficient ML of a correctly specified propensity score model, the correction reduces the variance, so using the estimated propensity score is more efficient than using the true one (Hirano, Imbens, and Ridder 2003). The naive standard error that treats \(\hat p(\bx_i)\) as known is therefore conservative for IPW, but in other two-step problems it can be too small.

Simulation: IPW with the true and the estimated propensity score
set.seed(2027)
one_draw <- function(n = 1000) {
  x  <- rnorm(n)
  p  <- plogis(-0.3 + 0.8 * x)            # true propensity score
  d  <- rbinom(n, 1, p)
  y  <- 1 + 2 * x + d * 1 + rnorm(n)       # true ATE = 1
  ph <- fitted(glm(d ~ x, family = binomial))
  ipw <- function(p) mean(d * y / p - (1 - d) * y / (1 - p))
  c(true_p = ipw(p), estimated_p = ipw(ph))
}
sim <- replicate(2000, one_draw())
round(rbind(mean = rowMeans(sim), sd = apply(sim, 1, sd)), 3)
#>      true_p estimated_p
#> mean  1.000       1.002
#> sd    0.183       0.086

Both versions are centred on the true ATE of one, and the estimator with the estimated propensity score has the clearly smaller standard deviation.

Problem Set 2, Problem 4 derives the moment functions and the blocks of \(\bA_0\) for the average treatment effect on the treated, and Computer Tutorial 2 estimates the model jointly, computes the stacked sandwich variance and compares it with the bootstrap.

2.10 Applications

The two applications below are discussed in class and are part of the exam. They show the two main reasons for using GMM: theory delivers more moment conditions than parameters, and moment conditions can be added to an estimation problem to impose properties we care about.

2.10.1 Dynamic panel data: Arellano and Bond (1991)

Consider the dynamic panel data model \[ y_{it}=\gamma y_{i,t-1}+\bx_{it}'\bbeta+\alpha_i+u_{it},\qquad i=1,\ldots,N,\quad t=1,\ldots,T, \] with an individual effect \(\alpha_i\) and idiosyncratic errors \(u_{it}\) that are serially uncorrelated. Asymptotics are for \(N\to\infty\) with \(T\) fixed and small, as in most micro panels. For simplicity we drop \(\bx_{it}\) in what follows; with strictly exogenous regressors, \(\Delta\bx_{it}\) simply serves as its own instrument.

Why the usual panel estimators fail.

  • Pooled OLS and random effects treat \(\alpha_i+u_{it}\) as the error. But \(y_{i,t-1}=\gamma y_{i,t-2}+\alpha_i+u_{i,t-1}\) depends on \(\alpha_i\), so the regressor is correlated with the error.
  • Fixed effects (within) removes \(\alpha_i\) by subtracting individual means. The demeaned lag \(y_{i,t-1}-\bar y_{i,-1}\) contains \(u_{i,t-1},\ldots\), and the demeaned error contains \(\bar u_i\), which includes the same shocks. The resulting bias is of order \(1/T\) (Nickell 1981) and does not vanish as \(N\to\infty\); with \(T=6\) it is large.
  • First differences remove \(\alpha_i\) as well, \[ \Delta y_{it}=\gamma\,\Delta y_{i,t-1}+\Delta u_{it},\qquad t=3,\ldots,T, \] but \(\Delta y_{i,t-1}=y_{i,t-1}-y_{i,t-2}\) contains \(u_{i,t-1}\), which also appears in \(\Delta u_{it}=u_{it}-u_{i,t-1}\). OLS on the differenced equation is inconsistent too.

Instruments from the past. Lags dated \(t-2\) and earlier are correlated with \(\Delta y_{i,t-1}\) but not with \(\Delta u_{it}\) (because \(u_{it}\) is serially uncorrelated). Anderson and Hsiao (1982) use \(y_{i,t-2}\) as a single instrument in a just-identified IV regression. Arellano and Bond (1991) observe that all earlier values are valid: \[ \E\big[y_{i,t-s}\,\Delta u_{it}\big]=0,\qquad s\ge2,\quad t=3,\ldots,T . \] For \(t=3\) only \(y_{i1}\) is available, for \(t=4\) both \(y_{i1}\) and \(y_{i2}\), and so on. Stacking the equations for \(t=3,\ldots,T\) for individual \(i\), the instrument matrix is block diagonal, \[ \bZ_i=\begin{pmatrix}y_{i1}&0&0&0&\cdots&0\\0&y_{i1}&y_{i2}&0&\cdots&0\\ \vdots&&&\ddots&&\vdots\\0&\cdots&&y_{i1}&\cdots&y_{i,T-2}\end{pmatrix}, \] with \(L=(T-1)(T-2)/2\) columns, and the moment conditions are \(\E[\bZ_i'\Delta\bu_i]=\bm0\). With one parameter and \(L>1\) conditions the model is overidentified, and efficient GMM (Theorem 2.3) combines the instruments optimally.

One-step and two-step GMM. If the \(u_{it}\) are homoskedastic and serially uncorrelated, \(\Var[\Delta\bu_i]=\sigma^2\bm H\) with \(\bm H\) the \((T-2)\times(T-2)\) matrix with 2 on the diagonal and \(-1\) next to it (the differenced errors follow an MA(1)). The one-step estimator uses \(\bW=\big(\sum_i\bZ_i'\bm H\bZ_i\big)^{-1}\) and needs no preliminary estimate. The two-step estimator uses the robust weight \(\big(\sum_i\bZ_i'\widehat{\Delta\bu}_i\widehat{\Delta\bu}_i'\bZ_i\big)^{-1}\) built from one-step residuals. The overidentifying restrictions are tested with Hansen’s \(J\) statistic (Theorem 2.4), with \(L-1\) degrees of freedom here.

Serial correlation. Everything rests on \(u_{it}\) being serially uncorrelated. Then \(\Delta u_{it}\) is correlated with \(\Delta u_{i,t-1}\) (first-order correlation is expected) but not with \(\Delta u_{i,t-2}\). Arellano and Bond propose testing for second-order serial correlation in the differenced residuals; rejection invalidates \(y_{i,t-2}\) as an instrument.

Weak instruments. If \(\gamma\) is close to one, lagged levels are weak instruments for differences and the estimator becomes imprecise and biased in finite samples. The system GMM estimator of Blundell and Bond (1998) adds moment conditions for the equation in levels, with lagged differences as instruments.

Table 2.2: Estimators of \(\gamma=0.5\) in \(y_{it}=\gamma y_{i,t-1}+\alpha_i+u_{it}\) with \(\alpha_i,u_{it}\sim N(0,1)\), \(N=500\), \(T=6\), stationary initial condition; 500 samples. Anderson<U+2013>Hsiao: instrument \(y_{i,t-2}\). Arellano<U+2013>Bond: all lags, \(L=10\) instruments. The two-step \(J\) test (9 degrees of freedom) rejected in 5.6% of the samples at the 5% level.
estimator mean bias sd
Pooled OLS 0.874 0.374 0.009
Fixed effects (within) 0.168 -0.332 0.022
Anderson-Hsiao IV 0.503 0.003 0.065
Arellano-Bond, one-step 0.488 -0.012 0.055
Arellano-Bond, two-step 0.489 -0.011 0.056

Pooled OLS is biased upward because the lag picks up the individual effect; fixed effects is biased downward (Nickell bias). Both IV/GMM estimators are close to unbiased, and using all available lags reduces the standard deviation by about 15% relative to the single Anderson–Hsiao instrument (Table 2.2).

2.10.2 Covariate balancing propensity score: Imai and Ratkovic (2014)

The IPW estimator of Section 2.9.1 requires an estimate of the propensity score \(p(\bx_i;\balpha)\), usually a logit estimated by ML. Its purpose, however, is not to predict treatment but to balance the covariates: after weighting, treated and controls should have the same covariate distribution. A slightly misspecified logit can fit \(D_i\) well and still leave the weighted covariate means far apart, which biases the IPW estimate.

Imai and Ratkovic (2014) estimate the propensity score by GMM and add balance conditions to the logit score. With \(\tilde\bx_i=f(\bx_i)\) a vector of functions of the covariates (e.g. \(\bx_i\) itself, or \(\bx_i\) and its squares), the population balance condition for the ATE is \[ \E\left[\frac{D_i\tilde\bx_i}{p(\bx_i;\balpha)}-\frac{(1-D_i)\tilde\bx_i}{1-p(\bx_i;\balpha)}\right]=\E\left[\frac{D_i-p(\bx_i;\balpha)}{p(\bx_i;\balpha)\{1-p(\bx_i;\balpha)\}}\,\tilde\bx_i\right]=\bm0 , \] which holds at the true \(\balpha\) by the argument of Equation 2.1: both inverse-weighted means equal \(\E[\tilde\bx_i]\).

  • Just-identified CBPS uses only the balance conditions with \(\tilde\bx_i=\bx_i\) (\(k\) conditions for \(k\) parameters). The sample conditions hold exactly, so the weighted covariate means of treated and controls are identical in the sample. Because \(\bx_i\) contains a constant, the weights \(D_i/\hat p_i\) and \((1-D_i)/(1-\hat p_i)\) then each average to one: the unnormalized and normalized IPW estimators of Section 2.9.1 coincide.
  • Overidentified CBPS stacks the logit score \(\big(D_i-p(\bx_i;\balpha)\big)\bx_i\) and the balance conditions (\(2k\) conditions for \(k\) parameters) and estimates \(\balpha\) by two-step efficient GMM. If the logit model is correct, both sets of conditions hold, and Hansen’s \(J\) test with \(k\) degrees of freedom is a specification test of the propensity score model.
Table 2.3: Propensity score for smoking during pregnancy (data of Computer Tutorial 2, \(N=4642\)). Standardized mean differences (SMD) of the covariates between smokers and non-smokers before and after normalized IPW weighting, the IPW estimates of the ATE (grams) and the overidentification test. Specification A: logit index linear in marital status, age, age squared, education and first birth. Specification B adds education squared.
weights A: max |SMD| A: ATE B: max |SMD| B: ATE
none (raw difference) 0.595 0.629
logit ML 0.136 -231.7 0.011 -222.3
CBPS, just-identified 0.000 -229.5 0.000 -222.8
CBPS, overidentified 0.212 -236.6 0.012 -223.4

Without weighting, smokers and non-smokers differ by up to 0.6 standard deviations (marital status and education). In specification A, the logit leaves an imbalance of about 0.14 standard deviations in education, the overidentified CBPS is even worse balanced, and the overidentification test rejects the propensity score model clearly: \(J=72.8\) with 6 degrees of freedom in specification A and \(J=7.0\) with 7 degrees of freedom in specification B. Adding education squared (specification B) removes the imbalance, the test no longer rejects, and all three weighting schemes give an ATE of about \(-222\) g (Table 2.3). The just-identified CBPS balances the covariates exactly by construction in both specifications. The example shows the two uses of the method: CBPS weights are more robust to a misspecified propensity score, and the \(J\) test tells us when the specification needs work.

2.11 Computer tutorial 2

Learning goals. Estimate a two-step estimator as one joint MM problem with nleqslv; compute its sandwich variance by hand and compare with the bootstrap; implement 2SLS, efficient two-step GMM and the J test in matrix form and check them against AER::ivreg.

Packages. nleqslv, boot, sandwich, lmtest, AER. Data. cattaneo2.csv (Cattaneo 2010), 4642 births; card1995.csv (Card 1995), 3613 young men from the NLS 1976 cross-section.

2.11.1 Problem 1: The effect of smoking on birth weight (IPW as joint MM)

This problem uses the IPW results of Section 2.9 of the lecture notes and Problem Set 2, Problem 4(a).

Variable Description
bweight infant birth weight (grams)
mbsmoke = 1 if the mother smoked during pregnancy
mmarried = 1 if the mother is married
mage mother’s age (years)
medu mother’s education (years)
fbaby = 1 if first baby

We want the average treatment effect \(\tau\) of mbsmoke on bweight. The propensity score is modelled as a logit, \[ P(\texttt{mbsmoke}=1\mid X_i)=\Lambda\big(\alpha_0+\alpha_1\texttt{mmarried}+\alpha_2\texttt{mage}+\alpha_3\texttt{mage}^2+\alpha_4\texttt{fbaby}+\alpha_5\texttt{medu}\big). \]

  1. Compute the raw difference in mean birth weight between smokers and non-smokers. Why is it unlikely to be the ATE?

  2. Write the stacked moment function for \(\btheta=(\balpha',\tau)'\) from Section 2.9.2 of the lecture notes as an R function that returns the \(k+1\) sample moments, and solve the system with nleqslv. Compare \(\hat\balpha\) with glm and \(\hat\tau\) with the IPW formula evaluated at the glm propensity score. Why do they coincide?

  3. Estimate the asymptotic variance of \(\hat\btheta\) with the MM sandwich \(\hat\bA^{-1}\hat\bV\hat\bA^{-1\prime}/n\), computing \(\hat\bA\) analytically. Report the standard error of \(\hat\tau\) and compare it with the “naive” standard error that treats the propensity score as known.

  4. Compute the ATE with normalized weights (weights that sum to one within each treatment group).

  5. Estimate the standard errors of both ATE estimators by the nonparametric bootstrap (500 replications). Remember that each bootstrap replication has to re-estimate the propensity score.

2.11.2 Problem 2: Returns to schooling with college proximity (IV and GMM)

Variable Description
lwage76 log hourly wage, 1976
ed76 years of education, 1976
age76 age in 1976
black, reg76r, smsa76r = 1 if black; lives in the South; lives in an urban area (1976)
nearc4a, nearc4b = 1 if grew up near a 4-year public / private college

Following Card (1995) and B. E. Hansen (2022a, Ch. 12), consider \[ \log w_i=\beta_0+\beta_1\,\texttt{educ}_i+\beta_2\,\texttt{exper}_i+\beta_3\,\texttt{exper}_i^2/100+\beta_4\texttt{black}_i+\beta_5\texttt{south}_i+\beta_6\texttt{urban}_i+u_i , \] with potential experience \(\texttt{exper}=\texttt{age}-\texttt{educ}-6\). Education is endogenous (ability is omitted), and so is experience, because it is a function of education. The excluded instruments are nearc4a, nearc4b, age76 and age76^2/100.

  1. Construct exper and exper2, drop observations with missing values and estimate the equation by OLS.

  2. Estimate the first stage for ed76. Test the joint significance of nearc4a and nearc4b with a heteroskedasticity-robust \(F\) test. Are the instruments strong?

  3. Count the moment conditions \(q\) and parameters \(k\). Compute 2SLS with the GMM formula and \(\bW_n=(\bZ'\bZ)^{-1}\), with heteroskedasticity-robust standard errors. Check your results with AER::ivreg and sandwich.

  4. Compute the two-step efficient GMM estimator and its standard errors.

  5. Compute Hansen’s J statistic and its p-value. What does it test here?

  6. Compare the estimated returns to schooling across OLS, 2SLS and GMM.

2.12 Exercises

Problem Set 2 contains the analytical exercises for this chapter:

  • Problem 1: two MM estimators of an exponential mean, their asymptotic distributions, efficient GMM combining both moments, and why the identity weighting matrix depends on the units of measurement.
  • Problem 2: ML, MM and GMM for the beta distribution.
  • Problem 3: one endogenous regressor and two instruments, by hand: IV, GMM as a weighted average of the IV estimators, 2SLS, efficient GMM, robust standard errors and the J test.
  • Problem 4: identification of the ATE and the ATT by inverse probability weighting, the ATT as a joint MM problem, and covariate balancing. Computer tutorial 2, Problem 1 implements the ATE version.