Commit cfea355
feat(callaway): allow_unbalanced_panel — RC-on-panel parity with R did
Adds CallawaySantAnna(allow_unbalanced_panel=True) matching R
did::att_gt(allow_unbalanced_panel=TRUE) on unbalanced panels. When set and the
input panel is unbalanced, the pooled observations route through the
repeated-cross-section levels estimator (DRDID::reg_did_rc) instead of the
default within-cell panel differencing (a different estimand on unbalanced
data), and the per-observation influence function is clustered by the original
unit.
ATT matches R bit-for-bit (cells AND dynamic aggregation): the RC cohort mass
and the aggregation pg use fixed UNIT cohort mass (not observation count), and
the per-unit WIF divides the per-observation weight-influence-function by each
unit's observation count so the unit-clustered sum is not over-counted. The
analytical SE matches R up to the documented CR1 sqrt(G/(G-1)) finite-sample
factor (diff-diff's cluster path applies the Bessel correction R's att_gt getSE
omits). The bootstrap resamples by unit via the same PSU.
Inert on balanced panels (byte-identical to the default). Independently, the
default path now emits a UserWarning on unbalanced input (previously silent).
survey_design= with the flag raises NotImplementedError (deferred).
Routing engages only when the panel is actually unbalanced (route-as-RC via an
internal flag threaded through the six self.panel sites; the unique-unit guard
is naturally bypassed since panel stays True). Verified vs R did 2.5.1
(benchmarks/data/cs_unbalanced_golden.json + TestAllowUnbalancedPanel); 499 CS
tests pass (RC / survey / panel paths unchanged). The TODO's "weighting" framing
was a mis-diagnosis: the dominant unbalanced divergence is the estimator choice.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0178r8ZK6VRiXbaBiknrWjQB1 parent 9208007 commit cfea355
10 files changed
Lines changed: 926 additions & 72 deletions
File tree
- benchmarks
- R
- data
- diff_diff
- docs/methodology
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
53 | 65 | | |
54 | 66 | | |
55 | 67 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
| 131 | + | |
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
Large diffs are not rendered by default.
0 commit comments