Differences from other packages¶
The estimators reproduce the reference packages’ estimates and standard errors when given the same conventions (see Validation). Defaults and names differ in places; this page lists them.
Names¶
Here |
R did |
R fixest / didimputation / did2s / etwfe |
Stata |
|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
the first argument of |
|
|
|
etwfe |
|
|
|
|
|
|
|
||
|
|
|
|
|
|
||
|
|
||
|
|
||
|
|
|
|
|
|
||
|
|
|
|
|
|
||
|
|
||
|
|
||
|
did2s with a single treatment indicator in |
||
|
emfx conditional ( |
||
|
etwfe |
||
|
fixest |
Conventions that differ¶
Standard errors. Every estimator clusters by unit. vcov="CRV0" (the
default) is the plain sum of influence-function outer products; "CRV1"
multiplies it by N/(N-1) only, without fixest’s (N-1)/(N-K) regression
adjustment. Intervals are normal, not t. R did’s default reports multiplier
bootstrap intervals; here they are opt-in (multiplier_bootstrap_reps), and
the analytic ones are the default.
Callaway-Sant’Anna. Matches R did with the same options. The doubly
robust estimator is the “traditional” one of DRDID, not the improved
locally efficient variant. Trimming drops high-score controls only, as DRDID
does. A comparison with few effective controls warns
(LowEffectiveSampleWarning) but is reported; R did reports it silently.
Sun-Abraham. Matches fixest’s sunab with ssc turned off. Aggregation
weights cells by their observed treated units, as sunab’s aggregation does.
BJS. Matches the authors’ Stata did_imputation with minn(0): Stata
suppresses effects with fewer than 30 contributing units by default, this
package does not (it reports them). leave_out and residual_averaging are
the authors’ leaveout and avgeffectsby. Treated observations that cannot
be imputed (a fixed-effect level with no untreated observations) are dropped
with a warning, as Stata’s autosample option does; Stata’s default is an
error, and R’s didimputation drops them silently.
Two-stage. Matches the authors’ did2s. The event study and the static ATT are separate fits; there is no aggregation of cohort-period effects.
Extended TWFE. Matches etwfe and emfx. The default comparison is the
never-treated units, as for the other estimators here; etwfe’s is
not-yet-treated (cgroup = "notyet"), so set control_group explicitly when
comparing. Only the linear model is implemented.
Continuous treatment. did_continuous matches the authors’ R contdid 0.1.1 in
its point estimates, with these differences:
The dose-response curves. contdid fits each cohort-period spline with boundary knots at that cell’s range of doses but evaluates the curves with boundary knots at the range of
dvals, so its ATT(d) and ACRT(d) are off unless every cell’s doses span exactly the grid (contdid issue #16, fix proposed in PR #18). Here the spline has its boundary at the range of all treated doses, for fitting and evaluating alike, and doses outside that range are an error.Options contdid ignores. contdid 0.1.1 accepts
control_group,base_periodand weights but does not apply them: it always uses not-yet-treated comparisons, a varying base period and no weights (contdid issue #19). Here both comparisons and both base periods are applied. Weights are not supported.Standard errors. Three problems in contdid and in ptetools, which it uses for inference, make its standard errors differ from these. The estimates are not affected.
Its ACRT standard errors (overall, cohort-period and event study) are too small by the share of treated units in each cell (contdid issue #13, fix proposed in PR #17). On the validation panel they were about a third of these.
Its ATT(d) standard errors reverse the covariance between a unit’s part as a treated unit in one cohort-period and as a comparison unit in another (with not-yet-treated comparisons): ptetools’
process_dose_gtgives the comparison units’ part the wrong sign. On the validation panel they were 1% to 4% smaller than these.Its overall ATT and event-study standard errors use a term for the estimated cohort shares that differs from R did’s, which these follow: ptetools’
pte_aggtecenters each cohort indicator at the cohort’s share of the treated units rather than of all units. The differences were under 0.2%.
A discrete dose. contdid 0.1.1 has none (“discrete treatment not supported yet”). Python’s diff-diff 4.0.0 (
ContinuousDiD(treatment_type="discrete")) is the same estimator, and its estimates, curves and curve standard errors match these. Its overall and event-study standard errors treat the cohort shares and each cohort’s shares of units at each dose as known; here they include the uncertainty of those estimated shares, as R did does for cohort shares and contdid for the doses. On the validation panel diff-diff’s overall ACRT standard error was 18% smaller, and its overall ATT and event-study ones up to 2% smaller. The same holds for diff-diff’s continuous dose, whose overall ACRT standard error treats the treated units’ average slope of the spline as known (0.4% smaller on the validation panel).Covariates (experimental here). contdid takes none. diff-diff 4.0.0’s regression adjustment (
estimation_method="reg") is the same method, and its estimates, curves and curve standard errors match these; its overall standard errors treat the estimated shares as known, as above. diff-diff’s default adjustment is doubly robust ("dr"), which is not implemented here, so compare withestimation_method="reg". diff-diff absorbs no fixed effects: here fixed-effect terms are absorbed (one exactly, several with hdfe-stream), which equals entering their levels as dummies.No untreated units. diff-diff 4.0.0’s
control_group="lowest_dose"(the paper’s Remark 3.1) is the same estimator ascontrol_group="lowest_dose"here, and its estimates, curves, curve standard errors, cells and event study match these. Its overall ACRT standard error treats the treated units’ average slope as known, as above. diff-diff lists the universal base period as a cell with an effect of 0, which is not listed here. diff-diff takes no covariates with it; here covariates and fixed effects are allowed (experimental), as is a group of reference doses (reference_dose), which equals diff-diff’s estimates with those doses set to one value.Sampling weights. contdid 0.1.1 ignores weights (contdid issue #19). diff-diff 4.0.0 takes them through
survey_design=SurveyDesign(weights=...), and its estimates, curves, cells and event studies match these. Its standard errors apply each unit’s weight twice: the units’ influence values include their weights, and its survey variance multiplies them by the weights again, so with unequal weights its standard errors are too large or too small (9% to 30% larger on the validation panels). diff-diff’sCallawaySantAnnaweights them once, as R did does and as these do. Weights that change over time are not in diff-diff; here they are experimental.Clustered standard errors. contdid clusters by unit only. diff-diff 4.0.0 clusters through a survey design’s primary sampling units (
SurveyDesign(psu=...)), and without weights its curves’ standard errors matchcluster=here withvcov="CRV1"; its overall and event-study standard errors differ as above, by holding estimated shares and the average slope fixed.Unbalanced panels (experimental here). contdid and diff-diff require a balanced panel. With
incomplete_units="keep", each comparison here uses the units observed in both of its periods, unlike R did’s unbalanced panels (anddid_callaway_santanna’s), which compare each period’s observed rows as repeated cross sections. So with missing periods the effect of being treated differs fromdid_callaway_santanna(..., incomplete_units="keep").The overall ATT is a cohort-weighted average of post-treatment cells, R did’s
aggte(type = "group").aggregate("overall")weights cells by their units instead, as for Callaway-Sant’Anna.The level event study. contdid 0.1.1 computes it by passing the dose to
ptetools::did_attgt, which DRDID 1.4.0 rejects; it is Callaway-Sant’Anna on being treated, and is checked against R did.
Switching treatment. did_dcdh matches the authors’ R DIDmultiplegtDYN 2.4.0
(did_multiplegt_dyn) in its estimates, standard errors and joint tests, with these
differences:
The covariance matrix.
did_multiplegt_dynreturns a covariance matrix (coef$vcov) whose off-diagonal entries use the first group’s value for every group, so they are not covariances: correlations can exceed one, and the matrix can have negative eigenvalues. Its own joint tests (p_jointplacebo,p_equality_effects) are computed correctly, and agree withpretrend_test()andeffects_equal_test()here.fit.vcovhere is the covariance those tests use, and the onefit.trend_sensitivity()uses.Missing treatments.
did_multiplegt_dynaccepts rows with an outcome but no treatment and fills the treatment in by its own rules. Here such rows are an error; missing periods (no row) are supported, withincomplete_units="keep", asdid_multiplegt_dyntreats them.Linear trends with missing periods. With
trends_lin,did_multiplegt_dyntakes each row’s first difference from the group’s previous row, so across a missing period it uses a two-period difference as if it were one.linear_trends=Truehere uses a first difference only where both of its periods are observed. In balanced panels the two agree.Switcher counts with linear trends. With
trends_lin, the number of switchersdid_multiplegt_dynreports for an effect (“Switchers”) is that of the last estimate it computed for the same horizon (with 4 effects, every effect shows the switchers of effect 4). Its weighted count (“Switchers.w”) and its estimates use the right switchers, andswitchers()here reports them.Names.
trends_nonparamistrends_by,trends_linislinear_trends,continuousiscontinuous_baseline, andweightisweights(withallow_time_varying_weights=Truefor weights that change over time).A continuous first-period treatment with missing periods. With
incomplete_units="keep"and switchers that miss periods between their first and last,did_multiplegt_dyn’scontinuousoption gives estimates that differ from the estimator it describes: the same command, without the option, on the treatment binarized at the switch with the polynomial controls added (which is how the option works).continuous_baselinehere equals that construction, and equals the option whenever switchers have no such gaps.Options not implemented:
same_switchers,same_switchers_pl,less_conservative_se,more_granular_demeaning,dont_drop_larger_lower,drop_if_d_miss_before_first_switch,date_first_switch,by,by_pathandpredict_het.Bootstrap.
did_multiplegt_dyn’sbootstrapresamples groups, or clusters withcluster, and refits;refit_bootstrap(estimator=did_dcdh)does the same. The draws use different random numbers, so the standard errors agree only up to simulation error: with 500 draws each, on the validation panel, within 4% (within about one simulation standard deviation), with and without clusters.
Aggregation. horizons filters event times for every kind of
aggregation, including calendar, where R did ignores its event-time limits.
Bootstrap. refit_bootstrap refits the whole estimator on unit
resamples; percentile intervals use R’s quantile(type = 7) and the normal
interval has no bias correction, so endpoints can differ from R’s
boot.ci. Simultaneous bands from refits are not implemented (the multiplier
bootstrap gives them for Callaway-Sant’Anna).
Sensitivity to parallel trends. trend_sensitivity gives the intervals of R’s
HonestDiD 0.2.8 (its names for the restrictions and intervals, and the few deliberate
differences, are on
hdfe-stream’s page).
Compared with HonestDiD’s own entry point for did results, honest_did(): it also
refuses a varying base period; it tests 1,000 grid points where honest_did tests
100, so its interval ends are finer; and the target is chosen by event time
(target=) rather than by position (e=). The Python package diff-diff 4.0.0 has the
method too, with two differences worth knowing: its relative-magnitudes interval
widens the estimated identified set by z standard errors (its conditional test is
disabled), which is not the method’s interval and has no coverage guarantee; and its
event study for de Chaisemartin and D’Haultfoeuille’s estimator uses only the standard
errors, a diagonal covariance, where the placebos and effects are correlated.
Diagnostics. bacon_decomp matches R’s bacondecomp; twfe_weights
matches the feTR type of the authors’ TwoWayFEWeights. The other types
(feS, first-difference) and continuous treatments are not implemented.
Not implemented¶
Nonlinear ETWFE (logit, Poisson): R’s etwfe, Stata’s
jwdid.Fixed effects interacted with the unit (unit-specific trends).