Add yatchew_hr_test(null='mean_independence') mode#397
Conversation
|
Overall Assessment ✅ Looks good — no unmitigated P0 or P1 findings. Executive Summary
Methodology No findings. The affected estimator surface is Code Quality No findings. Performance No findings. The change adds only a small dispatch branch plus intercept-only helper(s); the asymptotic cost of the Yatchew path is unchanged ( Maintainability No findings. The intercept-only mode is isolated in dedicated helpers and reuses the existing downstream variance code instead of duplicating formula logic ( Tech Debt No findings. This PR closes a previously tracked follow-up rather than introducing new untracked deferred work. Security No findings. The diff is limited to numerical logic, documentation, and tests; it does not add new I/O, parsing, credential, or command-execution surface. Documentation/Tests No findings. The added tests cover the exact interaction points that mattered here: default back-compat, weighted/unweighted composition, duplicate-dose and low- |
35833fb to
d7c45db
Compare
|
/ai-review |
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall Assessment ✅ Looks good Executive Summary
Methodology
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
|
P3: REGISTRY.md / docstring narrative inconsistency. Updates main Yatchew algorithm block (REGISTRY.md:2469-2477), Phase 3 row (REGISTRY.md:2546), module-level docstring (had_pretests.py:14-16), and YatchewTestResults class docstring (had_pretests.py:323-330) to describe yatchew_hr_test as a specification test with both nulls, labelling mean_independence explicitly as the documented R-parity extension (vs paper-derived linearity). P3: null_form propagation lightly tested. Adds three explicit regression tests in the existing test classes the reviewer cited: - TestJSONSerialization.test_yatchew_to_dict_carries_null_form: locks to_dict()["null_form"] for both modes. - TestSummary.test_yatchew_summary_switches_title_on_null_form: locks summary() title switching with both positive and negative controls. - TestSummary.test_yatchew_repr_includes_null_form: locks null_form= appears in repr() for both modes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
/ai-review |
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall Assessment ✅ Looks good Executive Summary
Methodology
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
|
Mirrors R YatchewTest::yatchew_test(order=0). Closes the placebo Yatchew R-parity gap from PR #392. - New keyword-only `null: Literal["linearity", "mean_independence"]` on `yatchew_hr_test` (default `"linearity"` is bit-exact backcompat). - `"mean_independence"` fits intercept-only OLS (residuals = dy - mean(dy)); the downstream sigma2_diff / sigma2_W / sort-by-d machinery is shared. - Wired through both unweighted and survey-weighted code paths (4-arm dispatch on (null × weighted)). - `YatchewTestResults` gained `null_form: str = "linearity"` field; `summary()` renders the correct null-hypothesis title; `__repr__` and `to_dict()` updated. - `tests/test_did_had_parity.py::TestYatchewParity` removed the placebo skip; routes effect rows through `null="linearity"` (R order=1) and placebo rows through `null="mean_independence"` (R order=0); both modes share the documented `× G/(G-1)` finite-sample convention shift and parity holds at `atol=1e-10`. - New `TestYatchewHRTestMeanIndependence` class (15 tests) covering happy path, naive Python baseline at `atol=1e-12`, population-variance closed form, invalid value, default backcompat, mode-agnostic tie/constant-d rejection, NaN handling, weighted reduction at w=ones(G) at `atol=1e-14`, weighted non-uniform baseline, default-under-weights, survey×null orthogonality, the (linearity, weighted) baseline (4-arm coverage), zero/replicate-weight rejection, and G<3 mode-agnostic. One additive backcompat case in each of `TestYatchewHRTest` and `TestYatchewHRTestSurvey`. - REGISTRY.md HAD § Yatchew note: TODO marker replaced with shipped description. CHANGELOG.md and TODO.md updated. Patch-level (additive keyword-only kwarg + additive dataclass field with default). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
P3: REGISTRY.md / docstring narrative inconsistency. Updates main Yatchew algorithm block (REGISTRY.md:2469-2477), Phase 3 row (REGISTRY.md:2546), module-level docstring (had_pretests.py:14-16), and YatchewTestResults class docstring (had_pretests.py:323-330) to describe yatchew_hr_test as a specification test with both nulls, labelling mean_independence explicitly as the documented R-parity extension (vs paper-derived linearity). P3: null_form propagation lightly tested. Adds three explicit regression tests in the existing test classes the reviewer cited: - TestJSONSerialization.test_yatchew_to_dict_carries_null_form: locks to_dict()["null_form"] for both modes. - TestSummary.test_yatchew_summary_switches_title_on_null_form: locks summary() title switching with both positive and negative controls. - TestSummary.test_yatchew_repr_includes_null_form: locks null_form= appears in repr() for both modes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ac66214 to
ebdcede
Compare
|
/ai-review |
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall Assessment ✅ Looks good Executive Summary
Methodology
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
|
Summary
null: Literal["linearity", "mean_independence"] = "linearity"toyatchew_hr_test. New mode mirrors RYatchewTest::yatchew_test(order=0)— fits intercept-only OLS so residuals aredy - mean(dy)instead ofdy - (a + b·d). Downstreamsigma2_diff/sigma2_W/ sort-by-dmachinery is shared between the two modes.(null × weighted)).tests/test_did_had_parity.py::TestYatchewParitynow routes effect rows throughnull="linearity"and placebo rows throughnull="mean_independence". Both modes share the documented× G/(G-1)finite-sample convention shift and parity holds atatol=1e-10.YatchewTestResultsgainednull_form: str = "linearity"field;summary()renders the correct null-hypothesis title;__repr__andto_dict()updated.Patch-level (additive keyword-only kwarg + additive dataclass field with default). Default
null="linearity"is bit-exact backcompat across all existing tests.Test plan
pytest tests/test_had_pretests.py::TestYatchewHRTest tests/test_had_pretests.py::TestYatchewHRTestSurvey tests/test_had_pretests.py::TestYatchewHRTestMeanIndependence tests/test_did_had_parity.py(58 tests)pytest tests/test_had_pretests.py(full file regression — 237 tests)pytest tests/test_had.py tests/test_had_dual_knob_deprecation.py(HAD estimator + deprecation regressions — 368 tests)🤖 Generated with Claude Code