Commit e82faab
Fix CI review R13: preserve NaN-SE contract on degenerate-cohort survey fits
_plugin_se returns NaN when the cohort-recentered IF is empty or
identically zero (documented degenerate-cohort contract — every
variance-eligible group is its own (D_{g,1}, F_g, S_g) singleton).
_survey_se_from_group_if only rejected negative variance, so on the
same panel it computed sqrt(0) = 0.0, suppressed the degenerate-cohort
warning (gated on np.isnan(overall_se)), and exposed a false zero SE.
The bug affected every surface routed through _compute_se — top-level
ATT, joiners/leavers, multi-horizon ATT, placebos, and derived
normalized/cumulated SEs.
Mirror the _plugin_se contract: short-circuit to NaN when U_centered
is empty or sum(U_centered**2) <= 0, before delegating to
compute_survey_if_variance.
Added TestSurveyWithinGroupValidation.test_degenerate_cohort_survey_se_is_nan:
4 groups × 5 periods, each switching at a unique F_g so every cohort
is a singleton; asserts overall_se is NaN (not 0.0) and that the
degenerate-cohort warning fires under the survey path.
All 272 targeted tests pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 657b62b commit e82faab
2 files changed
Lines changed: 58 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4874 | 4874 | | |
4875 | 4875 | | |
4876 | 4876 | | |
| 4877 | + | |
| 4878 | + | |
| 4879 | + | |
| 4880 | + | |
| 4881 | + | |
| 4882 | + | |
| 4883 | + | |
| 4884 | + | |
| 4885 | + | |
| 4886 | + | |
| 4887 | + | |
| 4888 | + | |
4877 | 4889 | | |
4878 | 4890 | | |
4879 | 4891 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1117 | 1117 | | |
1118 | 1118 | | |
1119 | 1119 | | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
1120 | 1166 | | |
1121 | 1167 | | |
1122 | 1168 | | |
| |||
0 commit comments