Tutorials › Econometrics (Graduate) › Deriving The Efficient Two-Step GMM Weighting Matrix

Dynamic Panel Models · Tutorial 304 of 952

Deriving The Efficient Two-Step GMM Weighting Matrix

Learn how to estimate the covariance of the Difference-GMM moments from first-step residuals and use its inverse as the feasible efficient weighting matrix.

Advanced 11 min read

What You'll Learn

  • Define the unit-level Difference-GMM moment vector and its covariance matrix.
  • Derive the covariance pattern created by first-differencing serially uncorrelated level errors.
  • Construct a feasible moment-covariance estimate from first-step residuals.
  • Form the two-step GMM weight by inverting the estimated moment covariance.
  • Explain the regularity conditions and asymptotic efficiency of the optimal weight.
  • Identify when residual weighting estimates or matrix inversion can be unreliable.

Why Estimate a Second-Step Weight?

Difference-GMM uses instrument-based moment conditions to estimate dynamic-panel parameters. The one-step estimator uses a specified weighting matrix to combine those moments. But different moments can have different variances and covariances, so treating them as equally informative need not be efficient. Two-step GMM estimates the covariance of the moments from first-step residuals and weights them using its inverse.

The key distinction is between the covariance of the differenced equation errors and the covariance of the moment vector. The former describes dependence among differenced errors; instruments transform those errors into moments, and the resulting moment covariance determines the GMM weight. The derivation below makes both transformations explicit.

Definition: For unit \(i\), let \(g_i(\theta)=Z_i'\Delta\varepsilon_i(\theta)\) be its \(q\)-dimensional moment vector, where \(Z_i\) is the instrument matrix, \(\Delta\varepsilon_i(\theta)\) is the vector of differenced equation errors implied by parameter vector \(\theta\), and \(q\) is the number of moment conditions. Under valid moments, \(E[g_i(\theta_0)]=0\) at the true parameter \(\theta_0\). The moment covariance matrix is \(S=E[g_i(\theta_0)g_i(\theta_0)']\).

