EconEnv
One Notebook. Multiple Econometric Engines.
Python, R, Stata and EViews in a single Jupyter workflow — on one Python kernel.
The problem
An applied econometrics paper rarely lives in one program. The unit-root test is
in EViews because that is where the ARDL bounds output is readable. The panel
estimator is in Stata because xtreg is the reference implementation. The plots
are in R because ggplot2 is better. The data cleaning is in Python because
pandas is better.
So the working day looks like this:
Python → to_csv() → Stata → export delimited → R → write.csv → EViews
Four programs open. Four windows. Four copies of the same data, drifting apart.
A missing value that meant .a in Stata arriving as an empty cell in R. A
quarterly index that became a string. And when a referee asks "why does your
robust standard error differ from mine?", there is no way to answer without
redoing the whole chain by hand.
The solution
EconEnv makes the four programs execution engines behind one Python kernel.
%load_ext econenv
df = pd.read_csv("data.csv") # Python, as usual
%%R -i df
fit <- lm(y ~ x1 + x2, data = df)
summary(fit)
%%stata
regress y x1 x2
%%eviews -i df
equation eq1.ls y c x1 x2
One notebook. One kernel. One dataset. No CSV round-trip.
And then the part that is hard to do any other way:
econenv.compare_ols(df, "y ~ x1 + x2")
OLS: y ~ x1 + x2
Engines agree within tolerance (rtol=1e-08, atol=1e-10)
Coefficients
python r stata eviews
term
x1 0.4821094 0.4821094 0.4821094 0.4821094
x2 -0.1330277 -0.1330277 -0.1330277 -0.1330277
_cons 1.9042118 1.9042118 1.9042118 1.9042118
Notes:
- aic: AIC normalisation differs: statsmodels -2ll+2k; R counts sigma^2 as a
parameter (k+1); EViews divides by n; Stata needs `estat ic`.
The coefficients match. The information criteria do not — and EconEnv says why, instead of quietly picking one.
Architecture
graph TD
A[JupyterLab / Notebook] --> B[IPython / Python kernel]
B --> C[EconEnv extension]
C --> D[Magics: %econ · %R · %stata · %eviews]
C --> E[Engine registry]
E --> F[Python engine]
E --> G[R engine]
E --> H[Stata engine]
E --> I[EViews engine]
G --> G1[subprocess backend<br/>persistent Rterm]
G --> G2[rpy2 backend<br/>when installed]
H --> H1[PyStata<br/>official]
I --> I1[COM automation<br/>comtypes]
C --> J[Data bridges<br/>pandas is canonical]
C --> K[Results · Diagnostics · Snapshots]
E -.future.-> L[MATLAB · Julia · SAS · Gretl · Dynare · GAUSS · Ox · RATS]
Three rules hold the design together:
- No custom kernel. EconEnv is a Python package plus an IPython extension. A polyglot kernel is evaluated in the roadmap, not assumed.
- Nothing above the engine layer touches a vendor API. Magics, the CLI,
diagnostics and the model layer speak only to
BaseEngine. Adding MATLAB means writing one adapter, not editing the core. - Never hide a difference. Lossy conversions warn. Engine disagreements are reported with the defaults that explain them.
Features
| Four engines, one kernel | Python, R, Stata, EViews — persistent sessions, no kernel switching |
| Real data bridge | pandas.DataFrame is canonical; push/pull/move between any two engines with no file round-trip |
| Type fidelity | Factors, categoricals, dates, booleans, integers and missing values survive the trip — or you get a warning saying exactly what changed |
| Econometric metadata | Time variable, panel variable, frequency, labels and conversion history travel with the frame |
| Structured results | ExecutionResult and ModelResult instead of scraped text; raw engine output always retained |
| Cross-engine comparison | Same specification, four engines, one table, with tolerance-aware agreement testing |
| Diagnostics | econenv doctor checks every layer and tells you how to fix what is broken |
| Reproducibility | Environment snapshots and provenance records (code hash, data hash, versions, timing) |
| Rich output | HTML tables, PNG/SVG plots from R and EViews rendered inline |
| Honest about limits | Capability matrix reports what each engine can do on this machine, not in theory |
Installation
pip install econenv
Optional extras — install only what you use:
pip install "econenv[stata]" # helper for locating PyStata
pip install "econenv[eviews]" # comtypes, Windows only
pip install "econenv[arrow]" # fast Arrow transfer to R
pip install "econenv[all]"
Then, in a notebook:
%load_ext econenv
%econ doctor
Requirements
| Required | Notes | |
|---|---|---|
| Python | 3.9+ | the host kernel |
| pandas, numpy, IPython | yes | installed automatically |
| R | optional | 4.0+; EconEnv finds it, no PATH setup needed |
| Stata | optional | 17 or newer — PyStata ships with Stata 17+ |
| EViews | optional | Windows only; automation is COM-based |
comtypes |
for EViews | pip install "econenv[eviews]" |
rpy2 |
never required | no Windows wheels; EconEnv's subprocess backend replaces it |
Engine setup
EconEnv discovers installations automatically — environment variables, PATH,
the Windows registry, then the usual install roots. You should not need to
configure anything. When you do:
%econ config r.home "C:/Program Files/R/R-4.5.2"
%econ config stata.home "C:/Program Files/Stata19"
%econ config stata.edition mp
%econ config eviews.progid EViews14.Manager
Or persistently, in ~/.econenv/config.toml:
[r]
home = "C:/Program Files/R/R-4.5.2"
[stata]
home = "C:/Program Files/StataNow19"
edition = "mp"
[eviews]
progid = "EViews14.Manager"
Environment variables work too: ECONENV_STATA_EDITION=mp, R_HOME,
STATA_HOME.
A note on R and Windows. rpy2 publishes no Windows wheels, so EconEnv's
default R backend is a persistent Rterm child process driven over a private
protocol — no compiler, no R_HOME gymnastics. Where rpy2 is installed
(usually Linux and macOS) EconEnv uses it, and loads rpy2's own %R/%%R
magics rather than shadowing them.
Examples
Move data without touching a file
econenv.push("stata", "default", df) # Python → Stata
econenv.move("stata", "r", "default") # Stata → R
back = econenv.pull("r", "econenv_ols_data")
Keep the metadata
%%R -i panel -o results
library(plm)
fit <- plm(y ~ x, data = panel, index = c("id", "year"), model = "within")
results <- as.data.frame(summary(fit)$coefficients)
panel's MultiIndex is recognised as (entity, time); results comes back with
its R types intact.
See what a transfer cost
econenv.push("eviews", "wf", df)
UserWarning: EconEnv push -> eviews: [warning] region: categorical stored as
integer codes; EViews has no factor type
Diagnose
econenv doctor
✔ PASS Python: 3.11.0
✔ PASS R installation: C:\Program Files\R\R-4.5.2 (R 4.5.2)
! WARNING Multiple R versions: 4.5.2, 4.4.3
→ EconEnv picks the newest. Pin one with `%econ config r.home ...`.
✔ PASS PyStata: C:\Program Files\StataNow19\utilities\pystata
! WARNING COM version binding: several EViews versions are installed
→ Pin one: `%econ config eviews.progid EViews14.Manager`.
More in examples/:
- Quick start
- Python + R
- Python + Stata
- Python + EViews
- All four engines
- The same OLS in four engines
- Data transfer and type fidelity
- Time series
- Panel data
Project status
v0.1 — alpha. Execution, engine management, the data bridge, results, graphs, diagnostics, snapshots and cross-engine OLS comparison are implemented and tested. The API may still change before v1.0.
What is verified, and on what:
| Verified | |
|---|---|
| Python engine | yes, in CI |
| R engine (subprocess) | yes, against R 4.5.2 on Windows |
| Stata engine | yes, against StataNow 19.5 MP + PyStata 0.1.2 |
| EViews engine | yes, against EViews 13 via COM on Windows |
| R engine (rpy2) | not verified — no rpy2 on the development machine |
| Linux / macOS | not verified — the design supports them; nobody has run them yet |
Where something is untested, this README and the docs say so. See
docs/audit/PHASE0_TECHNOLOGY_AUDIT.md
for the measured evidence behind every technical decision.
Roadmap
| Version | Scope |
|---|---|
| v0.1 | Execution + engine management + data bridge + results + graphs + diagnostics ✅ |
| v0.2 | Broader type coverage, Stata value labels, EViews alpha/matrix transfer, Arrow everywhere |
| v0.3 | Model registry beyond OLS: logit, probit, IV, panel FE/RE |
| v0.4 | Time-series and cointegration estimators; richer comparison reports |
| v0.5 | Full provenance capture and run manifests |
| v1.0 | Stable public API, documented multi-engine workflow, JupyterLab cell-toolbar extension |
Graphs were pulled forward from v0.3 into v0.1: plot capture is a property of the transport layer, and retrofitting it later would have meant touching every adapter twice.
Platform support
| Python | R | Stata | EViews | |
|---|---|---|---|---|
| Windows | ✅ | ✅ | ✅ | ✅ |
| Linux | ✅ | ✅ | ✅ | ✖ COM is unavailable |
| macOS | ✅ | ✅ | ✅ | ✖ COM is unavailable |
The absence of EViews never blocks installation or use of the others. On non-Windows platforms the EViews engine reports itself unavailable and everything else works normally.
Commercial software disclaimer
EconEnv contains, bundles and redistributes no part of Stata or EViews — no binaries, no libraries, no licence files, no serial numbers, no activation keys.
EconEnv locates software already installed on your machine and drives it through each vendor's own documented automation interface. You are responsible for obtaining, installing and licensing Stata and EViews, and for complying with those licences, including any restriction on concurrent sessions, server deployment or automated use.
Stata® is a registered trademark of StataCorp LLC. EViews® is a registered trademark of IHS Global Inc. R is free software from the R Foundation. None of them endorses or is affiliated with this project.
Troubleshooting
Start with econenv doctor — it names the problem and the fix. Common ones are
in docs/troubleshooting.md, including:
- Stata says the edition is wrong
- EViews connects to the wrong version
- R starts but never becomes ready
pyeviewsfails to import (it is not needed)- Values arrive in EViews as all-NA
Contributing
Issues and pull requests are welcome. See
docs/development.md for the layout, the test markers
(-m "not stata and not eviews" runs everything that needs no licence) and how
to write a new engine adapter.
Citation
If EconEnv is part of your research workflow, please cite it — see
CITATION.cff.
License
MIT — see LICENSE. The MIT grant covers EconEnv's own source only and confers no rights in Stata, EViews or R.
Author
Dr Merwan Roudane · github.com/merwanroudane
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file econenv-0.1.0.tar.gz.
File metadata
- Download URL: econenv-0.1.0.tar.gz
- Upload date:
- Size: 135.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9f7beb79ea49cad631b0a6d55a58ff978d7290691702520036e723b69a28d98
|
|
| MD5 |
7f72ca523c4829ed968900269e8d3f28
|
|
| BLAKE2b-256 |
885ee961205d7c4ce74736069f0467d39d1bf24517ef6452148188c674bc4884
|
File details
Details for the file econenv-0.1.0-py3-none-any.whl.
File metadata
- Download URL: econenv-0.1.0-py3-none-any.whl
- Upload date:
- Size: 109.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5691b4a6af7649d7e5c6a0717fe60f71c49331e34603be478b097326f7d38a05
|
|
| MD5 |
c73cf41e7ece17a5b7f061ac161f8766
|
|
| BLAKE2b-256 |
32be96a7f71a9d0823f6a95a4a47a17721a39003d6834b60e1ef5de9338f0e42
|