Commit 6dca2dd
feat(synth): 7 new SCM methods — Bayesian, BSTS/CausalImpact, Penalized (A&L 2021), FDID, Cluster, Sparse, Kernel
Expand synthetic control module from 13 to 20 methods, making StatsPAI
the most comprehensive SCM toolkit in any language (Python, R, or Stata).
New modules (5,009 LOC):
- bayesian.py: Full Bayesian SCM with MCMC posterior inference
- bsts.py: Bayesian Structural Time Series / CausalImpact (Brodersen et al. 2015)
- penscm.py: Penalized SCM with pairwise discrepancy (Abadie & L'Hour, JASA 2021)
- fdid.py: Forward DID with optimal donor selection (Li 2024)
- cluster.py: Cluster SCM with donor grouping (kmeans/spectral/hierarchical)
- sparse.py: Sparse SCM with L1 penalties (Amjad, Shah & Shen 2018)
- kernel.py: Kernel-based nonlinear SCM (RBF, polynomial, Laplacian)
Integration:
- synth() dispatcher routes all 20 methods via unified API
- __init__.py exports 9 new public functions
- compare.py method registry updated for benchmarking
- 50 new tests (119 total synth tests, all passing)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 052594a commit 6dca2dd
15 files changed
Lines changed: 8162 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
63 | 67 | | |
64 | 68 | | |
65 | 69 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
20 | 27 | | |
21 | 28 | | |
22 | 29 | | |
23 | 30 | | |
24 | 31 | | |
25 | 32 | | |
26 | 33 | | |
| 34 | + | |
| 35 | + | |
27 | 36 | | |
28 | 37 | | |
29 | 38 | | |
| |||
54 | 63 | | |
55 | 64 | | |
56 | 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 | + | |
57 | 96 | | |
58 | 97 | | |
59 | 98 | | |
| |||
77 | 116 | | |
78 | 117 | | |
79 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
80 | 126 | | |
81 | 127 | | |
82 | 128 | | |
83 | 129 | | |
84 | | - | |
| 130 | + | |
85 | 131 | | |
86 | 132 | | |
87 | 133 | | |
| |||
100 | 146 | | |
101 | 147 | | |
102 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
103 | 159 | | |
104 | 160 | | |
105 | 161 | | |
106 | 162 | | |
107 | 163 | | |
108 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
109 | 176 | | |
110 | 177 | | |
111 | 178 | | |
| |||
120 | 187 | | |
121 | 188 | | |
122 | 189 | | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
123 | 193 | | |
0 commit comments