NonlinearDiD-package: NonlinearDiD: Staggered DiD with Nonlinear Outcomes

NonlinearDiD-packageR Documentation

NonlinearDiD: Staggered DiD with Nonlinear Outcomes

Description

The NonlinearDiD package extends the Callaway and Sant'Anna (2021) staggered difference-in-differences framework to handle nonlinear outcome models, including binary (logit/probit), count (Poisson/NegBin), and odds-ratio estimands.

The Core Problem

The canonical CS2021 framework assumes parallel trends on the mean scale of a continuous outcome. For binary and count outcomes, this assumption is not scale-invariant: parallel trends in P(Y=1) does NOT imply parallel trends in log-odds, pre-trend tests depend on which scale is used, and treatment effect estimates conflate true effects with Jensen's inequality.

Main Functions

  • nonlinear_attgt() – Estimate ATT(g,t) under nonlinear outcome models

  • nonlinear_aggte() – Aggregate: event-study, group, calendar, overall

  • nonlinear_pretest() – Pre-treatment parallel trends test

  • binary_did_logit() – 2x2 DiD with logit outcome

  • binary_did_probit() – 2x2 DiD with probit outcome

  • binary_did_dr() – Doubly-robust binary DiD

  • count_did_poisson() – Poisson QMLE DiD for count outcomes

  • odds_ratio_did() – Odds-ratio DiD (scale-free)

  • nonlinear_bounds() – Nonparametric Manski / PT bounds

  • sim_binary_panel() – Simulate binary staggered panel data

  • sim_count_panel() – Simulate count staggered panel data

Quick Start

library(NonlinearDiD)
dat <- sim_binary_panel(n = 500, nperiods = 8, seed = 42)
res <- nonlinear_attgt(dat, yname = "y", tname = "period",
                        idname = "id", gname = "g",
                        outcome_model = "logit")
agg <- nonlinear_aggte(res, type = "dynamic")
plot(agg)
nonlinear_pretest(res)

Author(s)

Maintainer: Subir Hait haitsubi@msu.edu (ORCID)

References

Callaway, B., & Sant'Anna, P. H. C. (2021). Difference-in-differences with multiple time periods. Journal of Econometrics, 225(2), 200-230.

Roth, J., & Sant'Anna, P. H. C. (2023). When is parallel trends sensitive to functional form? Econometrica, 91(2), 737-747.

Wooldridge, J. M. (2023). Simple approaches to nonlinear difference-in-differences with panel data. The Econometrics Journal, 26(3).

See Also

Useful links:


NonlinearDiD documentation built on May 6, 2026, 1:06 a.m.