Open-source econometrics in Python for Stata, EViews and SPSS users
What an open-source Python workflow for econometrics looks like, which familiar tasks OpenEconometrics covers today and where its limits are.
Many economists learn econometrics in Stata, EViews or SPSS. These packages are mature and well documented, and their results are widely trusted. The reasons to look at an open-source alternative are practical: licence costs for students and teams, the freedom to read the code that produces a number, and scripts that a co-author or replicator can run without buying the same software.
This guide describes what that workflow looks like with OpenEconometrics, an open-source Python library and desktop workbench. It also covers what the project does not do yet, so you can decide whether it fits your work.
What OpenEconometrics is
OpenEconometrics is published on PyPI as the openecon package under the Apache 2.0 licence. It runs on Python 3.11 to 3.14. The estimators, covariance matrices and tests are written in the project itself on PyTorch float64 tensors. Packages such as statsmodels and SciPy are used only in the test suite, as independent references. The source-generated capability inventory lists 171 registered estimator names across linear, panel, instrumental-variable, discrete-choice, count, time-series, survival and treatment-effect families.
The project is a 0.3 alpha. The inventory states the supported options and the exclusions for every estimator. Treat a model or option that is not listed there as unsupported.
pip install openecon
The desktop app packages the same Python library in a workbench with a code editor, a persistent Python session, a data inspector, charts and LaTeX export. Analyses run on your own computer.
The workflow in one script
A typical applied analysis has the same steps in any package: load data, fit a model with a chosen inference method, run postestimation, and publish a table. The code below runs as a plain Python script with the published package.
import openecon as oe
df = oe.example() # 480 synthetic rows; read your own data with pandas.read_csv or read_stata
# 1. Fit OLS with a formula, a categorical control and HC3 standard errors
model = oe.ols(
data=df,
formula="wage ~ education + experience + C(region)",
covariance="HC3",
)
print(model.summary())
# 2. Joint and linear tests, as with test and lincom
print(model.test(["education", "experience"]))
print(model.lincom({"education": 1, "experience": -1}))
# 3. Average marginal effects, as with margins
print(model.margins(variables=["education"], method="ame"))
# 4. A publication table from the saved results
baseline = oe.ols(data=df, y="wage", x=["education"], covariance="HC3")
oe.regression_table([baseline, model], "wage_models.tex", precision=3)
OpenEconometrics accepts pandas DataFrames, dictionaries of columns and lists of records, so pandas can read CSV, Excel, Parquet and Stata .dta files for it. Categorical variables use treatment coding with the first level omitted. Rows with missing model variables are dropped by default in OLS, and missing="raise" makes that choice explicit.
Familiar commands and their counterparts
OpenEconometrics uses Stata-style names for many functions, which makes the move easier for Stata users. The table maps common tasks to functions in the published package. A matching name does not mean that every option of the original command is available. Check the method guide and oe.capabilities() for the options you rely on.
| Task | Stata command | OpenEconometrics |
|---|---|---|
| Linear regression | regress | oe.ols(...) or oe.regress(...) |
| Heteroskedasticity-robust errors | vce(robust) | covariance="robust" (HC1), "HC2", "HC3" |
| Clustered errors | vce(cluster id) | cluster="id", one to four dimensions |
| Newey–West errors | newey | oe.newey(...) or covariance="hac" |
| Panel fixed and random effects | xtreg, fe / xtreg, re | oe.xtreg(..., model="fe") / model="re" |
| Hausman test | hausman | oe.hausman(fe, re) |
| Instrumental variables | ivregress 2sls | oe.ivregress(..., endog=[...], instruments=[...]) |
| High-dimensional fixed effects | reghdfe (community) | oe.reghdfe(..., absorb=[...]) |
| Binary outcomes | logit / probit | oe.logit(...) / oe.probit(...) |
| Count data | poisson | oe.poisson(...) |
| Quantile regression | qreg | oe.qreg(..., quantile=0.5) |
| Unit-root test | dfuller | oe.dfuller(...) |
| ARIMA and VAR | arima / var | oe.arima(...) / oe.var(...) |
| Regression tables | esttab (community) | oe.regression_table(...) |
For SPSS users, analysis of variance with post-hoc comparisons is available as oe.oneway(df, "score", "group", posthoc=["tukey", "games_howell"]). For EViews users, the time-series family includes ARIMA, VAR and vector error-correction models, ARCH-type models and the Dickey–Fuller, Phillips–Perron and KPSS tests. The econometrics guide links each family's formulas, conventions and limitations.
What changes when you move to Python
Scripts replace session logs. A Python script is the record of the analysis. It runs from top to bottom on a clean machine, and version control shows every change. The reproducibility guide covers this in more detail.
Results are objects. A fitted model keeps its coefficients, full covariance matrix, sample information and provenance. Tests, predictions and tables are computed from that saved result, so a number in a table always comes from the model that produced it.
Defaults are stated. OLS uses classical standard errors unless you choose otherwise. Supplying cluster= without a covariance selects clustered errors, and sampling weights default to HC1. Every table note records the covariance method, the inference distribution and the estimation sample.
Current limits
Be clear about these before you plan a project around the alpha:
- Full Stata coverage and numerical parity with Stata have not been established. Some methods have been compared with published examples and independent references. That evidence does not cover every option.
- OpenEconometrics does not run Stata, EViews or SPSS commands and does not translate do-files or programs.
- Logit and probit support classical and one-way clustered covariance. Each estimator lists its own supported options.
- The desktop app is an alpha for Apple Silicon Macs with macOS 15 or later, and for Windows. The Mac app is ad-hoc signed; Apple Developer ID signing and notarization are pending. The Windows installer is unsigned. The download page shows the first-launch steps.
Where to go next
- Read robust and clustered standard errors for the inference options in detail.
- Work through the teaching labs, which pair economic questions with complete Python analyses.
- See how to validate econometric results before you rely on any package, including this one.