Commit 8bd7171
fix(linalg): cluster-count check precedes saturated-design NaN guard (CI review P1)
The saturated-design guard added earlier (n_eff <= k -> NaN vcov) was placed
before the cluster-robust "need >= 2 clusters" validation, so a 1-cluster
*saturated* cluster-robust request returned all-NaN instead of raising the
documented ValueError (verified: compute_robust_vcov(eye(2), 0, zeros(2)) now
raises; a non-saturated 1-cluster fit always raised). The cluster-count check
(with the zero-total-weight effective-cluster exclusion) now runs first on the
clustered path; the saturated NaN return only applies once that assumption
holds. Multi-cluster saturated designs still return NaN (no ZeroDivisionError),
and full-rank fits are unchanged.
Tests: 1-cluster saturated -> ValueError; 2-cluster saturated -> NaN vcov
(tests/test_linalg.py::TestComputeRobustVcov).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 91a458d commit 8bd7171
2 files changed
Lines changed: 33 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2623 | 2623 | | |
2624 | 2624 | | |
2625 | 2625 | | |
| 2626 | + | |
| 2627 | + | |
| 2628 | + | |
| 2629 | + | |
| 2630 | + | |
| 2631 | + | |
| 2632 | + | |
| 2633 | + | |
| 2634 | + | |
| 2635 | + | |
| 2636 | + | |
| 2637 | + | |
| 2638 | + | |
| 2639 | + | |
| 2640 | + | |
| 2641 | + | |
2626 | 2642 | | |
2627 | 2643 | | |
2628 | 2644 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
531 | 531 | | |
532 | 532 | | |
533 | 533 | | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
534 | 550 | | |
535 | 551 | | |
536 | 552 | | |
| |||
2140 | 2156 | | |
2141 | 2157 | | |
2142 | 2158 | | |
2143 | | - | |
2144 | | - | |
2145 | | - | |
| 2159 | + | |
2146 | 2160 | | |
2147 | 2161 | | |
2148 | 2162 | | |
| |||
0 commit comments