Skip to content
tomwenseleersPublic

About

Fast and scalable fitting of L0-norm and group-L0 penalized generalized linear models (GLMs) to approximate best subset and best subset of groups selection in low- and high-dimensional settings.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

L0glm hex logo with selected coefficient rows across response channels

L0glm: Scalable L₀ and Grouped L₀-Penalized Variable Selection for Generalized Linear Models

Documentation and tutorials · Function reference

L0glm fits L0-penalized and grouped L0-penalized models for best subset and best subset of groups selection. It combines adaptive ridge with IRLS, fast linear solvers and objective-based local support refinement to obtain sparse, low-bias estimates. Strong signals receive progressively less shrinkage as the fit concentrates on the active predictors, giving accurate coefficients with few false positives. It is highly efficient, with fitting often being one or two orders of magnitude faster than glmnet - the most widely used sparse regression framework - and it is shown to return solutions with far fewer false positives, with similar or better predictive power and sensitivity than other competing sparse regression methods, like LASSO, adaptive LASSO, relaxed LASSO, MCP or SCAD. For most problems, performance in terms of speed and quality of the solution obtained is also superior to that of other packages aimed at best subset selection, such as abess and L0Learn.

The Algorithm & theory guide explains the mathematics, regularization presets and full fitting algorithms.

  • Families: standard GLMs (gaussian, poisson, binomial, gamma, inverse gaussian, quasibinomial, quasipoisson) and their links, negative binomial with estimated shape, joint multinomial logistic regression, and right-censored Cox proportional hazards.
  • Data: dense or sparse, tall or wide designs; single or multiple responses; predictor-group and shared-row selection; SIS/ISIS screening for ultrahigh dimensions.
  • Large files: file-backed screening and fitting for bigmemory, HDF5 single-cell assays and packed PLINK genotypes, with training-only imputation and original-dimension sparse coefficients.
  • Controls: observation weights, offsets, unpenalized terms, starting values, normalization, original-scale coefficients and optional nonnegativity constraints.
  • Selection: a fast GIC preset, information-criterion path selection, or cross-validation with minimum-deviance and one-standard-error models; staged interaction selection using interactions=1L for pairwise terms or 2L for three-way terms.
  • Inference: optional selected-support standard errors and bootstrap selection stability through summary(fit, inference="posterior"), "conditional" or "bootstrap"; simulate(fit, nsim=1000) returns conditional posterior coefficient draws.
  • Comparison: sparseGLM() benchmarks L0glm, ABESS, L0Learn, LASSO, relaxed and adaptive LASSO, MCP and SCAD where their backends support the requested model. method="biglasso" adds native file-backed LASSO with IC or CV selection.

L0glm is the statistical fitting and variable-selection layer of a three-package toolkit. logconNMF provides sparse log-concave matrix factorization, PSF estimation and blind deconvolution; GCMSprime provides the GC/MS workflow, chromatogram reports and spectral libraries. Generic simulated deconvolution remains available in L0glm.

Installation

install.packages("remotes")
remotes::install_github("tomwenseleers/L0glm", subdir="L0glm")

The source package is in L0glm/. Windows source installation requires Rtools. The special-family examples use mgcv; Cox also uses survival.

One million predictor example

This Gaussian simulation has one million predictors, 1,000 observations and 60 nonzero effects. One default L0glm call takes 3.61 seconds and recovers 46 true effects with no false positives.

library(L0glm)
set.seed(123)
n <- 1000L
p <- 1000000L
X <- matrix(rnorm(n*p), n, p)
active <- sample.int(p, 60L)
beta <- numeric(p)
beta[active] <- runif(60L, -.8, .8)
set.seed(1)
y <- as.numeric(X[, active] %*% beta[active]) + rnorm(n)

system.time(fit <- l0glmFit(X, y, family=gaussian()))
l0glmMetrics(fit, beta_true=beta)[
  c("gic", "TP", "FP", "FN", "TN", "F1_score", "MCC")]
Method Selection Seconds GIC TP FP F1 MCC
L0glm + ISIS GIC preset 3.61 4195 46 0 0.868 0.876
LASSO 5-fold CV 205.98 14106 42 373 0.177 0.266
Relaxed LASSO 5-fold CV 188.73 4475 31 1 0.674 0.707

