-
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("config-i1/greybox")- R version 3.5.0 or higher
- The following R packages are automatically installed as dependencies:
statsgraphicszooscalesnloptr
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)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")If installation from CRAN fails, try:
- Update R to the latest version
- Install dependencies manually:
install.packages(c("zoo", "scales", "nloptr"))- Try installing from GitHub:
remotes::install_github("config-i1/greybox")The easiest way to install Greybox in Python is from PyPI:
pip install greyboxTo install the latest development version from GitHub:
Install directly from GitHub
# Install directly from the python subdirectory
pip install git+https://github.com/config-i1/greybox.git#subdirectory=python| 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]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)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