Commit af10cc4
stacked_did: address CI codex R2 P2 — clustered variance label
R2 verdict was ✅ + 1 P2: the summary's Variance: line (added in R1)
mislabelled clustered StackedDiD fits as one-way ("HC1
heteroskedasticity-robust" / "HC2 + Bell-McCaffrey DOF (one-way, n=N)")
because I passed cluster_name=None to _format_vcov_label. StackedDiD
is intrinsically clustered.
Fix:
- Added `cluster_name` and `n_clusters` fields to StackedDiDResults
dataclass.
- Populated both at fit() time: cluster_name=self.cluster, n_clusters=
np.unique(cluster_ids).size (matches the actual realized count, not
config).
- summary() now passes cluster_name + n_clusters into
_format_vcov_label, rendering "CR1 cluster-robust at unit, G=50"
for hc1 and "CR2 Bell-McCaffrey cluster-robust at unit, G=50" for
hc2_bm.
New regression test test_summary_renders_clustered_variance_label
verifies:
- hc1 → label contains "CR1 cluster-robust at unit"
- hc2_bm → label contains "CR2 Bell-McCaffrey cluster-robust at unit"
- Neither contains "(one-way" (catches the R2 regression directly)
- G= cluster count present
- cluster="unit_subexp" → label contains "at unit_subexp"
90 tests pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent f0aa060 commit af10cc4
3 files changed
Lines changed: 52 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
835 | 835 | | |
836 | 836 | | |
837 | 837 | | |
| 838 | + | |
| 839 | + | |
838 | 840 | | |
839 | 841 | | |
840 | 842 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
101 | 108 | | |
102 | 109 | | |
103 | 110 | | |
| |||
177 | 184 | | |
178 | 185 | | |
179 | 186 | | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
184 | 191 | | |
185 | 192 | | |
186 | 193 | | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | 194 | | |
192 | 195 | | |
193 | | - | |
194 | | - | |
| 196 | + | |
| 197 | + | |
195 | 198 | | |
196 | 199 | | |
197 | 200 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1678 | 1678 | | |
1679 | 1679 | | |
1680 | 1680 | | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
| 1685 | + | |
| 1686 | + | |
| 1687 | + | |
| 1688 | + | |
| 1689 | + | |
| 1690 | + | |
| 1691 | + | |
| 1692 | + | |
| 1693 | + | |
| 1694 | + | |
| 1695 | + | |
| 1696 | + | |
| 1697 | + | |
| 1698 | + | |
| 1699 | + | |
| 1700 | + | |
| 1701 | + | |
| 1702 | + | |
| 1703 | + | |
| 1704 | + | |
| 1705 | + | |
| 1706 | + | |
| 1707 | + | |
| 1708 | + | |
| 1709 | + | |
| 1710 | + | |
| 1711 | + | |
| 1712 | + | |
| 1713 | + | |
| 1714 | + | |
| 1715 | + | |
| 1716 | + | |
| 1717 | + | |
0 commit comments