L0glm is 57× faster than five-fold-CV LASSO in this comparison, recovering 46 true effects with no false positives.

L0glm uses its GIC preset with automatic ISIS screening and local support refinement. Both LASSO methods use five-fold CV on paths of up to 40 lambda values. The recovered coefficients are close to their true values.

Recovered versus true effects in the million-predictor example.

See the full comparison, including BIC-tuned LASSO and the SIS/ISIS tutorial. The dense design occupies about 8 GB. ISIS is enabled automatically when p_eligible > 10*n and uses all physical cores by default.

The file-backed tutorial also constructs and analyses an 80 GB design with 10,000 observations and one million predictors, plus a packed logistic GWAS example with an interaction. On the 80 GB Gaussian design, the default ISIS fit takes 249 seconds, recovering 50 of 60 effects with one false positive, compared with 792 seconds for BIC-tuned biglasso LASSO. Held-out RMSE is 0.993 versus 1.074, respectively.

Abess benchmark problems

With 20,000 predictors, L0glm matches ABESS's Gaussian GIC and support recovery in 0.37 s versus 1.80 s. Its logistic fit takes 0.54 s, recovering 14.7 of 20 true effects with no false positives on average across three replications.

The full comparison also includes L0Learn, MCP, SCAD and adaptive LASSO variants on these harder Gaussian and logistic problems.

Single channel sparse deconvolution

A blurred Poisson spike train has 10,000 observations, 10,000 candidate peak positions and 1,000 true peaks.

L0glm achieves F1 0.845 in 0.17 s with its GIC preset, compared with F1 0.534 in 6.70 s for fully relaxed LASSO tuned by five-fold CV.

See the single-sample comparison and deconvolution tutorial for fitted signals, coefficient plots and code.

Application: sparse multichannel deconvolution to separate overlapping GC/MS peaks

In GC/MS analysis, overlapping chromatographic peaks have distinct mass spectra. Regressing the observed signals on shifted copies of a peak-shape function lets L0glm select peak times jointly across mass channels and recover their spectra. This Poisson simulation has 10,000 scans, 10,000 candidate peak positions, 1,000 true peaks and all 226 informative mass channels.

multi <- simul(method=4L, n=10000L, p=10000L,
  n_nonzero=1000L, seed=2L)
fit_multi <- l0glmFit(multi$X, multi$y, family=poisson("identity"),
  lambda="gic", nonnegative=TRUE, ncores=4L)

L0glm recovers 944 of 1,000 true peaks with 11 false positives in 11.34 seconds. In this benchmark it is 21.6× faster than GIC-tuned group LASSO and 282× faster than relaxed group LASSO tuned by five-fold CV.

Method Selection Seconds GIC TP FP F1 MCC
L0glm GIC preset 11.34 5606331 944 11 0.966 0.962
Relaxed group LASSO GIC path 906.34 6138687 909 309 0.820 0.802
Relaxed group LASSO 5-fold CV 3199.62 6198648 962 502 0.781 0.769

The coefficient comparison shows how closely L0glm recovers individual mass-spectral intensities.

True versus estimated coefficients across all channels for L0glm and relaxed group LASSO.

Among correctly located peaks, the recovered mass spectra have a within-row F1 of 0.912 and MCC of 0.869.

L0glm fits the Poisson model directly with four cores. The group-LASSO methods use a weighted Gaussian approximation and select from ten lambda values; deconvolution CV uses four parallel workers. See the full multichannel comparison and heatmaps and fitted signals.

For compound-specific peak shapes, logconNMF fits log-concave profiles and spectra with a smooth background; GCMSprime provides the complete chromatogram-to-spectra workflow.

Model selection and special families

An automatic preset such as lambda="gic" typically provides a near-optimal sparse solution straight away. Tuning over a lambda grid or cross-validation remains available to refine regularization or optimize out-of-sample prediction.

The default local.search="auto" refines completed models with at most 50 coefficient dimensions through predictor additions, removals and small exchanges, after any SIS/ISIS screening. TRUE enables refinement for larger models and FALSE returns the adaptive-ridge fit directly. See the controls and diagnostics and benchmark examples. The option is available in l0glmFit(), l0nnPois() and l0glmTune(), including CV training fits.

