Skip to content

Installation

Ivan Svetunkov edited this page Feb 19, 2026 · 8 revisions

Installation

This page provides detailed instructions for installing the Greybox package in both R and Python.

R Installation

From CRAN (Recommended)

The easiest way to install Greybox in R is from CRAN:

install.packages("greybox")

To load the package:

library(greybox)

From GitHub (Development Version)

To install the latest development version from GitHub:

# Install from GitHub
remotes::install_github("config-i1/greybox")

R Requirements

  • R version 3.5.0 or higher
  • The following R packages are automatically installed as dependencies:
    • stats
    • graphics
    • zoo
    • scales
    • nloptr

Python Installation

From PyPI (Recommended)

The easiest way to install Greybox in Python is from PyPI:

pip install greybox

From GitHub (Development Version)

To install the latest development version from GitHub:

# Clone the repository
git clone https://github.com/config-i1/greybox.git

# Navigate to the Python directory
cd greybox/python

# Install in development mode
pip install -e .

Python Requirements

Minimum Requirements

Package Minimum Version
Python 3.8+
numpy 1.20.0
scipy 1.7.0
pandas 1.3.0
nlopt 2.7.0

Install optional dependencies:

pip install greybox[dev]

Verifying Installation

R

To verify that Greybox is installed correctly in R:

# Check package version
packageVersion("greybox")

# Load the package
library(greybox)

# Get help
?greybox

Python

To verify that Greybox is installed correctly in Python:

# Check package version
import greybox
print(greybox.__version__)

# Import main functions
from greybox import ALM, stepwise, lm_combine
from greybox.formula import formula

# Check help
help(greybox)

Quick Start

R

library(greybox)

# Simple example with mtcars data
data <- mtcars

# Fit a model
model <- alm(mpg ~ wt + disp + hp, data, distribution = "dnorm")

# Get summary
summary(model)

# Make predictions
predictions <- predict(model)

Python

from greybox.formula import formula
from greybox.alm import ALM

# Simple example
data = {
    'mpg': [21.0, 21.0, 22.8, 24.4, 19.2],
    'wt': [2.62, 2.32, 2.32, 2.46, 2.32],
    'disp': [160, 160, 108, 147, 141],
    'hp': [110, 110, 93, 62, 123]
}

# Parse formula
y, X = formula("mpg ~ wt + disp + hp", data)

# Fit model
model = ALM(distribution="dnorm")
model.fit(X, y)

# Get summary
print(model.summary())

# Make predictions
result = model.predict(X)

Building from Source

Python

To build Greybox from source:

# Clone the repository
git clone https://github.com/config-i1/greybox.git

# Navigate to the Python directory
cd greybox/python

# Install build tools
pip install build

# Build the package
python -m build

# Install the built package
pip install dist/greybox-*.whl

R

To build from source in R:

# Install devtools if not already installed
install.packages("devtools")

# Build from local source
devtools::build("/path/to/greybox")

# Or install from local source
devtools::install("/path/to/greybox")

Troubleshooting

Python Issues

nlopt installation error

If you encounter issues installing nlopt, you may need to install the nlopt development libraries:

Ubuntu/Debian:

sudo apt-get install libnlopt-dev

macOS:

brew install nlopt

Windows: nlopt should install automatically via pip. If issues persist, try:

pip install --no-cache-dir nlopt

Import errors

If you encounter import errors, make sure all dependencies are installed:

pip install numpy scipy pandas nlopt

R Issues

Package installation fails

If installation from CRAN fails, try:

  1. Update R to the latest version
  2. Install dependencies manually:
install.packages(c("zoo", "scales", "nloptr"))
  1. Try installing from GitHub:
remotes::install_github("config-i1/greybox")

Related Pages

  • Home - Main documentation page
  • ALM - Advanced Linear Model documentation
  • Stepwise - Stepwise regression
  • Distributions - Supported distributions

Clone this wiki locally