Skip to main content

EconEnv

One Notebook. Multiple Econometric Engines.

Python, R, Stata and EViews in a single Jupyter workflow — on one Python kernel.

Website PyPI Python License: MIT Status: stable Open In Colab

Website · Install from PyPI · User Guide (PDF) · Examples · Changelog


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

Never typed an EViews command before? You do not have to leave the notebook to find one:

%econ eviews find cointegration

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:

  1. No custom kernel. EconEnv is a Python package plus an IPython extension. A polyglot kernel is evaluated in the roadmap, not assumed.
  2. 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.
  3. 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

Released on PyPI: https://pypi.org/project/econenv/

pip install econenv

On an older release? Upgrade — EViews cell output and graph capture were broken in 0.1.0, and EViews version reporting in 0.1.0 and 0.1.1.

pip install --upgrade 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, statsmodels 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

Google Colab

Open In Colab

One line to install, no local setup.

Engine On Colab
Python works it is the kernel
R works R is on the Colab image
Stata possible Stata for Linux + a Linux licence, installed from Drive each session
EViews no no Linux build; Wine fails licence activation; and EViews forbids remote access — "web server access to EViews via COM is not allowed"

Want all four engines with the Colab interface? Use Colab's local runtime: the notebook UI stays Colab, but the kernel runs on your own PC, so EViews and Stata work exactly as they do locally. Nothing is exposed to the internet — your browser talks to localhost. It needs the classic Jupyter stack (notebook==6.4.12), because the bridge package does not load on notebook 7.

%econ doctor detects Colab and says which of these applies to you. Full details, including both recipes.


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 EViews.Manager.14

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 = "EViews.Manager.14"

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 EViews.Manager.14`.

More in examples/:

  1. Quick start
  2. Python + R
  3. Python + Stata
  4. Python + EViews
  5. All four engines
  6. The same OLS in four engines
  7. Data transfer and type fidelity
  8. Time series
  9. Panel data

Project status

v1.0 — stable, released on PyPI. Execution, engine management, the data bridge, results, graphs, diagnostics, snapshots and cross-engine OLS comparison are implemented and tested. The public API — the magics, push/pull/move, the result objects and compare_ols — is stable and follows semantic versioning: no breaking change without a major bump.

Releases

Version What changed
1.0.7 PyPI · notes First stable release; API declared stable
0.1.7 PyPI · notes Google Colab support; all four engines via a local runtime
0.1.6 PyPI · notes EViews command reference searchable from a cell; forecast plots; worked example on real data; user guide
0.1.5 PyPI · notes Full EViews graph/output audit; text and spool views captured; no silent failures
0.1.4 folded into 0.1.5 · notes EViews graph commands (line x) now render
0.1.3 PyPI · notes EViews plotting views (x.line) now render; no duplicate or repeated figures
0.1.2 PyPI · notes Correct EViews ProgID discovery; stop guessing the EViews version before connecting
0.1.1 PyPI · notes EViews cell output and graph capture; honest engine reporting
0.1.0 PyPI · notes First release

Install the latest with pip install --upgrade econenv.

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
  • pyeviews fails 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

econenv-1.0.7.tar.gz (933.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

econenv-1.0.7-py3-none-any.whl (129.2 kB view details)

Uploaded Python 3

File details

Details for the file econenv-1.0.7.tar.gz.

File metadata

  • Download URL: econenv-1.0.7.tar.gz
  • Upload date:
  • Size: 933.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.0

File hashes

Hashes for econenv-1.0.7.tar.gz
Algorithm Hash digest
SHA256 4e6782e7ef8f2d790570b1d540da6fdc5b4b9dd5169fe889bf5c9f67a3786ea0
MD5 03125dd6761a6db994facea1eccc43a3
BLAKE2b-256 b0c7ec07449e30619067ff11cba16a862cc96a094cb82ace56e689c482408088

See more details on using hashes here.

File details

Details for the file econenv-1.0.7-py3-none-any.whl.

File metadata

  • Download URL: econenv-1.0.7-py3-none-any.whl
  • Upload date:
  • Size: 129.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.0

File hashes

Hashes for econenv-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 5cb73c216a4b6e489d6af185cc2414eaed63edf7d20dfde66871b3e8783247bf
MD5 062ae9fc2eec5f1223d2fd76da410e84
BLAKE2b-256 9abccb251f34969d6b4f52975d487d0675f9eff44da154b0a0c6eccaa47a8f1f

See more details on using hashes here.

Release history Release notifications | RSS feed

1.1.1

2 files

1.0.9

2 files

1.0.8

2 files

This release

1.0.7 This release

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page