StatsPAI v0.2.0
StatsPAI v0.2.0
The Causal Inference & Econometrics Toolkit for Python.
What's New
Post-Estimation (Stata margins / test / lincom)
sp.margins(result, data=df)— Average Marginal Effects with delta-method SEsp.marginsplot(me)— Visualize marginal effectssp.test(result, "x1 = x2")— Wald test for linear restrictionssp.lincom(result, "x1 + x2")— Linear combinations with inference
Publication Tables
sp.sumstats(df, vars=[...])— Summary statistics (Statatabstat)sp.balance_table(df, treat='T', covariates=[...])— Balance table for matching/DIDsp.tab(df, 'var1', 'var2')— Cross-tabulation with chi² test (Statatab, chi2)
Export to Word (.docx)
sp.outreg2(r1, r2, filename='table.docx')— Multi-model table to Wordsp.modelsummary(r1, r2, output='table.docx')— Comparison table to Wordresult.to_docx('result.docx')— Any single result to Word- All tables support:
.docx,.xlsx,.tex,.html
Inference
sp.wild_cluster_bootstrap()— Wild cluster bootstrap for few-cluster inferencesp.aipw()— Augmented Inverse Probability Weighting
Other Improvements
- PSM now warns about King & Nielsen (2019) bias concerns
- Updated README with Stata/R comparison table
python-docxadded as core dependency
Full Module List (v0.2.0)
| Category | Functions |
|---|---|
| Regression | regress, ivreg, panel |
| DID | did, callaway_santanna |
| RD | rdrobust, rdplot |
| Matching | match (PSM/CEM/Mahalanobis) |
| Synth | synth |
| ML Causal | dml, causal_forest |
| Other | causal_impact, mediate, bartik |
| Post-estimation | margins, test, lincom |
| Diagnostics | oster_bounds, mccrary_test |
| Tables | modelsummary, outreg2, sumstats, balance_table, tab |
| Inference | wild_cluster_bootstrap, aipw |
Install
pip install statspai==0.2.0280 tests | 78% coverage | Python >= 3.9