diff_diff.dml_did_results.DMLDiDResults#
- class diff_diff.dml_did_results.DMLDiDResults[source]#
Bases:
CallawaySantAnnaResultsResults from DMLDiD (Chang 2020 DML DiD, staggered ATT(g,t)).
Inherits the full Callaway-Sant’Anna results surface —
att/sealiases,to_dataframe, post-fitaggregate()(simple / event_study / group, plus total on panel non-survey fits; repeated-cross-section AND declared-survey fits failtotalclosed) with bootstrap replay — and adds the DML provenance fields below.cluster_name/n_clusters/df_inference/survey_metadataare populated on survey/cluster=fits (CS conventions:survey_metadatamarks a DECLARED design;df_inferencecarries the bare-cluster df). Every inherited CS-only field that DMLDiD never populates (epv_*,pscore_fallback,allow_unbalanced_panel,used_rc_on_unbalanced_panel,influence_functions,event_study_effects/event_study_vcov/event_study_vcov_index/event_study_df) stays at its inherited default and is inert.group_effectsstaysNonepermanently —aggregate("group")returns a separate container and never mutates this object.panelis NOT inert: it carries the fit’s DECLARED design —Truefor the Case 1 panel lane,Falsefor the Case 2 repeated-cross-section lane (DMLDiD(panel=False)) — and report rendering plus the aggregationn_kindread it for “units” vs “observations” semantics.- propensity_learner, outcome_learner
The learner specs as configured — the string name verbatim; a passed LIBRARY-native learner object keeps its configuration-aware
repr(); a FOREIGN object is recorded as its qualified class name only (its__repr__could embed sensitive content). Never the object itself: result pickles must not retain arbitrary user objects.- Type:
- effective_n_folds#
The REALIZED fold count when it differs from
n_folds— set only when a coarse survey/cluster PSU design reduced K to the global PSU count to preserve cluster cohesion (warned at fit);Noneotherwise.- Type:
int, optional
- cross_fit_diagnostics#
Per-
(g, t)cross-fit diagnostics: per-stage fold losses and fit counts,p_hat, propensity clip count, and the fold-seed derivation. Cells that failed before fold assignment carry no entry.- Type:
dict, optional
- seed#
Root seed for the per-cell fold draws (and the bootstrap when enabled). With
seed=Nonethe recorded per-fit entropy is drawn from OS randomness.- Type:
int, optional
- n_bootstrap, bootstrap_weights, cband
Multiplier-bootstrap configuration used at fit.
- bad_control#
The bad-control column of a Caetano, Callaway, Payne & Sant’Anna (2026) fit (
fit(bad_control=...));Noneon plain Chang fits.- Type:
str, optional
- bad_control_covariates#
The
Wcolumns (user order; the outcome name means the outcome at the cell’s base period);()when a bad control was declared withoutW;Noneon plain fits.
- bad_control_diagnostics#
Per-
(g, t)ATT_X(g, t)pre-test (Remark 6): the AIPW mean-effect of treatment on the bad control att(pre-period cells assess MP-5 / MP-8 and should be zero; post-period cells check that treatment affects the covariate) with keyseffect/se/t_stat/p_value/conf_int/n_treated/n_control. Analytical SE only (never bootstrapped or aggregated). Retained cells only;Noneon plain fits. Read throughbad_control_summary().- Type:
dict, optional
Methods
__init__(group_time_effects, overall_att, ...)aggregate(type[, weights, balance_e])Re-aggregate this fit without refitting.
bad_control_summary()Per-cell
ATT_X(g, t)pre-test table (Caetano et al. 2026, Remark 6).epv_summary([show_all])Return per-cohort EPV diagnostics as a DataFrame.
print_summary([alpha])Print summary to stdout.
summary([alpha])Formatted summary with the DML banner and cross-fit header block.
to_dataframe([level])Parent DataFrame; on bad-control fits the
group_timelevel gainsatt_x/se_x(analytical, unlike a bootstrappedse).to_dict()Headline dict extended with DML provenance (JSON-serializable).
Attributes
allow_unbalanced_panelalphaanticipationattbase_periodbootstrap_resultsbootstrap_weightscbandcband_crit_valuecluster_namecoef_varSE / abs(overall ATT).
conf_intcontrol_groupdf_inferenceepv_diagnosticsepv_thresholdevent_study_dfevent_study_effectsevent_study_vcovevent_study_vcov_indexgroup_effectsinfluence_functionsis_significantCheck if overall ATT is significant.
n_bootstrapn_clustersoutcome_learnerp_valuepanelpropensity_learnerpscore_fallbackpscore_trimreference_event_timessesignificance_starsSignificance stars for overall ATT.
survey_metadatat_statused_rc_on_unbalanced_panelvcov_typegroup_time_effectsoverall_attoverall_seoverall_t_statoverall_p_valueoverall_conf_intgroupstime_periodsn_obsn_treated_unitsn_control_units- __init__(group_time_effects, overall_att, overall_se, overall_t_stat, overall_p_value, overall_conf_int, groups, time_periods, n_obs, n_treated_units, n_control_units, alpha=0.05, control_group='never_treated', base_period='varying', anticipation=0, panel=True, allow_unbalanced_panel=False, used_rc_on_unbalanced_panel=False, event_study_effects=None, group_effects=None, influence_functions=None, event_study_vcov=None, event_study_vcov_index=None, event_study_df=None, bootstrap_results=None, cband_crit_value=None, pscore_trim=0.01, survey_metadata=None, epv_diagnostics=None, epv_threshold=10, pscore_fallback='error', vcov_type='hc1', cluster_name=None, n_clusters=None, df_inference=None, reference_event_times=None, _aggregation_kit=None, propensity_learner='logit', outcome_learner='linear', n_folds=5, effective_n_folds=None, cross_fit_diagnostics=None, seed=None, n_bootstrap=0, bootstrap_weights=None, cband=True, bad_control=None, bad_control_covariates=None, bad_control_diagnostics=None)#
- Parameters:
overall_att (float)
overall_se (float)
overall_t_stat (float)
overall_p_value (float)
n_obs (int)
n_treated_units (int)
n_control_units (int)
alpha (float)
control_group (str)
base_period (str)
anticipation (int)
panel (bool)
allow_unbalanced_panel (bool)
used_rc_on_unbalanced_panel (bool)
influence_functions (np.ndarray | None)
event_study_vcov (np.ndarray | None)
event_study_vcov_index (list | None)
event_study_df (float | None)
bootstrap_results (CSBootstrapResults | None)
cband_crit_value (float | None)
pscore_trim (float)
survey_metadata (Any | None)
epv_diagnostics (Dict[Tuple[Any, Any], Dict[str, Any]] | None)
epv_threshold (float)
pscore_fallback (str)
vcov_type (str)
cluster_name (str | None)
n_clusters (int | None)
df_inference (int | None)
_aggregation_kit (Any | None)
propensity_learner (Any)
outcome_learner (Any)
n_folds (int)
effective_n_folds (int | None)
seed (int | None)
n_bootstrap (int)
bootstrap_weights (str | None)
cband (bool)
bad_control (str | None)
- Return type:
None
- classmethod __new__(*args, **kwargs)#