Software
AI tools
Panel data methods

fdid implements factorial difference-in-differences, a common research design that extends canonical difference-in-differences (DID) to settings in which an event affects all units.

bpCausal implements dynamic multilevel linear factor models (DM-LFMs), which are a Bayesian alternative to the synthetic control method for comparative case studies. It provides interpretable uncertainty estimates based on the Bayesian posterior distributions of the counterfactuals.

fect implements a group of counterfactual estimators for causal inference using panel data with binary treatments, including interactive fixed effects and matrix completion methods. It also offers several diagnostic tests, such as a placebo test (for no pre-trends).

Using panel data with binary treatments, tjbal seeks balance on kernelized features from pretreatment periods, thus allowing users to draw causal inference on average and distributional effects under weak functional form assumptions.

gsynth implements the generalized synthetic control method, an imputation-based causal inference method for panel data with binary treatments following staggered adoption. The original gsynth package is retiring. All functionalities have been incorporated into fect.

panelView provides four functions: (1) visualize treatment and missingness in panel data; (2) plot variables over time; (3) show bivariate relationships by unit or in aggregate; (4) display multi-way fixed effects as a k-partite graph, identifying components, singletons, and duplicates.
Choosing a panel method
Over the past few years, I have written three articles reviewing recent developments in causal panel analysis. I recommend interested readers review these before applying the methods on this page.
- Causal Inference with Time-Series Cross-Sectional Data: A Reflection: a discussion of two types of identification strategies for causal panel analysis
- A Practical Guide to Counterfactual Estimators for Causal Inference with Time-Series Cross-Sectional Data: a framework of counterfactual estimators for causal panel analysis
- Causal Panel Analysis under Parallel Trends: Lessons from a Large Reanalysis Study: a survey of recent DID methods and reanalysis of political science studies
With collaborators, I develop statistical routines for panel data visualization and analyses and for other causal inference and social data description purposes. Below are the use cases for the various panel methods:
panelView: panel data visualization.gsynth: panel causal inference with binary treatments following staggered adoption. Suitable when the number of treated units is small. Requires a large number of pretreatment periods for each treated unit and a sizable never-treated group.fect: panel causal inference with binary treatments of general patterns (switching on-and-off allowed). Requires a large number of treated and control units. Low-rank methods require a large number of untreated observations for each treated unit.bpCausal: Bayesian panel causal inference with binary treatments following staggered adoption. Requires a large number of pretreatment observations for each treated unit. Suitable when the number of treated units is small.tjbal: panel causal inference with binary treatments following staggered adoption. Requires a large number of pretreatment periods for each treated unit and a sizable never-treated group.fdid: implements the factorial difference-in-differences design.
Note that gsynth, fect, and bpCausal all rely on the strict exogeneity assumption (of some form), which corresponds to baseline randomization, while tjbal relies on sequential ignorability, which corresponds to sequential randomization. The table below summarizes their differences.
| gsynth | fect | bpCausal | tjbal | |
|---|---|---|---|---|
| Staggered adoption of treatment | ✓ | ✓ | ✓ | ✓ |
| General treatment pattern (e.g., switching on and off) | ✓ | |||
| Allow additive fixed effects | ✓ | ✓ | ✓ | ✓ |
| Allow feedback from past outcomes to treatment | ✓ | |||
| Allow short pretreatment period | (✓) | |||
| Accommodate a small number of treated units | ✓ | ✓ | ||
| Bayesian uncertainty estimates | ✓ | |||
| Placebo tests for pretrend | ✓ | ✓ | ✓ | ✓ |
| Accommodate low-rank structure | ✓ | ✓ | ✓ | ✓ |
Other methods

sconjoint implements structural conjoint, the structural deep learning estimator for forced-choice conjoint experiments. The estimator embeds a deep neural network inside a random-utility logit so that each respondent’s preference vector varies smoothly and flexibly with her observed covariates.

ivDiag provides estimation and diagnostic tools for instrumental variables designs, including bootstrapped confidence intervals, effective F-statistics, Anderson-Rubin test, F-dependent valid t-ratio test, and local-to-zero tests.

hbal implements hierarchically regularized entropy balancing, which hierarchically regularizes higher-order moment constraints of observed covariates. It improves both the feasibility and efficiency of entropy balancing and requires much less computational resources than kernel balancing.

interflex estimates and visualizes conditional marginal effects and performs diagnostics. It is the winner of the Best Statistical Software Award from the Society for Political Methodology for 2023.
Questions and bug reports
Questions about usage and bug reports are welcome.
- Please post them as an issue on the package’s GitHub repository rather than by email, so others who run into the same problem can find the answer.
-
If a method gives an error on your data, first install the development version from the package’s
devbranch, for example:devtools::install_github("xuyiqing/fect@dev")The problem may already be fixed.
-
For the panel-data packages (
fect,gsynth,fdid,tjbal,bpCausal), please include a treatment status plot generated bypanelViewwith your issue. It helps us diagnose the problem more quickly.
