Skip to content

GMM Tutorials

Learning Path

Prerequisites: Static Models tutorials, basic understanding of instrumental variables Time: 4--8 hours Level: Intermediate -- Advanced

Overview

Dynamic panel models include lagged dependent variables as regressors, which creates endogeneity that standard estimators cannot handle. The Generalized Method of Moments (GMM) approach uses internal instruments -- lagged levels or lagged differences of the dependent variable -- to achieve consistent estimation.

These tutorials cover the two canonical dynamic panel estimators: Arellano-Bond (Difference GMM) and Blundell-Bond (System GMM), along with advanced variants including CUE-GMM and bias-corrected estimation. You will learn to diagnose instrument validity, manage instrument proliferation, and apply these methods to real-world datasets.

The existing GMM Introduction Tutorial provides additional theoretical background and step-by-step derivations.

Instrument Proliferation

A key practical challenge with GMM is having too many instruments relative to cross-sectional units. The collapse option is critical for maintaining test validity. See notebook 03 for details.

Notebooks

# Tutorial Level Time Colab
1 Difference GMM Fundamentals Intermediate 45 min Open In Colab
2 System GMM & Efficiency Intermediate 45 min Open In Colab
3 Instrument Specification & Collapse Advanced 60 min Open In Colab
4 GMM Diagnostics (Hansen J, AR Tests) Advanced 60 min Open In Colab
5 CUE-GMM & Bias Correction Advanced 60 min Open In Colab
6 Complete Applied Case Study Advanced 60 min Open In Colab

Bonus: Validation: PanelBox vs pydynpd -- Cross-validation of PanelBox GMM results against pydynpd.

Learning Paths

Essential (4 hours)

Core dynamic panel methods for applied research:

Notebooks: 1, 2, 3, 4

Covers both Difference and System GMM, instrument specification, and all critical diagnostic tests (Hansen J, AR(1)/AR(2)).

Complete (8 hours)

Master every GMM variant including advanced estimators:

Notebooks: 1--6 + solutions

Adds CUE-GMM, bias correction, and a comprehensive applied case study.

Key Concepts Covered

  • Dynamic panel bias: Why FE fails with lagged dependent variables (Nickell bias)
  • Difference GMM: Arellano-Bond estimator using lagged levels as instruments
  • System GMM: Blundell-Bond extension using both levels and differences
  • One-step vs two-step: Efficiency vs reliability trade-offs
  • Instrument proliferation: Why too many instruments weaken tests
  • Collapse: Reducing the instrument count while preserving validity
  • Hansen J-test: Overidentification test for instrument validity
  • AR(1)/AR(2) tests: Serial correlation diagnostics
  • CUE-GMM: Continuously-updated estimator for robustness
  • Windmeijer correction: Finite-sample correction for two-step SE

Quick Example

from panelbox.gmm import DifferenceGMM, SystemGMM

# Arellano-Bond Difference GMM
ab = DifferenceGMM(
    data=data,
    dep_var="y",
    predetermined=["x1"],
    exogenous=["x2"],
    entity_col="id",
    time_col="year",
    lags=1,
    collapse=True
).fit()

print(ab.summary())
print(f"Hansen J p-value: {ab.hansen_test.pvalue:.4f}")
print(f"AR(2) p-value: {ab.ar_tests[2].pvalue:.4f}")

Solutions

Tutorial Solution
01. Difference GMM Fundamentals Solution
02. System GMM & Efficiency Solution
03. Instrument Specification Solution
04. GMM Diagnostics Solution
05. CUE & Bias Correction Solution
06. Applied Case Study Solution