Commit 7888c24
v0.9.17: three-school completion + clinical/MR depth + preregistration + review-fix pass
Three-school completion driven by the "Causal Inference Knowledge Map"
article (Econometrics / Epidemiology / ML), adds the entry-level
primitives, DSL, and QA layer that closed the last gaps vs. Stata / R.
New subpackages
- sp.epi — OR / RR / RD / AF / IRR / NNT / PR, Mantel-Haenszel
(+ Tarone-corrected Breslow-Day), direct + indirect
standardization, Bradford-Hill rubric, and the
clinical-diagnostics toolkit (sensitivity/
specificity, ROC + Hanley-McNeil SE, Cohen's kappa).
- sp.longitudinal — unified What-If Layer-4 dispatcher (IPW / MSM /
parametric g-formula ICE) plus a safe AST-walked
dynamic-treatment-regime DSL (no eval). contrast()
gives delta-method SE for two-regime comparisons.
- sp.question — estimand-first causal_question() DSL with
identify() -> estimate() -> report() flow and an
auto-design picker (IV / RD / DiD / longitudinal /
selection-on-observables).
MR full suite (sp.mr / sp.mendelian extended)
- Cochran Q / Ruecker Q', MR-Egger intercept test (t(n-2)),
leave-one-out, Steiger directionality, MR-PRESSO with per-SNP
outlier + distortion tests, Radial MR, weighted/simple mode
estimator (Hartwig ZEMPA), F-statistic instrument-strength panel,
funnel + scatter plot helpers.
Target Trial Emulation flagship
- TargetTrialResult.to_paper(fmt=markdown/latex/text) renders
STROBE-compatible Methods + Results blocks tracking the JAMA 2022
7-component TTE spec.
- fmt='target' adds the JAMA/BMJ Sep-2025 TARGET Statement 21-item
checklist with AUTO-filled fields from the protocol + result.
DAG UX
- DAG.recommend_estimator() with priority backdoor -> IV -> frontdoor
-> not-identifiable, plain-English identification story, and a
mediator detector.
Unified sensitivity dashboard
- result.sensitivity() method on CausalResult + EconometricResults;
single call runs E-value + Oster delta + Rosenbaum Gamma + Sensemakr
+ a CI-based breakdown-frontier estimate.
Pre-registration
- sp.preregister() / sp.load_preregister() + CausalQuestion.save() /
.load() / .to_yaml() produce OSF/AEA-style PAP files with a
timestamp + statspai-version metadata block, zero-dep YAML fallback.
Registry
- 20+ hand-written rich FunctionSpec entries for the new APIs; total
public callables registered now 729+, including first-class entries
for every new sp.epi / sp.mr / sp.longitudinal / sp.question name.
Independent review fixes (2 Critical + 5 High + 4 Medium)
- Critical: Katz RR SE formula corrected for Haldane-corrected cells.
- Critical: Mantel-Haenszel homogeneity Q replaced with the correct
inverse-variance weighted chi^2(K-1) form (previously fabricated).
- Regime AST walker now rejects non-numeric values from history
(blocks callable/string leakage via user-controlled dicts).
- NNT CI ordering fixed when RD CI is entirely negative.
- unified_sensitivity no longer fabricates beta_uncontrolled for
Oster delta; requires explicit input or skips with a warning.
- unified_sensitivity breakdown bias_to_flip now derives from the CI
bound closer to the null, not abs(estimate).
- unified_sensitivity exceptions now emit warnings.warn instead of
silently returning NaN.
- MR-Egger intercept p-value uses t(n-2) (matches R packages).
- mr_radial requires >= 2 SNPs; mr_f_statistic now reports per-SNP F.
- Longitudinal g-formula warns when pivot fills missing panel cells.
- YAML serializer partitions on ": " so colons in values round-trip.
Tests
- 129 new tests across 11 new test files; 0 regressions across the
2158-test existing suite.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 2a5f368 commit 7888c24
99 files changed
Lines changed: 18448 additions & 41 deletions
File tree
- src/statspai
- agent
- bcf
- bounds
- bridge
- causal_discovery
- conformal_causal
- dag
- did
- epi
- fairness
- longitudinal
- mendelian
- proximal
- qte
- question
- rd
- robustness
- surrogate
- synth
- target_trial
- tmle
- tests
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
181 | | - | |
| 181 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
75 | 77 | | |
76 | 78 | | |
77 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
78 | 180 | | |
79 | 181 | | |
80 | 182 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
| |||
73 | 75 | | |
74 | 76 | | |
75 | 77 | | |
| 78 | + | |
76 | 79 | | |
77 | 80 | | |
78 | 81 | | |
| |||
115 | 118 | | |
116 | 119 | | |
117 | 120 | | |
| 121 | + | |
| 122 | + | |
118 | 123 | | |
119 | 124 | | |
120 | 125 | | |
| |||
168 | 173 | | |
169 | 174 | | |
170 | 175 | | |
171 | | - | |
172 | | - | |
| 176 | + | |
| 177 | + | |
173 | 178 | | |
174 | | - | |
175 | | - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
176 | 190 | | |
177 | 191 | | |
178 | 192 | | |
179 | | - | |
| 193 | + | |
180 | 194 | | |
181 | 195 | | |
182 | 196 | | |
| |||
191 | 205 | | |
192 | 206 | | |
193 | 207 | | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
194 | 227 | | |
195 | 228 | | |
196 | 229 | | |
| |||
216 | 249 | | |
217 | 250 | | |
218 | 251 | | |
| 252 | + | |
| 253 | + | |
219 | 254 | | |
220 | 255 | | |
221 | 256 | | |
| |||
234 | 269 | | |
235 | 270 | | |
236 | 271 | | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
237 | 275 | | |
238 | 276 | | |
239 | 277 | | |
| |||
250 | 288 | | |
251 | 289 | | |
252 | 290 | | |
| 291 | + | |
253 | 292 | | |
254 | 293 | | |
255 | 294 | | |
| |||
349 | 388 | | |
350 | 389 | | |
351 | 390 | | |
| 391 | + | |
| 392 | + | |
352 | 393 | | |
353 | 394 | | |
354 | 395 | | |
| |||
372 | 413 | | |
373 | 414 | | |
374 | 415 | | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
375 | 421 | | |
376 | 422 | | |
377 | 423 | | |
| |||
1039 | 1085 | | |
1040 | 1086 | | |
1041 | 1087 | | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
1042 | 1092 | | |
1043 | 1093 | | |
1044 | 1094 | | |
1045 | 1095 | | |
1046 | 1096 | | |
1047 | 1097 | | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
1048 | 1101 | | |
1049 | 1102 | | |
1050 | 1103 | | |
1051 | 1104 | | |
1052 | | - | |
| 1105 | + | |
1053 | 1106 | | |
1054 | 1107 | | |
| 1108 | + | |
1055 | 1109 | | |
1056 | 1110 | | |
1057 | 1111 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
50 | 57 | | |
51 | 58 | | |
52 | 59 | | |
53 | 60 | | |
54 | 61 | | |
55 | 62 | | |
56 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
57 | 69 | | |
0 commit comments