Skip to content

Commit bb703d6

Browse files
Add causal inference modules (DID, RD, IV, fixest) and unify package API
Integrate pyfixest for high-dimensional fixed effects estimation via thin wrapper module (statspai.fixest). Add Difference-in-Differences (2x2 and Callaway-Sant'Anna), regression discontinuity, IV/2SLS, and synthetic control modules. Introduce unified CausalResult class for all causal methods with outreg2 compatibility. Rebrand imports from pyeconometrics to statspai. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e3ff200 commit bb703d6

21 files changed

Lines changed: 4444 additions & 123 deletions

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,7 @@ dmypy.json
159159
.Trashes
160160
ehthumbs.db
161161
Thumbs.db
162+
163+
164+
# Files
165+
Start Superpower for R.md

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ performance = [
5656
"jax[cpu]>=0.4.0",
5757
"jaxlib>=0.4.0",
5858
]
59+
fixest = [
60+
"pyfixest>=0.25.0",
61+
]
5962
plotting = [
6063
"matplotlib>=3.5.0",
6164
"seaborn>=0.11.0",

src/statspai/__init__.py

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,58 @@
11
"""
22
StatsPAI: The AI-powered Statistics & Econometrics Toolkit for Python
33
4-
This package provides tools for econometric analysis including:
5-
- OLS regression with robust standard errors
6-
- Causal Forest for heterogeneous treatment effects
7-
- Panel data models (IV/2SLS)
8-
- Time series analysis
9-
- Publication-ready output formatting
4+
Unified API for causal inference and econometrics:
105
11-
Basic usage:
126
>>> import statspai as sp
13-
>>>
14-
>>> # Traditional regression
15-
>>> result = pe.regress("y ~ x1 + x2", data=df)
16-
>>> result.summary()
17-
>>>
18-
>>> # Causal Forest for treatment effects
19-
>>> cf = pe.causal_forest("y ~ treatment | x1 + x2", data=df)
20-
>>> effects = cf.effect(df[['x1', 'x2']])
21-
>>>
22-
>>> # Export results
23-
>>> pe.outreg2(result, cf, filename="results.xlsx")
7+
>>>
8+
>>> # OLS regression
9+
>>> result = sp.regress("y ~ x1 + x2", data=df)
10+
>>>
11+
>>> # Difference-in-Differences
12+
>>> result = sp.did(df, y='wage', treat='treated', time='post')
13+
>>>
14+
>>> # Staggered DID (Callaway & Sant'Anna)
15+
>>> result = sp.did(df, y='wage', treat='first_treat',
16+
... time='year', id='worker_id')
17+
>>>
18+
>>> # Causal Forest
19+
>>> cf = sp.causal_forest("y ~ treatment | x1 + x2", data=df)
20+
>>>
21+
>>> # Publication-quality export
22+
>>> sp.outreg2(result, filename="results.xlsx")
2423
"""
2524

26-
from .core.results import EconometricResults
25+
__version__ = "0.1.0"
26+
__author__ = "Bryce Wang"
27+
__email__ = "bryce@copaper.ai"
28+
29+
from .core.results import EconometricResults, CausalResult
2730
from .regression.ols import regress
31+
from .regression.iv import ivreg, IVRegression
2832
from .causal.causal_forest import CausalForest, causal_forest
33+
from .did import did, did_2x2, callaway_santanna
34+
from .rd import rdrobust, rdplot
2935
from .output.outreg2 import OutReg2, outreg2
3036

31-
__version__ = "0.1.0"
32-
__author__ = "StatsPAI Team"
33-
__email__ = "contact@statspai.org"
34-
3537
__all__ = [
38+
# Core
39+
"EconometricResults",
40+
"CausalResult",
41+
# Regression
3642
"regress",
37-
"EconometricResults",
43+
"ivreg",
44+
"IVRegression",
45+
# DID
46+
"did",
47+
"did_2x2",
48+
"callaway_santanna",
49+
# RD
50+
"rdrobust",
51+
"rdplot",
52+
# Causal Forest
3853
"CausalForest",
3954
"causal_forest",
55+
# Output
4056
"OutReg2",
4157
"outreg2",
4258
]
43-
44-
__version__ = "0.1.0"
45-
__author__ = "Bryce Wang"
46-
__email__ = "your.email@example.com"
47-
48-
from .regression.ols import regress
49-
from .core.results import EconometricResults
50-
51-
__all__ = [
52-
"regress",
53-
"EconometricResults",
54-
]

0 commit comments

Comments
 (0)