diff_diff.DiagnosticReport#

class diff_diff.DiagnosticReport[source]#

Bases: object

Run the standard diff-diff diagnostic battery on a fitted result.

Parameters:
  • results (Any) – A fitted diff-diff results object (e.g. CallawaySantAnnaResults, DiDResults, SyntheticDiDResults). Any of the 16 result types in the library is accepted.

  • data (pandas.DataFrame, optional) – The underlying panel. Required for checks that need raw data (2x2 parallel-trends check on DiDResults; Bacon-from-scratch when results is not itself a Bacon fit; the opt-in placebo battery).

  • outcome (str, optional) – Column names identifying the panel structure.

  • treatment (str, optional) – Column names identifying the panel structure.

  • time (str, optional) – Column names identifying the panel structure.

  • unit (str, optional) – Column names identifying the panel structure.

  • first_treat (str, optional) – Column names identifying the panel structure.

  • pre_periods (list, optional) – Explicit pre- and post-treatment period labels.

  • post_periods (list, optional) – Explicit pre- and post-treatment period labels.

  • run_parallel_trends (bool) – Per-check opt-in flags. run_placebo defaults to False — the generic placebo battery is not implemented in MVP, so the placebo key remains reserved as skipped in the schema. (Exception: SyntheticControl’s in-space placebo permutation test IS implemented — run it via results.in_space_placebo(); its result is surfaced under estimator_native_diagnostics.in_space_placebo, not this generic section.) All other checks default to True and are further gated by estimator-type and instance-level applicability (see docs/methodology/REPORTING.md).

  • run_sensitivity (bool) – Per-check opt-in flags. run_placebo defaults to False — the generic placebo battery is not implemented in MVP, so the placebo key remains reserved as skipped in the schema. (Exception: SyntheticControl’s in-space placebo permutation test IS implemented — run it via results.in_space_placebo(); its result is surfaced under estimator_native_diagnostics.in_space_placebo, not this generic section.) All other checks default to True and are further gated by estimator-type and instance-level applicability (see docs/methodology/REPORTING.md).

  • run_placebo (bool) – Per-check opt-in flags. run_placebo defaults to False — the generic placebo battery is not implemented in MVP, so the placebo key remains reserved as skipped in the schema. (Exception: SyntheticControl’s in-space placebo permutation test IS implemented — run it via results.in_space_placebo(); its result is surfaced under estimator_native_diagnostics.in_space_placebo, not this generic section.) All other checks default to True and are further gated by estimator-type and instance-level applicability (see docs/methodology/REPORTING.md).

  • run_bacon (bool) – Per-check opt-in flags. run_placebo defaults to False — the generic placebo battery is not implemented in MVP, so the placebo key remains reserved as skipped in the schema. (Exception: SyntheticControl’s in-space placebo permutation test IS implemented — run it via results.in_space_placebo(); its result is surfaced under estimator_native_diagnostics.in_space_placebo, not this generic section.) All other checks default to True and are further gated by estimator-type and instance-level applicability (see docs/methodology/REPORTING.md).

  • run_design_effect (bool) – Per-check opt-in flags. run_placebo defaults to False — the generic placebo battery is not implemented in MVP, so the placebo key remains reserved as skipped in the schema. (Exception: SyntheticControl’s in-space placebo permutation test IS implemented — run it via results.in_space_placebo(); its result is surfaced under estimator_native_diagnostics.in_space_placebo, not this generic section.) All other checks default to True and are further gated by estimator-type and instance-level applicability (see docs/methodology/REPORTING.md).

  • run_heterogeneity (bool) – Per-check opt-in flags. run_placebo defaults to False — the generic placebo battery is not implemented in MVP, so the placebo key remains reserved as skipped in the schema. (Exception: SyntheticControl’s in-space placebo permutation test IS implemented — run it via results.in_space_placebo(); its result is surfaced under estimator_native_diagnostics.in_space_placebo, not this generic section.) All other checks default to True and are further gated by estimator-type and instance-level applicability (see docs/methodology/REPORTING.md).

  • run_epv (bool) – Per-check opt-in flags. run_placebo defaults to False — the generic placebo battery is not implemented in MVP, so the placebo key remains reserved as skipped in the schema. (Exception: SyntheticControl’s in-space placebo permutation test IS implemented — run it via results.in_space_placebo(); its result is surfaced under estimator_native_diagnostics.in_space_placebo, not this generic section.) All other checks default to True and are further gated by estimator-type and instance-level applicability (see docs/methodology/REPORTING.md).

  • run_pretrends_power (bool) – Per-check opt-in flags. run_placebo defaults to False — the generic placebo battery is not implemented in MVP, so the placebo key remains reserved as skipped in the schema. (Exception: SyntheticControl’s in-space placebo permutation test IS implemented — run it via results.in_space_placebo(); its result is surfaced under estimator_native_diagnostics.in_space_placebo, not this generic section.) All other checks default to True and are further gated by estimator-type and instance-level applicability (see docs/methodology/REPORTING.md).

  • sensitivity_M_grid (tuple of float, default (0.5, 1.0, 1.5, 2.0)) – Grid of M values passed to HonestDiD.sensitivity. Yields a SensitivityResults object with breakdown_M populated.

  • sensitivity_method (str, default "relative_magnitude") – HonestDiD restriction type.

  • alpha (float, default 0.05) – Significance level used across checks.

  • survey_design (SurveyDesign, optional) – The SurveyDesign object used to fit a survey-weighted estimator. Required for fit-faithful replay of Goodman-Bacon on a survey-backed fit; threaded to bacon_decompose(survey_design=...). When the fit carries survey_metadata but survey_design is not supplied, Bacon is skipped with an explicit reason rather than replaying an unweighted decomposition for a design that does not match the estimate. The simple 2x2 parallel-trends helper (utils.check_parallel_trends) has no survey-aware variant; on a survey-backed DiDResults it is skipped unconditionally regardless of survey_design. Supply precomputed={'parallel_trends': ...} with a survey-aware pretest to opt in. See docs/methodology/REPORTING.md.

  • precomputed (dict, optional) –

    Map of check name to a pre-computed result object. Accepted keys (this is the full implemented list; unsupported keys raise ValueError):

    • "parallel_trends" — a dict returned by utils.check_parallel_trends (adapted into the schema shape).

    • "sensitivity" — a SensitivityResults (grid) or HonestDiDResults (single-M) object; used verbatim and no HonestDiD.sensitivity_analysis call is made.

    • "pretrends_power" — a PreTrendsPowerResults object.

    • "bacon" — a BaconDecompositionResults object.

    Other sections (design_effect, heterogeneity, epv) are read directly from the fitted result object and do not currently accept precomputed values — there is no expensive call to bypass. placebo is reserved in the schema but opt-in / deferred in MVP for the generic battery; SyntheticControl surfaces its in-space placebo under estimator_native_diagnostics (run results.in_space_placebo()).

  • outcome_label (str, optional) – Plain-English labels used in prose rendering.

  • treatment_label (str, optional) – Plain-English labels used in prose rendering.

Methods

__init__(results, *[, data, outcome, ...])

export_markdown()

Alias for full_report().

full_report()

Return the multi-section markdown report.

run_all()

Run all applicable diagnostics.

summary()

Return a short plain-English paragraph.

to_dataframe()

Return one row per check with status and headline metric.

to_dict()

Return the AI-legible structured schema.

Attributes

applicable_checks

Names of checks that will run, given estimator + instance + options.

skipped_checks

Mapping of skipped check -> plain-English reason.

__init__(results, *, data=None, outcome=None, treatment=None, time=None, unit=None, first_treat=None, pre_periods=None, post_periods=None, run_parallel_trends=True, run_sensitivity=True, run_placebo=False, run_bacon=True, run_design_effect=True, run_heterogeneity=True, run_epv=True, run_pretrends_power=True, sensitivity_M_grid=(0.5, 1.0, 1.5, 2.0), sensitivity_method='relative_magnitude', alpha=0.05, survey_design=None, precomputed=None, outcome_label=None, treatment_label=None)[source]#
Parameters:
  • results (Any)

  • data (DataFrame | None)

  • outcome (str | None)

  • treatment (str | None)

  • time (str | None)

  • unit (str | None)

  • first_treat (str | None)

  • pre_periods (List[Any] | None)

  • post_periods (List[Any] | None)

  • run_parallel_trends (bool)

  • run_sensitivity (bool)

  • run_placebo (bool)

  • run_bacon (bool)

  • run_design_effect (bool)

  • run_heterogeneity (bool)

  • run_epv (bool)

  • run_pretrends_power (bool)

  • sensitivity_M_grid (Tuple[float, ...])

  • sensitivity_method (str)

  • alpha (float)

  • survey_design (Any | None)

  • precomputed (Dict[str, Any] | None)

  • outcome_label (str | None)

  • treatment_label (str | None)

classmethod __new__(*args, **kwargs)#