Learn R Programming

NonlinearDiD (version 0.1.0)

odds_ratio_did: Odds-Ratio DiD for Binary Outcomes

Description

Estimates the odds-ratio difference-in-differences (OR-DiD) for binary outcomes. OR-DiD equals 1 under no treatment effect and is invariant to which group is labelled treatment.

Usage

odds_ratio_did(
  data,
  yname,
  tname,
  idname,
  treat_period,
  control_period,
  dname = NULL,
  gname = NULL,
  xformla = ~1
)

Value

A list of class odds_ratio_did.

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.

Examples

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

Run the code above in your browser using DataLab