For \(N\) independent panel units, write the sample mean moment as \(\bar g_N(\theta)=N^{-1}\sum_{i=1}^N g_i(\theta)\). A GMM estimator minimizes \(\bar g_N(\theta)'W\bar g_N(\theta)\), where \(W\) is a positive-definite weighting matrix. With this convention, the optimal large-sample choice is \(W=S^{-1}\): moments with greater variance receive less weight, while their covariance is also accounted for.

From Level Errors to Differenced-Error Covariance

Consider the differenced dynamic-panel equation over periods \(t=3,\ldots,T\). Its error in period \(t\) is \(\Delta\varepsilon_{it}=\varepsilon_{it}-\varepsilon_{i,t-1}\). If the level errors are serially uncorrelated with variance \(\sigma^2\), then a differenced error has variance \(2\sigma^2\). Adjacent differenced errors share one level error with opposite signs, giving covariance \(-\sigma^2\); nonadjacent differenced errors share no level error and have covariance zero.

Thus, with \(m=T-2\) differenced equations, the covariance matrix of \(\Delta\varepsilon_i\) is \(\sigma^2 H_m\), where \(H_m\) has 2 on its diagonal, \(-1\) immediately above and below the diagonal, and 0 elsewhere. This structure follows from differencing; it is not a claim that differenced errors are serially uncorrelated.

Worked Example: Covariance Induced by Differencing

Suppose a hypothetical panel has four level-error observations for a unit, \((\varepsilon_{i1},\varepsilon_{i2},\varepsilon_{i3},\varepsilon_{i4})\), each with variance \(\sigma^2=4\), and the level errors are mutually uncorrelated. The three consecutive differences are \((\Delta\varepsilon_{i2},\Delta\varepsilon_{i3},\Delta\varepsilon_{i4})\).

The first variance is \(\operatorname{Var}(\varepsilon_{i2}-\varepsilon_{i1})=4+4=8\), and the same calculation gives variance 8 for each difference. The covariance of the first two differences is \[ \operatorname{Cov}(\varepsilon_{i2}-\varepsilon_{i1},\varepsilon_{i3}-\varepsilon_{i2})=-\operatorname{Var}(\varepsilon_{i2})=-4. \] The next adjacent covariance is also \(-4\), while the first and third differences have covariance zero because they share no level error. Therefore,

$$ \operatorname{Var}(\Delta\varepsilon_i) =4\begin{pmatrix}2&-1&0\\-1&2&-1\\0&-1&2\end{pmatrix} =\begin{pmatrix}8&-4&0\\-4&8&-4\\0&-4&8\end{pmatrix}. $$

The negative off-diagonal entries are essential: adjacent differences are negatively correlated even though the level errors are uncorrelated. With instruments \(Z_i\), the corresponding moment covariance is \(E[Z_i'\Delta\varepsilon_i\Delta\varepsilon_i'Z_i]\), not simply the error covariance matrix itself.

The matrix \(\sigma^2H_m\) can motivate a one-step weight under the stated homoskedastic, serially uncorrelated level-error structure. The efficient two-step weight, however, is defined by the covariance of the actual instrumented moments. It can accommodate more general heteroskedasticity across units and periods when estimated from unit-level residual moments, provided the moments remain valid and the sample covariance is well behaved.

Estimating the Moment Covariance

Let \(\hat\theta_1\) be a consistent first-step Difference-GMM estimate, obtained using a fixed positive-definite first-step weight. Compute the first-step residual vector \(\widehat{\Delta\varepsilon}_i=\Delta\varepsilon_i(\hat\theta_1)\), then form the estimated moment vector \(\hat g_i=Z_i'\widehat{\Delta\varepsilon}_i\). The usual uncentered estimator of the moment covariance is

$$ \hat S=\frac{1}{N}\sum_{i=1}^N \hat g_i\hat g_i' =\frac{1}{N}\sum_{i=1}^N Z_i'\widehat{\Delta\varepsilon}_i \widehat{\Delta\varepsilon}_i'Z_i. $$

The outer product is formed separately for each unit before averaging. This retains the covariance among that unit’s moments. The two-step estimator then minimizes \(\bar g_N(\theta)'\hat S^{-1}\bar g_N(\theta)\). It is called feasible because the optimal population matrix \(S^{-1}\) is unknown and is replaced by an estimate.

The residuals in \(\hat S\) come from the first step, not from an estimator that already uses \(\hat S^{-1}\). Under consistency of \(\hat\theta_1\), valid moments, and suitable regularity conditions, the residual-based \(\hat S\) converges to \(S\). The second-step estimate therefore uses an estimated weight that approaches the optimal population weight.

Worked Example: Building the Residual-Based Moment Covariance

Consider three hypothetical independent units, each with two instrumented moment components. Suppose their first-step residuals and instrument matrices are as follows. For unit 1, \(\widehat{\Delta\varepsilon}_1=(0.2,-0.1)'\) and \(Z_1=I_2\). For unit 2, \(\widehat{\Delta\varepsilon}_2=(-0.1,0.3)'\) and \(Z_2=\begin{pmatrix}1&1\\0&1\end{pmatrix}\). For unit 3, \(\widehat{\Delta\varepsilon}_3=(0.3,0.1)'\) and \(Z_3=\begin{pmatrix}1&1\\0&1\end{pmatrix}\).

Multiplying each instrument transpose by its residual gives \[ \hat g_1=(0.2,-0.1)',\qquad \hat g_2=(-0.1,0.2)',\qquad \hat g_3=(0.3,0.4)'. \] For example, unit 2’s second component is \((-0.1)+0.3=0.2\). Their outer products are \[ \hat g_1\hat g_1'=\begin{pmatrix}0.04&-0.02\\-0.02&0.01\end{pmatrix},\quad \hat g_2\hat g_2'=\begin{pmatrix}0.01&-0.02\\-0.02&0.04\end{pmatrix},\quad \hat g_3\hat g_3'=\begin{pmatrix}0.09&0.12\\0.12&0.16\end{pmatrix}. \]

Summing the entries and dividing by \(N=3\) yields

$$ \hat S=\frac{1}{3}\begin{pmatrix}0.14&0.08\\0.08&0.21\end{pmatrix} =\begin{pmatrix}0.04667&0.02667\\0.02667&0.07000\end{pmatrix}. $$

Its determinant is \(0.04667(0.07000)-(0.02667)^2\approx0.002556\), which is positive, so this two-by-two estimate is invertible. The inverse is approximately \[ \hat S^{-1}=\begin{pmatrix}27.39&-10.43\\-10.43&18.26\end{pmatrix}. \] This tiny calculation illustrates the construction, not a reliable empirical estimate: three units are far too few to establish stable large-sample behavior.

Why the Inverse Covariance Is Efficient

The efficiency result concerns large samples with many independent units and a fixed number of moments and parameters. Assume the moment conditions are valid at \(\theta_0\), \(S\) is finite and positive definite, and the mean moment function is differentiable near \(\theta_0\). Let \(D=E[\partial g_i(\theta_0)/\partial\theta']\), a \(q\)-by-\(k\) matrix of full column rank. Also assume the usual conditions for the sample moments and their derivatives to obey laws of large numbers and a central limit theorem. Under these conditions, a GMM estimator using a fixed positive-definite \(W\) has asymptotic variance, scaled by \(N\), equal to

$$ V(W)=(D'WD)^{-1}D'WSWD(D'WD)^{-1}. $$

For \(W=S^{-1}\), this simplifies to \(V(S^{-1})=(D'S^{-1}D)^{-1}\). A short matrix argument shows why no other fixed admissible weight has a smaller asymptotic variance in the positive-semidefinite ordering.

1
Write the estimator’s linear moment map.
Set \(L=(D'WD)^{-1}D'W\). Then \(LD=I_k\), and its asymptotic variance is \(LSL'\).
2
Define the optimal map.
Set \(L_*=(D'S^{-1}D)^{-1}D'S^{-1}\). It also satisfies \(L_*D=I_k\), and \(L_*SL_*'=(D'S^{-1}D)^{-1}\).
3
Compare the variances.
Let \(C=L-L_*\). Since \(CD=0\) and \(L_*S=(D'S^{-1}D)^{-1}D'\), the cross terms vanish: \(L_*SC'=0\) and \(CSL_*'=0\). Therefore \(LSL'=L_*SL_*'+CSC'\).
4
Conclude the efficiency comparison.
For every vector \(a\), \(a'CSC'a=(C'a)'S(C'a)\geq0\), since \(S\) is positive definite. Thus \(V(W)-V(S^{-1})=CSC'\) is positive semidefinite: the inverse-covariance weight is asymptotically efficient among these GMM weights.

In feasible two-step GMM, \(\hat S\) replaces \(S\). When \(\hat S\) converges to a nonsingular \(S\), this estimated weight converges to the optimal one, yielding the same limiting efficiency under the stated conditions. This is an asymptotic result; it does not guarantee that two-step estimates are more accurate in every finite sample.

Worked Example: An Analytic Weight Under a Simple Error Model

Suppose there are three consecutive differenced equations, the level errors are serially uncorrelated and homoskedastic, and the instrument matrix is the identity for these equations. The moment covariance is then \(S=\sigma^2H_3\), with \(H_3\) as in the first example. The inverse of \(H_3\) is

$$ H_3^{-1}=\frac{1}{4}\begin{pmatrix}3&2&1\\2&4&2\\1&2&3\end{pmatrix}. $$

To verify the scaling, the determinant of \(H_3\) is \(2(4-1)-(-1)(-2)=4\). Its cofactor matrix is \(\begin{pmatrix}3&2&1\\2&4&2\\1&2&3\end{pmatrix}\), so the inverse is that matrix divided by 4. Consequently, the optimal weight for these error moments is \(S^{-1}=\sigma^{-2}H_3^{-1}\). The common scale \(\sigma^{-2}\) does not change the minimizer of the GMM criterion, because multiplying the entire criterion by a positive constant leaves its minimizer unchanged. With non-identity instruments, the moment covariance instead involves \(Z_i'\Delta\varepsilon_i\Delta\varepsilon_i'Z_i\), so one must account for the instruments rather than use \(H_3^{-1}\) alone.

Assumptions, Limitations, and a Common Pitfall

The residual-based covariance estimate relies on independent sampling across units (or an appropriate treatment of cross-unit dependence), valid moment conditions, and enough units for the sample outer products to estimate their expectation. The matrix to be inverted must also be nonsingular. Heteroskedasticity across units can be reflected in the unit-level outer products; by contrast, residual weighting does not make invalid instruments valid or remove serial dependence that violates the chosen moments.

Common pitfall: “Differencing makes the errors independent, so the optimal weight is the identity.” This is incorrect. Even when level errors are serially uncorrelated, adjacent differenced errors have covariance \(-\sigma^2\), as the shared level error enters with opposite signs. Further, the relevant weight is the inverse covariance of the instrumented moment vector, not generally the identity or simply the inverse covariance of uninstrumented errors. Construct \(\hat g_i=Z_i'\widehat{\Delta\varepsilon}_i\), estimate \(\hat S\) from its unit-level outer products, and use \(\hat S^{-1}\) only when the estimate is sufficiently well-conditioned to invert.

The two-step weight matters because it accounts for both the scale and dependence of the moments, rather than assigning them equal precision. In practice, a large number of moments relative to the number of units can make \(\hat S\) unstable or singular; then its inverse can be numerically unreliable. That is a limitation of the estimated weighting matrix, not evidence that the population optimal-weight result is false.

Key takeaway: Estimate the moment covariance by averaging the outer products of first-step, instrument-weighted residuals, then use its inverse as the feasible second-step weight. Under valid moments, regularity conditions, and a well-behaved covariance estimate, this converges to the asymptotically efficient GMM weighting matrix.

Check Your Understanding

Answer each question by referring to the definitions and assumptions above.

  1. Why are adjacent differenced errors negatively correlated when the level errors are serially uncorrelated?
  2. For a unit with residual vector \(\widehat{\Delta\varepsilon}_i\), what is the dimension and meaning of \(\hat g_i=Z_i'\widehat{\Delta\varepsilon}_i\)?
  3. Why does the standard residual-based estimator average \(\hat g_i\hat g_i'\) across units rather than first averaging the moment vectors?
  4. State two conditions needed for the two-step weight to deliver its asymptotic efficiency result.
  5. Why does the optimal weight generally differ from the inverse covariance matrix of the uninstrumented differenced errors?
Clinical Biostats