Commit 6b052e6
docs(survey): waive zero-weight-PSU SE-invariance item; lock Lumley full-design convention (#589)
* docs(survey): waive zero-weight-PSU SE-invariance item; lock Lumley full-design convention
Re-examined the TODO row proposing the survey TSL finite-sample correction
count only positive-weight PSUs so the SE is invariant to zero-weight
(subpopulation / padded) rows. Investigation shows the premise conflicts with
the library's documented, R-validated convention:
- `_compute_stratified_psu_meat`'s per-stratum correction
(1 - f_h)*n_PSU_h/(n_PSU_h - 1) and PSU-mean centering intentionally keep
genuine-subpopulation zero-weight PSUs. This is the full-design domain
estimator of Lumley (2004 Section 3.4) / R survey::svyrecvar(subset()),
already documented in REGISTRY section "Subpopulation Analysis".
- The ATT is exactly invariant; the survey SE is deliberately NOT invariant to
genuine-subpopulation zeroing (it should differ from a naive physical subset
-- that is the whole point of subpopulation()). R produces the matching SE
(only df differs).
- Zero-weight rows that reuse an existing PSU label are already bit-invariant.
The only invariance-violating shape -- appending synthetic new all-zero PSUs
-- arises in no estimator path (domain padding goes through prep.py's
zero-padded full-design cell variance, which retains the real PSU layout).
Forcing the meat to positive-weight-only counting would break the documented
Lumley/R parity, so the item is waived (no estimator behavior change):
- TODO.md: move the row from Actionable Backlog to "Won't-fix / waived
(decisions on the record)" with the Lumley/R justification.
- REGISTRY.md: add a Note in section "Subpopulation Analysis" making explicit
that the TSL meat finite-sample correction counts zero-weight PSUs by design.
- tests/test_survey.py: add TestZeroWeightPsuConventionWaiver regression-lock
(inert existing-PSU padding is bit-invariant; subpopulation zeroing keeps the
full PSU structure so its SE differs from a naive subset). A future
positive-weight-only change would collapse the two and trip the test.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* test(survey): add direct _compute_stratified_psu_meat full-design unit test
Addresses the CI review's actionable P3 (Documentation/Tests): the SE-level
test only asserts that subpopulation zeroing differs from a physical subset,
which catches a full positive-weight-only rewrite but could miss a partial
edit (e.g. changing only the finite-sample denominator while still centering
over the zero PSU).
Adds a direct unit test on _compute_stratified_psu_meat with crafted PSU
scores including one all-zero-score PSU (a fully zeroed subpopulation PSU),
asserting the exact full-design meat formula (n_PSU_h including the zero
PSU) and that it is NOT the positive-weight-only meat. Any change to the
centering OR the denominator now trips the lock.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* test(survey): model a true zero-weight PSU in the direct meat fixture
Addresses the re-review's actionable P3: the direct meat test represented its
all-zero PSU via zero score rows only, with weights left all ones. A future
denominator-only edit that reads resolved.weights to drop positive-weight PSUs
would not have been caught. Set PSU 2's weights to 0 so the fixture models a
true fully zero-weight subpopulation PSU. The current meat ignores weights
(it operates on scores), so the expected value is unchanged; the change only
hardens the regression lock.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent c8928d2 commit 6b052e6
3 files changed
Lines changed: 190 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
38 | 37 | | |
39 | 38 | | |
40 | 39 | | |
| |||
155 | 154 | | |
156 | 155 | | |
157 | 156 | | |
| 157 | + | |
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4538 | 4538 | | |
4539 | 4539 | | |
4540 | 4540 | | |
| 4541 | + | |
| 4542 | + | |
| 4543 | + | |
| 4544 | + | |
| 4545 | + | |
| 4546 | + | |
| 4547 | + | |
| 4548 | + | |
| 4549 | + | |
| 4550 | + | |
| 4551 | + | |
| 4552 | + | |
| 4553 | + | |
| 4554 | + | |
| 4555 | + | |
| 4556 | + | |
| 4557 | + | |
| 4558 | + | |
| 4559 | + | |
4541 | 4560 | | |
4542 | 4561 | | |
4543 | 4562 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
2146 | 2147 | | |
2147 | 2148 | | |
2148 | 2149 | | |
| 2150 | + | |
| 2151 | + | |
| 2152 | + | |
| 2153 | + | |
| 2154 | + | |
| 2155 | + | |
| 2156 | + | |
| 2157 | + | |
| 2158 | + | |
| 2159 | + | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
| 2179 | + | |
| 2180 | + | |
| 2181 | + | |
| 2182 | + | |
| 2183 | + | |
| 2184 | + | |
| 2185 | + | |
| 2186 | + | |
| 2187 | + | |
| 2188 | + | |
| 2189 | + | |
| 2190 | + | |
| 2191 | + | |
| 2192 | + | |
| 2193 | + | |
| 2194 | + | |
| 2195 | + | |
| 2196 | + | |
| 2197 | + | |
| 2198 | + | |
| 2199 | + | |
| 2200 | + | |
| 2201 | + | |
| 2202 | + | |
| 2203 | + | |
| 2204 | + | |
| 2205 | + | |
| 2206 | + | |
| 2207 | + | |
| 2208 | + | |
| 2209 | + | |
| 2210 | + | |
| 2211 | + | |
| 2212 | + | |
| 2213 | + | |
| 2214 | + | |
| 2215 | + | |
| 2216 | + | |
| 2217 | + | |
| 2218 | + | |
| 2219 | + | |
| 2220 | + | |
| 2221 | + | |
| 2222 | + | |
| 2223 | + | |
| 2224 | + | |
| 2225 | + | |
| 2226 | + | |
| 2227 | + | |
| 2228 | + | |
| 2229 | + | |
| 2230 | + | |
| 2231 | + | |
| 2232 | + | |
| 2233 | + | |
| 2234 | + | |
| 2235 | + | |
| 2236 | + | |
| 2237 | + | |
| 2238 | + | |
| 2239 | + | |
| 2240 | + | |
| 2241 | + | |
| 2242 | + | |
| 2243 | + | |
| 2244 | + | |
| 2245 | + | |
| 2246 | + | |
| 2247 | + | |
| 2248 | + | |
| 2249 | + | |
| 2250 | + | |
| 2251 | + | |
| 2252 | + | |
| 2253 | + | |
| 2254 | + | |
| 2255 | + | |
| 2256 | + | |
| 2257 | + | |
| 2258 | + | |
| 2259 | + | |
| 2260 | + | |
| 2261 | + | |
| 2262 | + | |
| 2263 | + | |
| 2264 | + | |
| 2265 | + | |
| 2266 | + | |
| 2267 | + | |
| 2268 | + | |
| 2269 | + | |
| 2270 | + | |
| 2271 | + | |
| 2272 | + | |
| 2273 | + | |
| 2274 | + | |
| 2275 | + | |
| 2276 | + | |
| 2277 | + | |
| 2278 | + | |
| 2279 | + | |
| 2280 | + | |
| 2281 | + | |
| 2282 | + | |
| 2283 | + | |
| 2284 | + | |
| 2285 | + | |
| 2286 | + | |
| 2287 | + | |
| 2288 | + | |
| 2289 | + | |
| 2290 | + | |
| 2291 | + | |
| 2292 | + | |
| 2293 | + | |
| 2294 | + | |
| 2295 | + | |
| 2296 | + | |
| 2297 | + | |
| 2298 | + | |
| 2299 | + | |
| 2300 | + | |
| 2301 | + | |
| 2302 | + | |
| 2303 | + | |
| 2304 | + | |
| 2305 | + | |
| 2306 | + | |
| 2307 | + | |
| 2308 | + | |
| 2309 | + | |
| 2310 | + | |
| 2311 | + | |
| 2312 | + | |
| 2313 | + | |
| 2314 | + | |
| 2315 | + | |
| 2316 | + | |
| 2317 | + | |
| 2318 | + | |
2149 | 2319 | | |
2150 | 2320 | | |
2151 | 2321 | | |
| |||
0 commit comments