Skip to content

fix(design): align the unreleased design-stage API before release (power_results, not_checked, two-sided power in power_by_M) - #917

Open
igerber wants to merge 1 commit into
mainfrom
fix/design-api-consistency
Open

igerber wants to merge 1 commit into
mainfrom
fix/design-api-consistency

Conversation

@igerber

@igerber igerber commented Nov 26, 2026

Copy link
Copy Markdown
Owner

Summary

A consistency pass over the design-stage API added since 4.0.0, before it is released. Nothing here changes behaviour of anything in 4.0.0: every name below was introduced after that release.

Renames and values:

  • DesignDiagnosisResults.results is now power_results, and the matching key of to_dict() likewise. results meant two things in the same module: the per-estimator power cells on the diagnosis, and the fitted model on DesignReconciliationResults (which keeps results). The new name sits beside mde_results and event_study_results.
  • The reconciliation check status "not checked" is now "not_checked". Every other status value in the library is snake_case, and the report block already spells its own keys not_checked / n_not_checked. The summary text is unchanged.
  • design.placebo_pretest_rate and design.PLACEBO_ESTIMAND are now private (_placebo_pretest_rate, _PLACEBO_ESTIMAND). Neither was exported; every sibling helper already had an underscore.

HonestDiD.power_by_M:

  • power is now the share of draws whose interval excludes zero, on either side: the rule of HonestDiDResults.is_significant and of the rejection rates diagnose_design reports, so "power" has one meaning across the diagnosis. It previously counted only intervals on the effect's side of zero. mde is unchanged (it is set from the effect's side alone, the larger of the two signs), and its guarantee still holds: an interval on the effect's side excludes zero, so power is at least that share and the target is reached for every effect larger than mde. The two definitions differ by at most placebo_rejection_rate; tutorial 34's numbers are unchanged.
  • The table gains a size_controlled column. It was computed per row and then dropped, so a withheld row was recognisable only by its NaN. The diagnosis table already has that column.

Error messages:

  • HonestDiD.fit(diagnosis) (and sensitivity_analysis, breakdown_value, compute_honest_did) raised a generic "Unsupported results type". It now raises the same ValueError as for a placebo event study, pointing to power_by_M.
  • DMLDiDResults.get_loo_effects_df() is inherited from CallawaySantAnnaResults and can never succeed (DMLDiD has no vcov_type); its error told the user to refit with CallawaySantAnna. It now says the method is not available for DMLDiD results.

Reviewed and left as it is: DesignLock.fit returning the reconciliation with the estimate in .results; event_study= on diagnose_design; placebo_rejection_rate in both planning tables; design_reconciliation= on the reports.

Methodology references (required if estimator / math changes)

  • Method name(s): HonestDiD (design-stage planning). docs/methodology/REGISTRY.md ## HonestDiD, Note (design-stage planning, power_by_M): the power(th) line of the definition block and the paragraph on power and mde are rewritten for the two-sided definition, and size_controlled is added to the block.
  • Paper / source link(s): N/A. power_by_M is a library procedure with no paper source (Rambachan & Roth 2023 give no planning procedure); the Note says so.
  • Any intentional deviations from the source (and why): None new. The definition of power moves to the one the rest of the diagnosis uses.

