The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

multipathaic

Multi-path AIC selection for linear and logistic regression with stability-based model filtering.

Installation

Install the package directly from GitHub:

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

# Install multipathaic
remotes::install_github("mobuobi/multipathaic")

Interactive Shiny App

Explore the multi-path AIC selection procedure with our comprehensive interactive dashboard!

Launch the App

# 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()

App Features

Data Management

Algorithm Controls

Visualizations

Results Tab: - Variable stability scores with threshold line - Models retained by step (line plot with area fill) - Top 10 most stable variables with color-coded bars - Summary value boxes (steps, models, AIC, runtime)

Plausible Models Tab: - Interactive table of selected models with AIC and stability - Jaccard overlap heatmap between models - Variable inclusion probability across plausible models

Branching Tree Tab: - Interactive scatter plot of all explored models - Step-by-step visualization of path exploration - Point size indicates number of variables - Color-coded by selection step

Diagnostics Tab:

For Binomial (Logistic) Models: - Confusion matrix with color gradient (TP, TN, FP, FN) - Performance metric cards (Accuracy, Sensitivity, Specificity, Precision) - ROC curve with AUC calculation - Predicted probability distribution by class

For Gaussian (Linear) Models: - Residual plot with LOESS smoothing - Predicted vs Actual scatter with R² and RMSE - Model performance summary cards

Export & Reporting

App Screenshots

The app features a modern dashboard layout with: - Blue-themed professional interface - Responsive design with collapsible sections - Interactive plots powered by Plotly - Sortable, filterable data tables - Value boxes for key metrics - Real-time progress indicators

Educational Use

Perfect for: - Teaching variable selection methods - Demonstrating bootstrap stability - Comparing model selection strategies - Understanding AIC-based selection - Exploring multi-path algorithms

Example Workflow in App

  1. Upload Data: Navigate to Data tab, upload your CSV/Excel file
  2. Preview: Review data summary and select variables
  3. Set Parameters: Go to Parameters tab, adjust K, δ, Δ, τ, B
  4. Run Analysis: Click “Run Multi-Path AIC Analysis”
  5. View Results: Explore stability plots and value boxes
  6. Check Models: Review plausible models and overlap
  7. Explore Paths: Visualize branching in Branching Tree tab
  8. Diagnostics: Examine performance metrics and plots
  9. Download: Export HTML report of findings

Quick Start

Linear Regression Example (Gaussian)

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

Logistic Regression Example (Binomial)

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)

Parameters

Core Parameters

Stability Parameters

Plausibility Parameters

Interpretation and validation

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.

Real Data Example

The package includes a detailed vignette using the diabetes progression dataset:

# View the vignette
vignette("diabetes-analysis", package = "multipathaic")

Key Functions

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

Workflow Diagram

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

System Requirements

Required R Packages

# 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")

Citation

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

References

Author

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Issues and Support


Package Status: Active Development

Acknowledgments

I thank the Auburn University Department of Mathematics and Statistics for support and guidance throughout this project.

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.