Implements a multi-path forward selection algorithm using the Akaike
Information Criterion (AIC) for both linear (Gaussian) and logistic (binomial)
regression models. Unlike traditional stepwise methods that follow a single path,
this approach explores multiple competitive model paths simultaneously by retaining
near-optimal models at each step. The package includes stability estimation via
bootstrap resampling and identifies plausible models based on AIC tolerance and
variable stability thresholds. The information criterion is described by
Akaike (1974)
Multi-path AIC selection for linear and logistic regression with stability-based model filtering.
Install the package directly from GitHub:
# Install remotes if not already installed
install.packages("remotes")
# Install multipathaic
remotes::install_github("mobuobi/multipathaic")
Explore the multi-path AIC selection procedure with our comprehensive interactive dashboard!
# Install required packages first (if not already installed)
install.packages(c("shiny", "shinydashboard", "plotly", "DT", "ggplot2", "readxl"))
# Load package and launch
library(multipathaic)
launch_app()
Flexible Data Input:
Data Cleaning & Preview:
Results Tab:
Plausible Models Tab:
Branching Tree Tab:
Diagnostics Tab:
For Binomial (Logistic) Models:
For Gaussian (Linear) Models:
The app features a modern dashboard layout with:
Perfect for:
library(multipathaic)
# Generate synthetic data
set.seed(123)
n <- 150; p <- 10
X <- as.data.frame(matrix(rnorm(n*p), n, p))
names(X) <- paste0("x", 1:p)
beta <- c(2, -1.5, 0, 0, 1, rep(0, p-5))
y <- as.numeric(as.matrix(X) %*% beta + rnorm(n, 1))
# Step 1: Build multi-path forest
forest <- build_paths(
X = X,
y = y,
family = "gaussian",
K = 10,
eps = 1e-6,
delta = 2,
L = 50
)
# Step 2: Compute stability across resamples
stab <- stability(
X = X,
y = y,
family = "gaussian",
B = 50,
K = 10,
eps = 1e-6,
delta = 2,
L = 50
)
# Step 3: Select plausible models
plaus <- plausible_models(
forest = forest,
pi = stab$pi,
Delta = 2,
tau = 0.6
)
# View results
print(plaus$summary)
Or use the all-in-one wrapper:
# Complete pipeline in one function
result <- multipath_aic(
X = X,
y = y,
family = "gaussian",
K = 10,
B = 50,
Delta = 2,
tau = 0.6
)
# Access components
result$forest # Multi-path search results
result$stab # Stability scores
result$plaus # Plausible models
library(multipathaic)
# Generate binary outcome data
set.seed(42)
n <- 200; p <- 8
X <- as.data.frame(matrix(rnorm(n*p), n, p))
names(X) <- paste0("x", 1:p)
# True model: x1, x2, x5 are important
eta <- 1.5*X$x1 - 2*X$x2 + 1*X$x5
prob <- 1 / (1 + exp(-eta))
y <- rbinom(n, 1, prob)
# Step 1: Build multi-path forest
forest <- build_paths(
X = X,
y = y,
family = "binomial",
K = 8,
eps = 1e-6,
delta = 2,
L = 50
)
# Step 2: Compute stability
stab <- stability(
X = X,
y = y,
family = "binomial",
B = 50,
K = 8,
eps = 1e-6,
delta = 2,
L = 50
)
# Step 3: Select plausible models
plaus <- plausible_models(
forest = forest,
pi = stab$pi,
Delta = 2,
tau = 0.6
)
# View plausible models
print(plaus$plausible_models)
Evaluate classification performance:
# Run complete pipeline
result <- multipath_aic(
X = X,
y = y,
family = "binomial",
K = 8,
B = 50,
Delta = 2,
tau = 0.6
)
# Compute confusion matrix and metrics for best model
confusion_metrics(result, model_index = 1, cutoff = 0.5)
K: Maximum number of forward selection steps (default: min(ncol(X), 10))eps: Minimum AIC improvement threshold (default: 1e-6)delta: AIC tolerance for keeping near-best models at each step (default: 2)L: Maximum models retained per step (default: 100)B: Number of bootstrap resamples (default: 100)resample_fraction: Fraction of data per resample (default: 0.8)Delta: AIC tolerance for plausible model set (default: 2)tau: Minimum average stability threshold (default: 0.6)Predictors must be finite numeric columns. Encode categorical predictors explicitly; the dashboard does not impose an arbitrary numeric ordering on categories. The core API rejects missing values so all AIC comparisons use identical observations.
stability() samples floor(resample_fraction * n) rows with replacement.
For each successful draw, it averages variable inclusion over the deepest retained
frontier, then averages those fractions across draws. Failed draws are reported and
excluded from the denominator; successful intercept-only draws contribute zeros.
B in the returned object counts successes; B_requested counts attempts.
tau filters the mean score of a model's variables. It does not require every
variable to exceed the threshold. The intercept-only model is exempt, with NA
average stability. An empty plausible set is also a valid outcome.
This bounded forward search can miss jointly useful predictors and does not guarantee
the global AIC minimum. Stability scores and model inclusion fractions are descriptive,
not posterior probabilities or guaranteed error-rate control. Use sensitivity analysis
for delta, L, B, and tau, and perform selection entirely inside each training
partition when evaluating predictive performance.
confusion_metrics() and the dashboard's diagnostic plots use training data. The
dashboard's separate test-set table evaluates the training-selected model on held-out
rows. Test R² is 1 - SSE/SST and can be negative. Repeatedly tuning to a test set
makes it a validation set; keep a final untouched test set for final assessment.
Set set.seed() before API calls to reproduce bootstrap results. The dashboard has
an analysis seed and saves run settings with the result and downloaded report.
See the review and validation record for changes and limitations.
The package includes a detailed vignette using the diabetes progression dataset:
# View the vignette
vignette("diabetes-analysis", package = "multipathaic")
| Function | Description |
|---|---|
build_paths() |
Multi-path forward selection with AIC branching |
stability() |
Bootstrap-based variable stability estimation |
plausible_models() |
Filter models by AIC + stability |
multipath_aic() |
Complete pipeline (Algorithms 1-3) |
confusion_metrics() |
Classification performance metrics |
launch_app() |
Launch interactive Shiny application |
Data (X, y)
↓
┌─────────────────────────────────────┐
│ Algorithm 1: build_paths() │
│ Multi-path forward selection │
│ - Explores multiple branches │
│ - Keeps near-optimal models │
└─────────────────────────────────────┘
↓
┌─────────────────────────────────────┐
│ Algorithm 2: stability() │
│ Bootstrap resampling │
│ - Computes variable stability │
│ - Identifies reliable predictors │
└─────────────────────────────────────┘
↓
┌─────────────────────────────────────┐
│ Algorithm 3: plausible_models() │
│ AIC + stability filtering │
│ - Combines fit & stability │
│ - Returns final model set │
└─────────────────────────────────────┘
↓
Final Plausible Models
# Core dependencies (automatically installed)
- stats
# Shiny app dependencies (install manually)
install.packages(c("shiny", "shinydashboard", "plotly", "DT", "ggplot2"))
# For Excel file support (optional)
install.packages("readxl")
# For vignette datasets (optional)
install.packages("lars")
If you use this package, please cite:
Obuobi, M. (2025). multipathaic: Multi-Path Stepwise
Selection with AIC. R package version 0.1.1.
https://github.com/mobuobi/multipathaic
MIT License - see LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
?multipathaic or help(package = "multipathaic")Package Status: Active Development
I thank the Auburn University Department of Mathematics and Statistics for support and guidance throughout this project.