-
Notifications
You must be signed in to change notification settings - Fork 8
Installation
This page provides detailed instructions for installing the Greybox package in both R and Python.
The easiest way to install Greybox in R is from CRAN:
install.packages("greybox")To load the package:
library(greybox)To install the latest development version from GitHub:
# Install from GitHub
remotes::install_github("openforecast-org/greybox")- R version 3.5.0 or higher
- The following R packages are automatically installed as dependencies:
statsgenericsgraphicsutilspracmanloptrstatmodzootexregxtablemethods-
Rcpp(LinkingTo)
To verify that Greybox is installed correctly in R:
# Check package version
packageVersion("greybox")
# Load the package
library(greybox)
# Get help
?greyboxlibrary(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)If installation from CRAN fails, try:
- Update R to the latest version
- Install dependencies manually:
install.packages(c("generics", "pracma", "nloptr", "statmod", "zoo", "texreg", "xtable"))- Try installing from GitHub:
remotes::install_github("openforecast-org/greybox")The easiest way to install Greybox in Python is from PyPI:
pip install greyboxTo install the latest development version from GitHub:
pip install greybox @ git+https://github.com/openforecast-org/greybox.git#subdirectory=pythonOr clone and install in editable mode:
git clone https://github.com/openforecast-org/greybox.git
cd greybox/python
pip install -e .| Package | Minimum Version |
|---|---|
| Python | 3.9+ |
| numpy | 1.20.0 |
| scipy | 1.7.0 |
| pandas | 1.3.0 |
| nlopt | 2.7.0 |
Install optional dependencies:
pip install greybox[dev]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, CALM
from greybox.formula import formula
# Check help
help(greybox)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)If you encounter issues installing nlopt, you may need to install the nlopt development libraries:
Ubuntu/Debian:
sudo apt-get install libnlopt-devmacOS:
brew install nloptWindows: nlopt should install automatically via pip. If issues persist, try:
pip install --no-cache-dir nloptIf you encounter import errors, make sure all dependencies are installed:
pip install numpy scipy pandas nlopt- Home - Main documentation page
- ALM - Advanced Linear Model documentation
- stepwise - Stepwise regression
- distributions - Supported distributions