| Title: | Gradient Descent LASSO with Stability Selection and Bootstrapped Confidence Intervals |
| Version: | 0.1.1 |
| Description: | Implements LASSO regression using gradient descent with support for Gaussian, Binomial, Negative Binomial, and Zero-Inflated Negative Binomial (ZINB) families. Features cross-validation for determining lambda, stability selection, and bootstrapping for confidence intervals. Methods described in Tibshirani (1996) <doi:10.1111/j.2517-6161.1996.tb02080.x> and Meinshausen and Buhlmann (2010) <doi:10.1111/j.1467-9868.2010.00740.x>. |
| URL: | https://github.com/ddefranza/gradLasso |
| BugReports: | https://github.com/ddefranza/gradLasso/issues |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.3 |
| Imports: | stats, utils, graphics, grDevices, foreach, doParallel, parallel |
| Suggests: | testthat (≥ 3.0.0), knitr, rmarkdown |
| Config/testthat/edition: | 3 |
| VignetteBuilder: | knitr |
| NeedsCompilation: | no |
| Packaged: | 2026-01-07 12:47:51 UTC; ddefranza |
| Author: | David DeFranza [aut, cre] |
| Maintainer: | David DeFranza <david.defranza@ucd.ie> |
| Repository: | CRAN |
| Date/Publication: | 2026-01-08 19:10:10 UTC |
Extract Model Coefficients
Description
Extract Model Coefficients
Usage
## S3 method for class 'gradLasso'
coef(object, ...)
Arguments
object |
A gradLasso fitted object. |
... |
Additional arguments. |
Value
A numeric vector of coefficients.
Cross-Validation for gradLasso
Description
Cross-Validation for gradLasso
Usage
cv.gradLasso(
object,
data = NULL,
family,
lambdas = NULL,
nfolds = 5,
batch_size = NULL,
subsample = NULL,
parallel = FALSE,
verbose = FALSE
)
Arguments
object |
Matrix X (predictors). |
data |
Vector y (response). |
family |
Family object (e.g., grad_gaussian, grad_zinb). |
lambdas |
Vector of lambda values to test. If NULL, a sequence is generated. |
nfolds |
Integer. Number of CV folds (default 5). |
batch_size |
Integer. Mini-batch size for SGD. |
subsample |
Integer. Number of rows to use for CV (if NULL, uses all data). |
parallel |
Logical. If TRUE, runs folds in parallel. |
verbose |
Logical. Print progress to console? |
Value
A list containing CV results (mean error, SD, optimal lambdas).
Internal FISTA Solver
Description
Internal FISTA Solver
Usage
fit_gradlasso(
X,
y,
family,
lambda,
alpha = 1,
max_iter = 2000,
tol = 1e-05,
step_size = 0.001,
batch_size = NULL,
init_beta = NULL
)
Extract Fitted Values
Description
Extract Fitted Values
Usage
## S3 method for class 'gradLasso'
fitted(object, ...)
Arguments
object |
A gradLasso fitted object. |
... |
Additional arguments. |
Value
A numeric vector of fitted values.
Generate Lambda Sequence
Description
Generate Lambda Sequence
Usage
get_lambda_seq(X, y, family, n_lambda = 20, ratio = 0.001)
Gradient Descent LASSO with Stability Selection
Description
Gradient Descent LASSO with Stability Selection
Usage
gradLasso(
formula,
data = NULL,
family = grad_gaussian(),
lambda = NULL,
lambda_cv = TRUE,
standardize = TRUE,
cv_subsample = NULL,
parallel = FALSE,
n_cores = NULL,
boot = TRUE,
n_boot = 50,
boot_ci = c(0.025, 0.975),
batch_size = NULL,
warm_start = TRUE,
verbose = FALSE
)
Arguments
formula |
Formula object. Supports pipes for ZINB (e.g., y ~ x1 + x2 | z1). |
data |
Data frame. |
family |
Family object. |
lambda |
Optional fixed lambda. |
lambda_cv |
Configuration for CV. |
standardize |
Logical. Standardize predictors? |
cv_subsample |
Integer. Speedup for CV. |
parallel |
Logical. Enable parallel processing? |
n_cores |
Integer. Number of cores. |
boot |
Logical. Run stability selection? |
n_boot |
Number of bootstraps. |
boot_ci |
Vector of two probabilities for CIs. |
batch_size |
Integer. Mini-batch SGD. |
warm_start |
Logical. Warm start bootstraps. |
verbose |
Logical. Print progress to console? |
Value
An object of class gradLasso. This is a list containing:
coefficients |
A named vector of the final estimated regression coefficients. |
fitted.values |
A vector of the fitted values (response scale). |
residuals |
A vector of the residuals (observed - fitted). |
lambda |
The penalty term (lambda) used for the final model. |
boot_matrix |
A matrix of bootstrap coefficient estimates (rows=iterations, cols=features), or NULL if |
cv_results |
A list containing cross-validation metrics (if |
family |
The family object used for the fit. |
deviance |
The final model deviance. |
nobs |
The number of observations used. |
Package Imports and Global Documentation
Description
This file manages all external package dependencies and global imports required by gradLasso. It ensures that standard library functions (like those from stats or graphics) are available without explicit namespace qualification.
Binomial Family (Logistic Regression)
Description
Binomial Family (Logistic Regression)
Usage
grad_binomial()
Value
A list containing gradient, deviance, and prediction functions for logistic regression.
Gaussian Family (Least Squares)
Description
Gaussian Family (Least Squares)
Usage
grad_gaussian()
Value
A list containing gradient, deviance, and prediction functions for Gaussian regression.
Negative Binomial Family
Description
Negative Binomial Family
Usage
grad_negbin()
Value
A list containing gradient, deviance, and prediction functions for Negative Binomial regression.
Zero-Inflated Negative Binomial Family
Description
Zero-Inflated Negative Binomial Family
Usage
grad_zinb()
Value
A list containing gradient, deviance, and prediction functions for ZINB regression.
Extract Log-Likelihood
Description
Extract Log-Likelihood
Usage
## S3 method for class 'gradLasso'
logLik(object, ...)
Arguments
object |
A gradLasso fitted object. |
... |
Additional arguments. |
Value
An object of class logLik.
Plot CV results (Standalone)
Description
Plot CV results (Standalone)
Usage
## S3 method for class 'cv.gradLasso'
plot(x, ...)
Arguments
x |
A cv.gradLasso fitted object. |
... |
Additional arguments passed to plot. |
Value
Invisibly returns NULL.
Master Plot Method
Description
Diagnostic plots for gradLasso objects (Stability, CV, Residuals).
Usage
## S3 method for class 'gradLasso'
plot(x, which = c(1L:5L), ...)
Arguments
x |
A gradLasso fitted object. |
which |
Integer vector specifying which plots to draw (1:5). |
... |
Additional arguments passed to plotting functions. |
Value
Invisibly returns NULL.
Predict method for gradLasso
Description
Predict method for gradLasso
Usage
## S3 method for class 'gradLasso'
predict(object, newdata, type = c("response", "link", "count", "zero"), ...)
Arguments
object |
A gradLasso fitted object. |
newdata |
Optional new data frame for prediction. If missing, returns fitted values. |
type |
Type of prediction: "response" (default), "link", "count" (mu), or "zero" (pi). |
... |
Additional arguments passed to methods. |
Value
A vector or matrix of predictions.
Print CV results
Description
Print CV results
Usage
## S3 method for class 'cv.gradLasso'
print(x, ...)
Arguments
x |
A cv.gradLasso fitted object. |
... |
Additional arguments passed to print. |
Value
Invisibly returns the input object.
Print method for gradLasso object
Description
Print method for gradLasso object
Usage
## S3 method for class 'gradLasso'
print(x, ...)
Arguments
x |
A gradLasso fitted object. |
... |
Additional arguments passed to print. |
Value
Invisibly returns the input object.
Print method for summary
Description
Print method for summary
Usage
## S3 method for class 'summary.gradLasso'
print(x, ...)
Arguments
x |
A summary.gradLasso object. |
... |
Additional arguments passed to print. |
Value
Invisibly returns the input object.
Extract Residuals
Description
Extract Residuals
Usage
## S3 method for class 'gradLasso'
residuals(object, ...)
Arguments
object |
A gradLasso fitted object. |
... |
Additional arguments. |
Value
A numeric vector of residuals.
Simulate Data for gradLasso
Description
Generates synthetic data for Gaussian, Binomial, Negative Binomial, or ZINB models with correlated predictors.
Usage
simulate_data(
n = 1000,
p = 20,
family = "gaussian",
rho = 0.2,
k = 5,
k_mu = 5,
k_pi = 5,
theta = 1,
intercept_mu = 0,
intercept_pi = -1,
snr = 3
)
Arguments
n |
Number of observations. |
p |
Number of predictors. |
family |
Model family: "gaussian", "binomial", "negbin", or "zinb". |
rho |
Correlation coefficient between predictors (Toeplitz structure). |
k |
Number of non-zero coefficients (sparsity) for single-part models. |
k_mu |
Number of non-zero coefficients for Count part (ZINB only). |
k_pi |
Number of non-zero coefficients for Zero part (ZINB only). |
theta |
Dispersion parameter for NegBin and ZINB. |
intercept_mu |
Intercept for main model (or count part). |
intercept_pi |
Intercept for zero-inflation part. |
snr |
Signal-to-noise ratio (Gaussian only). |
Value
A list containing the following components:
X |
A matrix of predictor variables with induced correlation. |
y |
A vector of the simulated response variable. |
family |
The family string used for simulation. |
truth |
A list containing the true parameters used to generate the data (e.g., |
Summary method for gradLasso
Description
Summary method for gradLasso
Usage
## S3 method for class 'gradLasso'
summary(object, ...)
Arguments
object |
A gradLasso fitted object. |
... |
Additional arguments passed to methods. |
Value
A list containing the coefficient table, fit statistics (AIC/BIC), and stability selection results.