Validation

  • Tests added/updated: tests/test_design_sensitivity.py (two-sided power against real injection on every identity case; power counts an exclusion on either side; mde is set from the effect's side only and the target holds above it for both signs; the size_controlled column; fit(diagnosis) and sensitivity_analysis(diagnosis) name power_by_M), tests/test_staggered_jackknife.py (the DMLDiD accessor error; the refusal itself was already tested), tests/test_diagnostic_marker.py (the shared reconciliation fixture uses the status vocabulary, and the summary and report block count its skipped check), tests/test_design.py, tests/test_methodology_design.py, tests/test_design_event_study.py, tests/test_t34_design_diagnosis_drift.py, tests/helpers/results_foundation.py (renames and the status value).
  • Backtest / simulation / notebook evidence (if applicable): tutorial 34 was re-executed; one source line changed (result.power_results) and every output is identical. benchmarks/data/sensitivity_planning_check.json is unchanged: it checks the planned mde, whose definition did not change.
  • The affected suites pass on both backends; mypy diff_diff at the pinned versions reports no errors; the Sphinx -W build passes.

Security / privacy

  • Confirm no secrets/PII in this PR: Yes

Changelog

  • changelog.d/ fragment added (or N/A - no user-visible change): N/A relative to 4.0.0 (every name changed here is unreleased). The existing fragment 20261126-sensitivity-planning.md is updated so the release notes describe power and size_controlled as shipped.

Every name changed here was introduced after 4.0.0.

- DesignDiagnosisResults.results -> power_results (and the to_dict() key).
  `results` also names the fitted model on DesignReconciliationResults,
  which keeps it; the new name sits beside mde_results and
  event_study_results.
- The reconciliation check status "not checked" -> "not_checked", the
  spelling of every other status value and of the report block's own keys.
- design.placebo_pretest_rate and design.PLACEBO_ESTIMAND are private
  (neither was exported).
- HonestDiD.power_by_M: `power` is the share of draws whose interval excludes
  zero on either side, the definition of the rejection rates diagnose_design
  reports (it counted the effect's side only). `mde` is unchanged and its
  guarantee still holds. The table gains the `size_controlled` column it
  computed and dropped.
- HonestDiD.fit and its siblings raise the power_by_M pointer for a design
  diagnosis too, not a generic "Unsupported results type".
- DMLDiDResults.get_loo_effects_df says it is not available for DMLDiD; the
  inherited message told the user to refit with CallawaySantAnna.
@github-actions

Copy link
Copy Markdown

Overall assessment: ✅ Looks good

No unmitigated P0, P1, or P2 findings identified.

Executive summary

  • Two-sided power matches the updated Methodology Registry definition.
  • The directional MDE threshold remains explicitly documented.
  • API renames propagate consistently through callers, serialization, reporting, and examples.
  • Static checks passed; runtime tests could not run because the environment lacks test and numerical dependencies.

Methodology

Affected method: HonestDiD.power_by_M. Reviewed against the Registry, docstrings, and the repository’s Rambachan–Roth (2023) paper review. The Registry explicitly identifies planning as a library procedure without a paper source.

  • P3 — Informational: documented MDE convention.
    Location: diff_diff/honest_did.py:L3851-L3861; docs/methodology/REGISTRY.md:L6799-L6816.
    Impact: Two-sided power can reach the target below the reported directional MDE. The Registry expressly documents this conservative convention and its guarantee above MDE.
    Concrete fix: None required.

Empty and nonfinite interval handling remains intact; failed size checks retain NaN power and MDE values. No estimator, weighting, or variance changes were introduced.

Code Quality

No findings. Renamed helpers and diagnosis fields have no stale callers in the searched source, tests, or benchmarks.

Performance

No findings. The additional rejection condition introduces negligible work relative to the existing interval calculations.

Maintainability

No findings. The shared extraction guard consistently routes diagnosis inputs toward planning, and the DML accessor now gives an applicable error.

Tech Debt

No new untracked limitation identified. Existing planning restrictions are documented or tracked.

Security

No findings in the supplied diff.

Documentation/Tests

No actionable findings. Documentation, examples, tests, and a changelog fragment were updated.

All 14 changed Python files and the tutorial’s code cells parsed successfully. Targeted pytest execution stopped before collection because pytest is unavailable; NumPy, pandas, and SciPy are also absent. Runtime behavior and backend parity therefore remain unverified in this environment.

@igerber igerber added the ready-for-ci Triggers CI test workflows label Nov 26, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ci Triggers CI test workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant