Skip to content
StatsOtter A workspace for causal thinking
Method library WORKFLOW / 056
Research workflow/5 steps

Matching for panel / time-series cross-sectional data (PanelMatch)

01
The method workspace

Follow the analysis.

Select a node to explore the method

Method mapInput → 5 steps → output
START WITHInput data
ARRIVE ATResults
Read step 01
Inside the methodReasoning, equations & implementation
Step 1 of 5
01
Diagnostic / pre-tests

Inspect treatment distribution

A pre-flight check — run this before trusting any estimate downstream.

What happens here

Use DisplayTreatment() to visualize when democratization (dem) turns on across countries and years.

Reads fromNot specified Feeds into#2
Key code
# Install:  install.packages("PanelMatch")
library(PanelMatch)
DisplayTreatment(unit.id = "wbcode2", time.id = "year",
                 treatment = "dem", data = dem,
                 legend.position = "none", xlab = "year", ylab = "Country Code")

Reference / docs ↗

Discussion on this step (0)
StatsOtterDiscussion starter · Editorial note

Before using this step, make its assumptions and its output explicit. A useful peer note explains what you would check, what could go wrong, or what would change your interpretation.

Questions to explore
  1. Which assumption matters most here, and what evidence could challenge it?
  2. What would you check before passing this output to the next step?

Peer discussion

  • Bring your experience, a question, or a different perspective.
02
Data contract

Inputs & data

A long-format panel with unit ID, time ID, a binary treatment, an outcome, and time-varying covariates.

Show data format & exampleHide example
unit year treat outcome gdp
A 2001 0 12.4 3.1
A 2002 1 13.0 3.4
B 2001 0 9.8 2.2
B 2002 0 10.1 2.5
03
Read the evidence

Results & interpretation

1 figure Workflow discussion 0
01FigureDynamic ATT across lead periods t+0…t+4 with a 95% confidence band.

Result figure rendered by StatsOtter from the package's documented example — unofficial community showcase; all credit to the original authors.

The estimate

\hat\delta_F=\frac{1}{|\mathcal A|}\sum_{(i,t)\in\mathcal A}!\Big{(Y_{i,t+F}-Y_{i,t-1})-\sum_{j\in\mathcal M_{it}}w_{ij}(Y_{j,t+F}-Y_{j,t-1})\Big}

Context & interpretation

⚠️ Unofficial community showcase of PanelMatch (docs). Not affiliated with the authors — all credit to Kosuke Imai & coauthors; this summarizes public documentation.

What it does: PanelMatch implements the Imai-Kim-Wang matching framework for causal inference with time-series cross-sectional (panel) data and binary treatments. How it works: for each treated observation it builds a matched set of control units that share an identical treatment history over a user-specified number of lags. The matched set is then refined by Mahalanobis distance, propensity-score matching, or propensity-score weighting on time-varying covariates. Treatment effects are estimated with a difference-in-differences estimator that nets out unit and time effects, yielding short- and long-term ATTs with block-bootstrap standard errors. Assumptions: a parallel-trends/limited-carryover assumption conditional on treatment history and covariates, plus no unobserved time-varying confounding. The package also provides covariate-balance diagnostics and visualizations of treatment-variation and matched sets so users can assess match quality before estimation.

What you get — Short- and long-term ATTs (point estimates at multiple lead periods) with bootstrapped confidence intervals, plus covariate-balance and matched-set diagnostics.

Example output

Weighted Difference-in-Differences with Propensity Score
Matches created with 4 lags

Standard errors computed with 1000 Weighted bootstrap samples

Estimate of Average Treatment Effect on the Treated (ATT) by Period:
     estimate std.error      2.5%    97.5%
t+0    0.2475     0.633   -0.9410    1.554
t+1   -0.7800     1.144   -3.0426    1.430
t+2   -1.4290     1.700   -4.7917    1.832
t+3   -1.7770     2.187   -6.0908    2.448
t+4   -1.3450     2.567   -6.4096    3.715

Links: package · paper

Peer notes

Discuss the workflow (0)

  • No comments yet — start the conversation.
IN THE MARGINS

Peer discussion