Skip to content

Commit 7b78c63

Browse files
Add new analysis modules (bartik, causal_impact, diagnostics, dml, matching, mediation, panel, synth) and modelsummary output
New modules: shift-share/Bartik IV, causal impact analysis, sensitivity diagnostics, double ML, propensity score matching, causal mediation, panel regression, and synthetic control. Added modelsummary output formatter and comprehensive tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent bb703d6 commit 7b78c63

32 files changed

Lines changed: 6158 additions & 15 deletions

pyproject.toml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,32 @@ description = "The AI-powered Statistics & Econometrics Toolkit for Python"
99
readme = "README.md"
1010
license = "MIT"
1111
authors = [
12-
{name = "Bryce Wang", email = "bryce.wang@example.com"}
12+
{name = "Bryce Wang", email = "bryce@copaper.ai"}
1313
]
1414
maintainers = [
15-
{name = "Bryce Wang", email = "bryce.wang@example.com"}
15+
{name = "Bryce Wang", email = "bryce@copaper.ai"}
1616
]
1717
classifiers = [
1818
"Development Status :: 3 - Alpha",
1919
"Intended Audience :: Science/Research",
2020
"Operating System :: OS Independent",
2121
"Programming Language :: Python :: 3",
22-
"Programming Language :: Python :: 3.8",
2322
"Programming Language :: Python :: 3.9",
2423
"Programming Language :: Python :: 3.10",
2524
"Programming Language :: Python :: 3.11",
2625
"Programming Language :: Python :: 3.12",
26+
"Programming Language :: Python :: 3.13",
2727
"Topic :: Scientific/Engineering :: Mathematics",
2828
"Topic :: Office/Business :: Financial",
2929
]
30-
keywords = ["econometrics", "statistics", "regression", "causal-inference", "causal-forest", "panel-data", "instrumental-variables", "stata", "R", "machine-learning"]
31-
requires-python = ">=3.8"
30+
keywords = [
31+
"econometrics", "statistics", "causal-inference",
32+
"difference-in-differences", "regression-discontinuity",
33+
"synthetic-control", "matching", "propensity-score",
34+
"instrumental-variables", "panel-data", "double-ml",
35+
"stata", "R", "machine-learning",
36+
]
37+
requires-python = ">=3.9"
3238
dependencies = [
3339
"numpy>=1.20.0",
3440
"pandas>=1.3.0",
@@ -40,6 +46,7 @@ dependencies = [
4046
"patsy>=0.5.0",
4147
"openpyxl>=3.0.0",
4248
"xlsxwriter>=3.0.0",
49+
"python-docx>=1.0.0",
4350
]
4451

4552
[project.optional-dependencies]
@@ -66,10 +73,10 @@ plotting = [
6673
]
6774

6875
[project.urls]
69-
Homepage = "https://github.com/brycewang-stanford/pyEconometrics"
76+
Homepage = "https://github.com/brycewang-stanford/statspai"
7077
Documentation = "https://statspai.readthedocs.io/"
71-
Repository = "https://github.com/brycewang-stanford/pyEconometrics"
72-
"Bug Reports" = "https://github.com/brycewang-stanford/pyEconometrics/issues"
78+
Repository = "https://github.com/brycewang-stanford/statspai"
79+
"Bug Reports" = "https://github.com/brycewang-stanford/statspai/issues"
7380

7481
[tool.setuptools.packages.find]
7582
where = ["src"]
@@ -79,7 +86,7 @@ where = ["src"]
7986

8087
[tool.black]
8188
line-length = 88
82-
target-version = ['py38']
89+
target-version = ['py39']
8390

8491
[tool.pytest.ini_options]
8592
testpaths = ["tests"]
@@ -89,7 +96,7 @@ python_functions = ["test_*"]
8996
addopts = "--cov=statspai --cov-report=html --cov-report=term-missing"
9097

9198
[tool.mypy]
92-
python_version = "3.8"
99+
python_version = "3.9"
93100
warn_return_any = true
94101
warn_unused_configs = true
95102
disallow_untyped_defs = true

src/statspai/__init__.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,16 @@
3232
from .causal.causal_forest import CausalForest, causal_forest
3333
from .did import did, did_2x2, callaway_santanna
3434
from .rd import rdrobust, rdplot
35+
from .synth import synth, SyntheticControl
36+
from .matching import match, MatchEstimator
37+
from .dml import dml, DoubleML
38+
from .panel import panel, PanelRegression
39+
from .causal_impact import causal_impact, CausalImpactEstimator
40+
from .mediation import mediate, MediationAnalysis
41+
from .bartik import bartik, BartikIV
3542
from .output.outreg2 import OutReg2, outreg2
43+
from .output.modelsummary import modelsummary, coefplot
44+
from .diagnostics import oster_bounds, mccrary_test
3645

3746
__all__ = [
3847
# Core
@@ -49,10 +58,36 @@
4958
# RD
5059
"rdrobust",
5160
"rdplot",
61+
# Synthetic Control
62+
"synth",
63+
"SyntheticControl",
64+
# Matching
65+
"match",
66+
"MatchEstimator",
67+
# Double ML
68+
"dml",
69+
"DoubleML",
70+
# Panel
71+
"panel",
72+
"PanelRegression",
73+
# Causal Impact
74+
"causal_impact",
75+
"CausalImpactEstimator",
5276
# Causal Forest
5377
"CausalForest",
5478
"causal_forest",
5579
# Output
5680
"OutReg2",
5781
"outreg2",
82+
"modelsummary",
83+
"coefplot",
84+
# Mediation
85+
"mediate",
86+
"MediationAnalysis",
87+
# Bartik IV
88+
"bartik",
89+
"BartikIV",
90+
# Diagnostics
91+
"oster_bounds",
92+
"mccrary_test",
5893
]

src/statspai/bartik/__init__.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""
2+
Shift-Share (Bartik) Instrumental Variables for StatsPAI.
3+
4+
Constructs Bartik instruments from industry shares and national shocks,
5+
with diagnostics for instrument validity following Goldsmith-Pinkham,
6+
Sorkin, and Swift (2020) and Borusyak, Hull, and Jaravel (2022).
7+
8+
References
9+
----------
10+
Goldsmith-Pinkham, P., Sorkin, I., and Swift, H. (2020).
11+
"Bartik Instruments: What, When, Why, and How."
12+
*American Economic Review*, 110(8), 2586-2624.
13+
14+
Borusyak, K., Hull, P., and Jaravel, X. (2022).
15+
"Quasi-Experimental Shift-Share Research Designs."
16+
*Review of Economic Studies*, 89(1), 181-213.
17+
"""
18+
19+
from .shift_share import bartik, BartikIV
20+
21+
__all__ = ['bartik', 'BartikIV']

0 commit comments

Comments
 (0)