Commit c6c2c38
Use positive-weight count for HC1/classical df with zero-weight rows
When pweight/aweight fits have zero-weight rows (from subpopulation),
use np.count_nonzero(weights > 0) for HC1 df adjustments instead of
total n. Zero-weight rows contribute nothing to the sandwich and
should not inflate df.
Also fix clustered SEs to exclude zero-total-weight clusters from
G/(G-1) small-sample correction, and DEFF effective_n to use
positive-weight count.
Survey design df (n_PSU - n_strata) unchanged — preserves design
structure matching R's survey::degf() convention.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent a3d2343 commit c6c2c38
3 files changed
Lines changed: 31 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1046 | 1046 | | |
1047 | 1047 | | |
1048 | 1048 | | |
1049 | | - | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
1050 | 1053 | | |
1051 | | - | |
1052 | | - | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
1053 | 1059 | | |
1054 | 1060 | | |
1055 | 1061 | | |
| |||
1075 | 1081 | | |
1076 | 1082 | | |
1077 | 1083 | | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
1078 | 1089 | | |
1079 | 1090 | | |
1080 | 1091 | | |
| |||
1741 | 1752 | | |
1742 | 1753 | | |
1743 | 1754 | | |
1744 | | - | |
| 1755 | + | |
| 1756 | + | |
1745 | 1757 | | |
1746 | | - | |
1747 | | - | |
| 1758 | + | |
| 1759 | + | |
| 1760 | + | |
| 1761 | + | |
| 1762 | + | |
1748 | 1763 | | |
1749 | 1764 | | |
1750 | 1765 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
849 | 849 | | |
850 | 850 | | |
851 | 851 | | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
852 | 855 | | |
853 | 856 | | |
854 | 857 | | |
| |||
861 | 864 | | |
862 | 865 | | |
863 | 866 | | |
864 | | - | |
| 867 | + | |
865 | 868 | | |
866 | 869 | | |
867 | 870 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2093 | 2093 | | |
2094 | 2094 | | |
2095 | 2095 | | |
2096 | | - | |
2097 | | - | |
2098 | | - | |
2099 | | - | |
2100 | | - | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
| 2099 | + | |
| 2100 | + | |
| 2101 | + | |
2101 | 2102 | | |
2102 | 2103 | | |
2103 | 2104 | | |
| |||
0 commit comments