binary_did_dr: Doubly-Robust Binary DiD

View source: R/estimators.R

binary_did_drR Documentation

Doubly-Robust Binary DiD

Description

Doubly-robust estimator for binary outcomes combining a nonlinear outcome regression model with inverse probability weighting via propensity score. Consistent if EITHER the outcome model OR the propensity score is correctly specified.

Usage

binary_did_dr(
  data,
  yname,
  tname,
  idname,
  treat_period,
  control_period,
  dname = NULL,
  gname = NULL,
  xformla = ~1,
  outcome_model = c("logit", "probit"),
  se_type = c("robust", "cluster", "analytical"),
  cluster_var = NULL
)

Arguments

data

A data frame (long format).

yname

Character. Binary outcome variable name.

tname

Character. Time period variable name.

idname

Character. Unit ID variable name.

treat_period

Numeric. The treatment (post) period.

control_period

Numeric. The pre-treatment baseline period.

dname

Character. Treatment indicator variable name (optional).

gname

Character. Cohort variable name (optional).

xformla

One-sided formula for covariates. Default ~1.

outcome_model

Character. "logit" (default) or "probit".

se_type

Character. SE type: "robust" (default), "cluster", or "analytical".

cluster_var

Character. Clustering variable (if se_type = "cluster").

Value

A list of class binary_did_dr.

Examples

dat <- sim_binary_panel(n = 500, nperiods = 4, prop_treated = 0.5)
dat2 <- dat[dat$period %in% c(2, 3), ]
res <- binary_did_dr(dat2, "y", "period", "id", 3, 2, gname = "g",
                      outcome_model = "logit")
print(res)

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