gic <- l0glmTune(multi$X, multi$y, family=poisson("identity"),
  tune="gic", nlambda=10L, nonnegative=TRUE, grouped=TRUE)
cv <- l0glmTune(multi$X, multi$y, family=poisson("identity"),
  tune="cv", nfolds=5L, nlambda=10L,
  nonnegative=TRUE, grouped=TRUE)
coef(cv$fit_1se)
predict(cv$fit_best, newdata=multi$X, type="response")

CV returns lambda_best, lambda_1se, fit_best and fit_1se, with both models refitted on all observations. Plots show coefficient paths and mean validation deviance ± one standard error.

The same interface supports negative binomial, joint multinomial and Cox models. These small sparse simulations show a preset, GIC tuning and five-fold CV for each family:

fit_and_tune <- function(data) {
  args <- list(X=data$X, y=data$y, family=data$family,
    intercept=data$intercept, maxit=100L)
  list(preset=do.call(l0glmFit, c(args, list(lambda="gic"))),
    gic=do.call(l0glmTune, c(args, list(tune="gic", nlambda=10L))),
    cv=do.call(l0glmTune, c(args, list(tune="cv", nfolds=5L, nlambda=10L))))
}

nb <- fit_and_tune(simul("normal", n=300L, p=20L, n_nonzero=3L,
  family=mgcv::nb(), intercept=1, options=list(theta=2), seed=31L))
multinomial <- fit_and_tune(simul("normal", n=300L, p=20L, n_nonzero=3L,
  family=mgcv::multinom(K=2), intercept=c(.3, 0, -.3), seed=32L))
cox <- fit_and_tune(simul("normal", n=300L, p=20L, n_nonzero=3L,
  family=mgcv::cox.ph(), seed=33L))
fitted(multinomial$cv$fit_1se)  # category probabilities

Negative binomial models accept counts, multinomial models accept factors or category-count matrices, and Cox models accept survival::Surv(time, status). Multinomial coefficients use zero-sum CLR contrasts; Cox predictions give relative risks.

Choose a starting point

I would like to… Start here
Fit a model and make predictions Get started
Choose a penalty by GIC or cross-validation Model selection
Use weights, constraints or held-out early stopping Fitting controls
Fit counts, classes or survival outcomes Negative binomial · Multinomial · Cox
Search a very large predictor set SIS / ISIS
Understand the mathematics Algorithm & theory
Compare speed and support recovery Benchmarks

Foundations

The method builds on adaptive ridge and broken adaptive ridge, with an IRLS implementation for generalized linear models. The algorithm article develops the quadratic updates and their connection to sparse penalties, drawing on Frommlet & Nuel (2016), Li et al. (2021) and Abergel, Bouaziz & Nuel (2024). It also explains screening, grouped selection and likelihood-based scoring. The adaptive updates also have a hierarchical Bayesian and automatic relevance determination (ARD) interpretation: each ridge step estimates a Gaussian-prior MAP, then the prior scales adapt to the fitted effects. Zero-centered skeptical priors tighten around small effects and relax around strong ones.

Reproduce and extend

The performance page gives the complete comparisons, simulation settings and timing conventions. These benchmarks use an HP ZBook Fury G8, Intel Core i9-11950H at 2.60 GHz, 8 physical / 16 logical cores, Windows, R 4.5.0 and OpenBLAS.

Run Rscript benchmarks/render_readme.R to regenerate these highlights from the shared benchmark measurements and figures.

Citation

An article describing the methods implemented in L0glm is in preparation. If you use the package before the article is formally published, we would appreciate a citation to the package:

Wenseleers T, Lanzas L, Vanderaa C (2026). L0glm: Scalable L₀ and Grouped L₀-Penalized Variable Selection for Generalized Linear Models. R package version 0.2.0.9000, https://tomwenseleers.github.io/L0glm/.

The Authors and Citation page also provides the citation in BibTeX format.

Acknowledgements

OpenAI Codex, using GPT-6 Astra and GPT-6.1 Sol, was used to optimize and refactor code and help draft the documentation. The key ideas and methodological decisions are the authors' own, and the authors take full responsibility for the work presented here.

About

Fast and scalable fitting of L0-norm and group-L0 penalized generalized linear models (GLMs) to approximate best subset and best subset of groups selection in low- and high-dimensional settings.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages