diff_diff.BusinessReport#
- class diff_diff.BusinessReport[source]#
Bases:
objectProduce a stakeholder-ready narrative from any diff-diff results object.
- Parameters:
results (Any) – A fitted diff-diff results object. Any of the 16 result types is accepted.
BaconDecompositionResultsis not a valid input — Bacon is a diagnostic, not an estimator; useDiagnosticReportfor that.outcome_label (str, optional) – Stakeholder-friendly outcome name (e.g.
"Revenue per user").outcome_unit (str, optional) – Unit label:
"$"/"%"/"pp"/"log_points"/"count"(recognized for formatting) or any free-form string (used verbatim without arithmetic translation).outcome_direction (str, optional) –
"higher_is_better"or"lower_is_better". Drives whether the effect is described as “lift” / “drag” rather than just “increase” / “decrease”.business_question (str, optional) – Question the analysis answers (prepended to the summary).
treatment_label (str, optional) – Stakeholder-friendly treatment name (e.g.
"the campaign").alpha (float, optional) – Significance level. Defaults to
results.alphawhen not supplied. Single knob: drives both CI level and significance phrasing.honest_did_results (HonestDiDResults or SensitivityResults, optional) – Pre-computed sensitivity result. When supplied, this is forwarded to the internal
DiagnosticReportso sensitivity is not re-computed.auto_diagnostics (bool, default True) – When
TrueanddiagnosticsisNone, auto-construct aDiagnosticReport. SetFalseto skip diagnostics entirely.diagnostics (DiagnosticReport or DiagnosticReportResults, optional) – Explicit diagnostics object. Takes precedence over
auto_diagnostics.include_appendix (bool, default True) – Whether
full_report()appends the estimator’s academicresults.summary()output under a “Technical Appendix” section.data (optional) – Raw panel + column names forwarded to the auto-constructed
DiagnosticReportso data-dependent checks (2x2 PT on simple DiD, Bacon-from-scratch, EfficientDiD Hausman pretest) can run.outcome (optional) – Raw panel + column names forwarded to the auto-constructed
DiagnosticReportso data-dependent checks (2x2 PT on simple DiD, Bacon-from-scratch, EfficientDiD Hausman pretest) can run.treatment (optional) – Raw panel + column names forwarded to the auto-constructed
DiagnosticReportso data-dependent checks (2x2 PT on simple DiD, Bacon-from-scratch, EfficientDiD Hausman pretest) can run.unit (optional) – Raw panel + column names forwarded to the auto-constructed
DiagnosticReportso data-dependent checks (2x2 PT on simple DiD, Bacon-from-scratch, EfficientDiD Hausman pretest) can run.time (optional) – Raw panel + column names forwarded to the auto-constructed
DiagnosticReportso data-dependent checks (2x2 PT on simple DiD, Bacon-from-scratch, EfficientDiD Hausman pretest) can run.first_treat (optional) – Raw panel + column names forwarded to the auto-constructed
DiagnosticReportso data-dependent checks (2x2 PT on simple DiD, Bacon-from-scratch, EfficientDiD Hausman pretest) can run.survey_design (SurveyDesign, optional) – The
SurveyDesignobject used to fit a survey-weighted estimator. Forwarded to the auto-constructedDiagnosticReportfor fit-faithful Goodman-Bacon replay. When the fit carriessurvey_metadatabutsurvey_designis 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-backedDiDResultsit is skipped unconditionally regardless ofsurvey_design. Supplyprecomputed={'parallel_trends': ...}with a survey-aware pretest to opt in. Seedocs/methodology/REPORTING.md.precomputed (dict, optional) – Pre-computed diagnostic objects forwarded to the auto- constructed
DiagnosticReport(same keys asDiagnosticReport(precomputed=...)):"parallel_trends","sensitivity","pretrends_power","bacon". DR validates keys and rejects estimator-incompatible entries (e.g., HonestDiD bounds or generic PT on SDiD / TROP).honest_did_resultsremains a shorthand forsensitivity; an explicitprecomputed['sensitivity']wins on conflict.
Methods
__init__(results, *[, outcome_label, ...])caveats()Return the list of structured caveats (severity + topic + message).
export_markdown()Alias for
full_report()(discoverability).full_report()Return a structured multi-section markdown report.
headline()Return just the headline sentence.
summary()Return a short plain-English paragraph block (6-10 sentences).
to_dict()Return the AI-legible structured schema (single source of truth).
to_json(*[, indent])Return
to_dict()serialized as JSON.- __init__(results, *, outcome_label=None, outcome_unit=None, outcome_direction=None, business_question=None, treatment_label=None, alpha=None, honest_did_results=None, auto_diagnostics=True, diagnostics=None, include_appendix=True, data=None, outcome=None, treatment=None, unit=None, time=None, first_treat=None, survey_design=None, precomputed=None)[source]#
- Parameters:
results (Any)
outcome_label (str | None)
outcome_unit (str | None)
outcome_direction (str | None)
business_question (str | None)
treatment_label (str | None)
alpha (float | None)
honest_did_results (Any | None)
auto_diagnostics (bool)
diagnostics (DiagnosticReport | DiagnosticReportResults | None)
include_appendix (bool)
data (Any | None)
outcome (str | None)
treatment (str | None)
unit (str | None)
time (str | None)
first_treat (str | None)
survey_design (Any | None)
- classmethod __new__(*args, **kwargs)#