Learn R Programming

sparsegl

The goal of sparsegl is to fit regularization paths for sparse group-lasso penalized learning problems. The model is typically fit for a sequence of regularization parameters $\lambda$. Such estimators minimize

$$ -\ell(\beta | y,\ \mathbf{X}) + \lambda(1-\alpha)\sum_{g\in G} \lVert\beta_g\rVert_2 + \lambda\alpha \lVert\beta\rVert_1. $$

The main focus of this package is for the case where the loglikelihood corresponds to Gaussian or logistic regression. But we also provide the ability to fit arbitrary GLMs using stats::family() objects. Details may be found in Liang, Cohen, Sólon Heinsfeld, Pestilli, and McDonald (2024).

Installation

You can install the released version of sparsegl from CRAN with:

install.packages("sparsegl")

You can install the development version from GitHub with:

# install.packages("remotes")
remotes::install_github("dajmcdon/sparsegl")

Minimal Example

set.seed(1010)
n <- 100
p <- 200
X <- matrix(data = rnorm(n * p, mean = 0, sd = 1), nrow = n, ncol = p)
eps <- rnorm(n, mean = 0, sd = 1)
beta_star <- c(
  rep(5, 5), c(5, -5, 2, 0, 0),
  rep(-5, 5), c(2, -3, 8, 0, 0), rep(0, (p - 20))
)
y <- X %*% beta_star + eps
groups <- rep(1:(p / 5), each = 5)
fit1 <- sparsegl(X, y, group = groups)
plot(fit1, y_axis = "coef", x_axis = "penalty", add_legend = FALSE)

References

Liang, X., Cohen, A., Sólon Heinsfeld, A., Pestilli, F., and McDonald, D.J. 2024. “sparsegl: An R Package for Estimating Sparse Group Lasso.” Journal of Statistical Software 110(6), 1–23. https://doi.org/10.18637/jss.v110.i06.

Copy Link

Version

Install

install.packages('sparsegl')

Monthly Downloads

289

Version

1.1.1

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Daniel McDonald

Last Published

August 24th, 2024

Functions in sparsegl (1.1.1)

cv.sparsegl

Cross-validation for a sparsegl object.
coef.cv.sparsegl

Extract coefficients from a cv.sparsegl object.
coef.sparsegl

Extract model coefficients from a sparsegl object.
estimate_risk

Calculate information criteria.
predict.sparsegl

Make predictions from a sparsegl object.
sparsegl-package

sparsegl: Sparse Group Lasso
plot.cv.sparsegl

Plot cross-validation curves produced from a cv.sparsegl object.
%>%

Pipe operator
zero_norm

Calculate common norms
sparsegl

Regularization paths for sparse group-lasso models
make_irls_warmup

Create starting values for iterative reweighted least squares
plot.sparsegl

Plot solution paths from a sparsegl object.
trust_experts

Trust in scientific experts during the Covid-19 pandemic
predict.cv.sparsegl

Make predictions from a cv.sparsegl object.