Covariates in Callaway-Sant’Anna¶
Outcome regression, inverse probability weighting and the doubly robust estimator, with two covariates. The diagnostics count the nuisance models and the passes over the data they took: comparisons with the same sample and covariate period share a model, and all are fitted together.
from diff_stream import did_callaway_santanna
from diff_stream.simulate import simulate_conditional_panel
panel = simulate_conditional_panel(2000, 5)
for adjustment in ["regression", "ipw", "doubly_robust"]:
fit = did_callaway_santanna(
"y ~ x + z",
panel,
panel=("id", "time"),
cohort="first_treat",
adjustment=adjustment,
n_threads=4,
)
fit.aggregate("overall").summary()
print("Nuisance models:", fit.diagnostics["nuisance_systems"])
print("Shared source passes:", fit.diagnostics["nuisance_source_passes"])
Output:
### y ~ x + z
estimator: cs; units: 2,000
vcov: CRV0
obs: 10,000
unit clustered; nuisance-adjusted analytic scores
shape: (1, 5)
┌─────────────┬──────────┬────────────┬──────────┬────────────┐
│ Coefficient ┆ Estimate ┆ Std. Error ┆ t value ┆ Pr(>|t|) │
│ --- ┆ --- ┆ --- ┆ --- ┆ --- │
│ str ┆ f64 ┆ f64 ┆ f64 ┆ f64 │
╞═════════════╪══════════╪════════════╪══════════╪════════════╡
│ ATT ┆ 0.997422 ┆ 0.049116 ┆ 20.30763 ┆ 1.1009e-91 │
└─────────────┴──────────┴────────────┴──────────┴────────────┘
Nuisance models: 9
Shared source passes: 3
### y ~ x + z
estimator: cs; units: 2,000
vcov: CRV0
obs: 10,000
unit clustered; nuisance-adjusted analytic scores
shape: (1, 5)
┌─────────────┬──────────┬────────────┬───────────┬────────────┐
│ Coefficient ┆ Estimate ┆ Std. Error ┆ t value ┆ Pr(>|t|) │
│ --- ┆ --- ┆ --- ┆ --- ┆ --- │
│ str ┆ f64 ┆ f64 ┆ f64 ┆ f64 │
╞═════════════╪══════════╪════════════╪═══════════╪════════════╡
│ ATT ┆ 0.988 ┆ 0.049459 ┆ 19.976139 ┆ 8.8834e-89 │
└─────────────┴──────────┴────────────┴───────────┴────────────┘
Nuisance models: 9
Shared source passes: 8
### y ~ x + z
estimator: cs; units: 2,000
vcov: CRV0
obs: 10,000
unit clustered; nuisance-adjusted analytic scores
shape: (1, 5)
┌─────────────┬──────────┬────────────┬───────────┬────────────┐
│ Coefficient ┆ Estimate ┆ Std. Error ┆ t value ┆ Pr(>|t|) │
│ --- ┆ --- ┆ --- ┆ --- ┆ --- │
│ str ┆ f64 ┆ f64 ┆ f64 ┆ f64 │
╞═════════════╪══════════╪════════════╪═══════════╪════════════╡
│ ATT ┆ 0.99936 ┆ 0.049141 ┆ 20.336449 ┆ 6.1205e-92 │
└─────────────┴──────────┴────────────┴───────────┴────────────┘
Nuisance models: 9
Shared source passes: 8