Commit f8e959c
Address PR #370 R4 review (1 P0 + 1 P1)
R4 P0 (Methodology) -- Yatchew test statistic was not invariant to
uniform pweight rescaling. The formula `T_hr = sqrt(sum(w)) * (...)`
makes T_hr scale as sqrt(c) under weights -> w * c, so weights=w and
weights=100*w produced different p-values for the same design. Worse,
SurveyDesign.resolve() normalizes pweights to mean=1 internally, so
the survey= entry path and the weights= shortcut disagreed numerically.
Fix: normalize per-unit pweights to mean=1 at every helper entry
(stute_test, yatchew_hr_test, stute_joint_pretest) and at the workflow
resolution helper. Matches SurveyDesign.resolve() convention; makes
the Yatchew statistic scale-invariant; ensures weights=w and
survey=SurveyDesign(weights="w") produce identical results for the
same design. Stute is internally scale-invariant in functional form
but normalization is required so the bootstrap helper sees the same
weight vector under both entry paths (cross-path numerical agreement).
R4 P1 (Code Quality) -- column-vector weights (e.g. `df[["w"]].to_numpy()`
producing (G, 1)) silently broadcast through weighted moments / CvM
sums instead of raising. Fix: validate via `_validate_1d_numeric` on
all `weights=` arrays in stute_test, yatchew_hr_test, stute_joint_pretest;
add explicit ndim check in `_resolve_pretest_unit_weights` with a
hint about the common df[["w"]].to_numpy() mistake.
6 new regression tests in TestPhase45CR1Regressions:
- test_yatchew_weights_scale_invariant (weights=w vs weights=100*w)
- test_stute_weights_scale_invariant (mirror for Stute)
- test_workflow_weights_eq_survey_at_overall_path (weights= shortcut
and survey=SurveyDesign(...) produce identical Yatchew + Stute
results, atol=1e-10)
- test_stute_test_rejects_2d_weights / test_yatchew_hr_test_rejects_2d_weights
/ test_workflow_rejects_2d_weights (column-vector rejection at all
three direct-helper / workflow entry points)
177 pretest tests pass (was 171 after R3).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 39b29a9 commit f8e959c
2 files changed
Lines changed: 154 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1548 | 1548 | | |
1549 | 1549 | | |
1550 | 1550 | | |
| 1551 | + | |
| 1552 | + | |
1551 | 1553 | | |
1552 | | - | |
| 1554 | + | |
1553 | 1555 | | |
1554 | 1556 | | |
1555 | 1557 | | |
1556 | 1558 | | |
1557 | 1559 | | |
1558 | | - | |
1559 | | - | |
1560 | | - | |
1561 | | - | |
1562 | | - | |
1563 | | - | |
1564 | 1560 | | |
1565 | 1561 | | |
1566 | 1562 | | |
| |||
1570 | 1566 | | |
1571 | 1567 | | |
1572 | 1568 | | |
1573 | | - | |
| 1569 | + | |
1574 | 1570 | | |
1575 | 1571 | | |
1576 | 1572 | | |
| |||
1584 | 1580 | | |
1585 | 1581 | | |
1586 | 1582 | | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
1587 | 1594 | | |
1588 | 1595 | | |
1589 | 1596 | | |
| |||
1895 | 1902 | | |
1896 | 1903 | | |
1897 | 1904 | | |
| 1905 | + | |
1898 | 1906 | | |
1899 | | - | |
| 1907 | + | |
1900 | 1908 | | |
1901 | 1909 | | |
1902 | 1910 | | |
| |||
1909 | 1917 | | |
1910 | 1918 | | |
1911 | 1919 | | |
1912 | | - | |
| 1920 | + | |
1913 | 1921 | | |
1914 | 1922 | | |
1915 | 1923 | | |
| |||
1924 | 1932 | | |
1925 | 1933 | | |
1926 | 1934 | | |
| 1935 | + | |
| 1936 | + | |
| 1937 | + | |
| 1938 | + | |
| 1939 | + | |
| 1940 | + | |
| 1941 | + | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
1927 | 1946 | | |
1928 | 1947 | | |
1929 | 1948 | | |
| |||
2682 | 2701 | | |
2683 | 2702 | | |
2684 | 2703 | | |
| 2704 | + | |
2685 | 2705 | | |
2686 | | - | |
| 2706 | + | |
| 2707 | + | |
| 2708 | + | |
2687 | 2709 | | |
2688 | 2710 | | |
2689 | 2711 | | |
| |||
2698 | 2720 | | |
2699 | 2721 | | |
2700 | 2722 | | |
2701 | | - | |
| 2723 | + | |
2702 | 2724 | | |
2703 | 2725 | | |
2704 | 2726 | | |
| |||
2712 | 2734 | | |
2713 | 2735 | | |
2714 | 2736 | | |
| 2737 | + | |
| 2738 | + | |
| 2739 | + | |
| 2740 | + | |
| 2741 | + | |
2715 | 2742 | | |
2716 | 2743 | | |
2717 | 2744 | | |
| |||
2915 | 2942 | | |
2916 | 2943 | | |
2917 | 2944 | | |
| 2945 | + | |
| 2946 | + | |
| 2947 | + | |
| 2948 | + | |
| 2949 | + | |
| 2950 | + | |
| 2951 | + | |
| 2952 | + | |
| 2953 | + | |
| 2954 | + | |
2918 | 2955 | | |
2919 | 2956 | | |
2920 | 2957 | | |
| |||
2927 | 2964 | | |
2928 | 2965 | | |
2929 | 2966 | | |
| 2967 | + | |
| 2968 | + | |
| 2969 | + | |
| 2970 | + | |
| 2971 | + | |
2930 | 2972 | | |
2931 | 2973 | | |
2932 | 2974 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3724 | 3724 | | |
3725 | 3725 | | |
3726 | 3726 | | |
| 3727 | + | |
| 3728 | + | |
| 3729 | + | |
| 3730 | + | |
| 3731 | + | |
| 3732 | + | |
| 3733 | + | |
| 3734 | + | |
| 3735 | + | |
| 3736 | + | |
| 3737 | + | |
| 3738 | + | |
| 3739 | + | |
| 3740 | + | |
| 3741 | + | |
| 3742 | + | |
| 3743 | + | |
| 3744 | + | |
| 3745 | + | |
| 3746 | + | |
| 3747 | + | |
| 3748 | + | |
| 3749 | + | |
| 3750 | + | |
| 3751 | + | |
| 3752 | + | |
| 3753 | + | |
| 3754 | + | |
| 3755 | + | |
| 3756 | + | |
| 3757 | + | |
| 3758 | + | |
| 3759 | + | |
| 3760 | + | |
| 3761 | + | |
| 3762 | + | |
| 3763 | + | |
| 3764 | + | |
| 3765 | + | |
| 3766 | + | |
| 3767 | + | |
| 3768 | + | |
| 3769 | + | |
| 3770 | + | |
| 3771 | + | |
| 3772 | + | |
| 3773 | + | |
| 3774 | + | |
| 3775 | + | |
| 3776 | + | |
| 3777 | + | |
| 3778 | + | |
| 3779 | + | |
| 3780 | + | |
| 3781 | + | |
| 3782 | + | |
| 3783 | + | |
| 3784 | + | |
| 3785 | + | |
| 3786 | + | |
| 3787 | + | |
| 3788 | + | |
| 3789 | + | |
| 3790 | + | |
| 3791 | + | |
| 3792 | + | |
| 3793 | + | |
| 3794 | + | |
| 3795 | + | |
| 3796 | + | |
| 3797 | + | |
| 3798 | + | |
| 3799 | + | |
| 3800 | + | |
| 3801 | + | |
| 3802 | + | |
| 3803 | + | |
| 3804 | + | |
| 3805 | + | |
| 3806 | + | |
| 3807 | + | |
| 3808 | + | |
| 3809 | + | |
| 3810 | + | |
| 3811 | + | |
| 3812 | + | |
| 3813 | + | |
| 3814 | + | |
| 3815 | + | |
| 3816 | + | |
| 3817 | + | |
| 3818 | + | |
| 3819 | + | |
| 3820 | + | |
| 3821 | + | |
| 3822 | + | |
| 3823 | + | |
| 3824 | + | |
| 3825 | + | |
| 3826 | + | |
0 commit comments