Skip to content

Installation

Ivan Svetunkov edited this page Oct 22, 2026 · 9 revisions

Installation

R

From CRAN

install.packages("greybox")
library(greybox)

Development version from GitHub

remotes::install_github("openforecast-org/greybox")

Building from source compiles C++ code through Rcpp, so it needs the R build tools (Rtools on Windows, the Xcode command-line tools on macOS).

Requirements

  • R 3.5.0 or higher.
  • Imports, installed automatically: stats, generics (>= 0.1.2), graphics, utils, pracma, nloptr, statmod, zoo, texreg, xtable, methods, Rcpp (also LinkingTo).
  • Suggested: smooth (>= 3.1.0), used by xregExpander() and B() to extrapolate the lags and leads (without it, the gaps take the first and last values); foreach with doMC or doParallel for parallel=TRUE in calm() and ro().

Check

packageVersion("greybox")

model <- alm(mpg ~ wt + disp + hp, mtcars, distribution="dnorm")
summary(model)

Python

From PyPI

pip install greybox

Development version from GitHub

pip install "git+https://github.com/openforecast-org/greybox.git#subdirectory=python"

or, for an editable install:

git clone https://github.com/openforecast-org/greybox.git
cd greybox/python
pip install -e .

Installing from source compiles five C++ extensions with pybind11 (the densities, dgamma, lowess, supsmu and the latent variance of ALM), so it needs a C++17 compiler; pybind11 is fetched automatically as a build requirement. The wheels on PyPI need no compiler.

Requirements

Package Minimum version
Python 3.11
numpy 1.20.0
scipy 1.7.0
pandas 1.3.0
nlopt 2.7.0
matplotlib 3.5

Optional: smooth (Python), used by xreg_expander() and B() to extrapolate the lags and leads, as in R; without it they fill the gaps with the first and last values. The development tools are in the dev extra: pip install "greybox[dev]".

Check

from importlib.metadata import version
from greybox import ALM, formula, mtcars

print(version("greybox"))

y, X = formula("mpg ~ wt + disp + hp", mtcars)
model = ALM(distribution="dnorm").fit(X, y)
print(model.summary())

Troubleshooting

  • A compiler error during pip install means pip is building from source: either no wheel matches the platform and Python version, or the install is from GitHub. Install a C++17 compiler (build-essential on Debian/Ubuntu, the Xcode command-line tools on macOS, the MSVC build tools on Windows), or use a Python version with a published wheel.
  • nlopt fails to install: nlopt ships wheels for the common platforms; pip install --no-cache-dir nlopt retries without a stale cached build.

See also

  • Home — function index and quick start
  • ALM — the core estimator
  • R-Python-differences — how closely the two implementations agree

Clone this wiki locally