Diagnose TWFE-DiD weights (de Chaisemartin & D'Haultfoeuille, 2020)
Source:R/did.R
morie_did_twoway_fe_weights.RdThin interface to TwoWayFEWeights::twowayfeweights: returns the
decomposition of the two-way fixed-effects DiD estimand into the
weighted average of the \(N \times T\) unit-time ATEs. Use
this to quantify how many of the implicit comparisons receive
negative weight, which is the canonical diagnostic for whether a
TWFE specification can be interpreted as a convex combination of
treatment effects.
Usage
morie_did_twoway_fe_weights(
panel,
group,
time,
treatment,
outcome = NULL,
type = "feTR",
...
)Arguments
- panel
A long-format balanced (or near-balanced) panel
data.frame.- group
Name of the unit / group identifier column.
- time
Name of the time period column.
- treatment
Name of the binary or continuous treatment column.
- outcome
Optional outcome column. When supplied, TwoWayFEWeights computes the weights AND the implied TWFE coefficient; when
NULL, only the weights are returned (faster, dimension-free).- type
Weight type passed through to
TwoWayFEWeights::twowayfeweights:"feTR"(default, feasibleTRweights),"feS","fdTR", or"fdS". See the TwoWayFEWeights documentation.- ...
Additional arguments forwarded to
TwoWayFEWeights::twowayfeweights.
Value
An S3 list of class morie_did_twfe_diagnostics with
elements n_negative_weights, sum_weights,
sum_negative_weights, share_negative_weights,
method, and raw (the full
twowayfeweights object).
Details
Wrapper-as-extender: morie_did_panel_fe already estimates the
TWFE coefficient; this function exposes the diagnostic side of the
same backend so that downstream MRM analyses can flag heterogeneous-
treatment-effects bias without leaving the rmorie API.