Installation
R package
From GitHub (development version)
The recommended way to install the R package is from GitHub using the remotes package:
# Install remotes if you haven't already
install.packages("remotes")
# Install unifres from GitHub
remotes::install_github("bgreenwell/unifres", subdir = "r/unifres")Dependencies
The core package has minimal dependencies. Optional dependencies for advanced plotting include:
hexbin- for hexagonal binning plotslattice- for lattice graphicsMASS- for 2D kernel density estimationmgcv- for GAM model supportVGAM- for ordinal and zero-inflated model supportpscl- for zero-inflated Poisson models
You can install all optional dependencies with:
install.packages(c("hexbin", "lattice", "MASS", "mgcv", "VGAM", "pscl"))Verify installation
After installation, verify that everything works:
library(unifres)
# Generate simple test data
set.seed(123)
x <- rnorm(100)
y <- rbinom(100, 1, plogis(x))
fit <- glm(y ~ x, family = binomial)
# Test basic functionality
fres <- fresiduals(fit)
ffplot(fit)Python package
Using pip
Install directly from GitHub:
pip install git+https://github.com/bgreenwell/unifres.git#subdirectory=pythonUsing uv (recommended)
uv is a fast Python package manager:
uv pip install git+https://github.com/bgreenwell/unifres.git#subdirectory=pythonFrom source
Clone the repository and install in development mode:
git clone https://github.com/bgreenwell/unifres.git
cd unifres/python
pip install -e .Dependencies
The Python package requires:
numpy(>= 1.21.0)scipy(>= 1.7.0)pandas(>= 1.3.0)matplotlib(>= 3.5.0)seaborn(>= 0.11.0)statsmodels(>= 0.13.0)plotnine(>= 0.10.0)
These are automatically installed when you install the package.
Verify installation
After installation, verify that everything works:
import numpy as np
import statsmodels.api as sm
from unifres import fresiduals, ffplot, fredplot
# Generate simple test data
np.random.seed(123)
x = np.random.normal(size=100)
y = np.random.binomial(1, 1/(1 + np.exp(-x)))
X = sm.add_constant(x)
model = sm.GLM(y, X, family=sm.families.Binomial()).fit()
# Test basic functionality
fres = fresiduals(model)
ffplot(model)System requirements
R
- R >= 4.0.0
- Works on Windows, macOS, and Linux
Python
- Python >= 3.9
- Works on Windows, macOS, and Linux
Troubleshooting
R package issues
Problem: Error about missing suggested packages
Solution: Install the missing optional dependencies:
install.packages(c("hexbin", "lattice", "MASS"))Problem: Installation fails on macOS
Solution: Ensure you have Xcode Command Line Tools installed:
xcode-select --installPython package issues
Problem: Compilation errors during installation
Solution: Upgrade pip and try again:
pip install --upgrade pip
pip install git+https://github.com/bgreenwell/unifres.git#subdirectory=pythonProblem: Import errors after installation
Solution: Ensure you’re using a clean Python environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install git+https://github.com/bgreenwell/unifres.git#subdirectory=pythonDevelopment installation
For contributors who want to modify the code:
R development
# Clone and install in dev mode
git clone https://github.com/bgreenwell/unifres.git
cd unifres/r/unifres
# In R:
devtools::install_deps()
devtools::load_all()
devtools::test()Python development
# Clone repository
git clone https://github.com/bgreenwell/unifres.git
cd unifres/python
# Option 1: Using uv (recommended)
uv venv # Create virtual environment
uv pip install -e ".[dev]" # Install in editable mode with dev dependencies
# Option 2: Using pip
pip install -e ".[dev]"
# Run tests
pytest tests/ -vSee the Contributing Guide for more details on development workflow.