Menu

Tree [c1ba33] master /
 History

HTTPS access


File Date Author Commit
 demo 21 hours ago marcingretl marcingretl [17be9f] fractint test added
 doc 2025-12-12 marcingretl marcingretl [d74d8f] some doc tweaks
 gretl 3 days ago marcingretl marcingretl [cc8800] interface to libgretl's set command refactored
 src 21 hours ago marcingretl marcingretl [17be9f] fractint test added
 .gitignore 2025-05-16 marcingretl marcingretl [d40554] version which builds whl (wheel) package for ms...
 LICENSE 2025-06-07 marcingretl marcingretl [104090] add licence
 MANIFEST.in 2025-10-21 marcingretl marcingretl [cef94a] versioning tweak
 README.md 2025-12-10 marcingretl marcingretl [419890] new README.md
 changelog.txt 21 hours ago marcingretl marcingretl [17be9f] fractint test added
 gretl4py_version.h.in 2025-10-20 marcingretl marcingretl [ef3334] fix names clash on windows (VERSION related)
 install.py 16 hours ago Allin Cottrell Allin Cottrell [c1ba33] try recreating install fix
 meson.build 2025-12-12 marcingretl marcingretl [89a58b] restore lines for generating gretl4py_version.h
 meson_options.txt 2025-05-17 marcingretl marcingretl [5523df] teaks to meson.build to install in local dirs b...
 pyproject.toml 2025-10-27 marcingretl marcingretl [cfa681] classifiers updated
 read.me 2025-07-29 Allin Cottrell Allin Cottrell [6d19ce] call gretl_set_python_mode() to get data file s...
 setup.py 2025-10-27 marcingretl marcingretl [cfa681] classifiers updated
 todo.txt 2025-12-10 marcingretl marcingretl [419890] new README.md
 version.cfg 2025-12-12 marcingretl marcingretl [3113f5] add version format validator
 webinstall.py 2025-10-21 marcingretl marcingretl [d0c219] fix version in webinstall.py

Read Me

gretl4py: Python Bindings for gretl

            _   _   ___
           | | | | /   |

__ _ _ __ | || |/ /| | __ _ _
/
` | '
/ _ \ | / /| | ' | | | |
| (
| | | | / |_| _ | |) | || |
_, || _|_|| |_/ ./ __, |
/ | | | / |
|
/ |_| |___/

gretl4py provides Python bindings to gretl, a free, open-source, cross-platform software package for econometric analysis.
Gretl is known for its numerical accuracy and computational efficiency — capabilities that gretl4py inherits directly through the underlying libgretl engine.

gretl4py is not a standalone econometrics library. Instead, it serves as a bridge between Python and libgretl, exposing a high-performance backend that supports:

  1. Econometric estimation: least squares, maximum likelihood, GMM; single-equation and system estimators; regularized regression (LASSO, Ridge, Elastic Net)
  2. Time-series methods: ARIMA, numerous univariate GARCH-type models, VARs and VECMs (including structural VARs), unit-root/cointegration tests, Kalman filter, etc.
  3. Limited dependent variables: logit, probit, tobit, sample selection, interval regression, count and duration models, etc.
  4. Panel-data estimators: including IV, probit, and GMM-based dynamic panel methods
  5. Mixed-frequency (MIDAS) models
  6. Machine learning support via LIBSVM
  7. The hansl scripting language, enabling users to write gretl function packages — collections of hansl-written functions for advanced econometric analysis
    https://gretl.sourceforge.net/function_packages.html

Please note that some features available in gretl (e.g., Kalman filtering) are not yet implemented in gretl4py, but are planned.
For full documentation, visit the gretl4py project page:
https://gretl.sourceforge.net/gretl4py.html

Note
The official PDF documentation is under development and still requires updates.
Example scripts are available in the demo/ directory:
https://sourceforge.net/p/gretl/gretl4py/ci/v0.2/tree/demo/


Package Contents

  1. libgretl (including plugins) and its dependencies
  2. The gretl4py binary module providing the Python–C interface
  3. Additional Python helper modules
  4. Example scripts in examples/
  5. Sample datasets in data/

Provided Functionality

Available Estimators

:: ar, ar1, arima, biprobit, dpanel, duration, garch, heckit, hsk,
intreg, lad, logit, logistic, midasreg, mpols, negbin, ols, panel,
poisson, probit, quantreg, tobit, tsls, wls, var, vecm

Available Tests

:: add, adf, arch, autocorr, bds, bkw, breusch-pagan, chow, coeffsum, coint, comfac,
cusum, difftest, johansen, kpss, leverage, levinlin, logs, meantest, normality,
normtest, omit, panel, panspec, qlrtest, reset, restrict, runs, squares,
white, white-nocross, vartest, vif, xdepend

Note
Some tests operate on datasets, while others are model-based.


Usage

1. Loading Datasets

Supported formats:
.gdt, .gdtb, .csv, .dta, .wf1, .xls, .xlsx, .ods

Use get_data() to load a dataset:

import importlib.resources as resources
import gretl

data_dir = resources.files('gretl').joinpath('data')
d1 = gretl.get_data(str(data_dir.joinpath('bjg.gdt')))

Bundled Datasets:

:: abdata.gdt, bjg.gdt, data9-7.gdt, greene19_1.gdt, grunfeld.gdt, mroz87.gdt,
rac3d.gdt, b-g.gdt, data4-10.gdt, denmark.gdt, greene22_2.gdt, kennan.gdt,
ooballot.gdt, tobit.gdt, bjg.csv, data4-1.gdt, gdp_midas.gdt, greene25_1.gdt,
longley.csv, penngrow.gdt, wtp.gdt

  1. Estimating Models

Basic usage pattern:

m = gretl.ESTIMATOR()
m.fit()

where ESTIMATOR() is any supported estimator.
To use a specific dataset, supply it via data=... keyword argument.

Examples

Example scripts are located in examples/estimators/ and include:

:: ar1.py, biprobit.py, heckit.py, logit.py, ols.py, probit.py, wls.py,
arima.py, duration.py, lad.py, mpols.py, panel.py, tobit.py, ar.py,
garch.py, logistic.py, negbin.py, poisson.py, quantreg.py, tsls.py

Example: OLS Regression

To view the source of ols.py

import inspect
import gretl.examples.estimators.ols

print(inspect.getsource(gretl.examples.estimators.ols.run_example))

To run the example:

import gretl.examples.estimators.ols
gretl.examples.estimators.ols.run_example()