| Title: | Gradient Descent LASSO with Stability Selection and Bootstrapped Confidence Intervals |
|---|---|
| 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>. |
| Authors: | David DeFranza [aut, cre] |
| Maintainer: | David DeFranza <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.1 |
| Built: | 2026-05-09 07:51:01 UTC |
| Source: | https://github.com/ddefranza/gradlasso |
Extract Model Coefficients
## S3 method for class 'gradLasso' coef(object, ...)## S3 method for class 'gradLasso' coef(object, ...)
object |
A gradLasso fitted object. |
... |
Additional arguments. |
A numeric vector of coefficients.
Cross-Validation for gradLasso
cv.gradLasso( object, data = NULL, family, lambdas = NULL, nfolds = 5, batch_size = NULL, subsample = NULL, parallel = FALSE, verbose = FALSE )cv.gradLasso( object, data = NULL, family, lambdas = NULL, nfolds = 5, batch_size = NULL, subsample = NULL, parallel = FALSE, verbose = FALSE )
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? |
A list containing CV results (mean error, SD, optimal lambdas).
Extract Fitted Values
## S3 method for class 'gradLasso' fitted(object, ...)## S3 method for class 'gradLasso' fitted(object, ...)
object |
A gradLasso fitted object. |
... |
Additional arguments. |
A numeric vector of fitted values.
Binomial Family (Logistic Regression)
grad_binomial()grad_binomial()
A list containing gradient, deviance, and prediction functions for logistic regression.
Gaussian Family (Least Squares)
grad_gaussian()grad_gaussian()
A list containing gradient, deviance, and prediction functions for Gaussian regression.
Negative Binomial Family
grad_negbin()grad_negbin()
A list containing gradient, deviance, and prediction functions for Negative Binomial regression.
Zero-Inflated Negative Binomial Family
grad_zinb()grad_zinb()
A list containing gradient, deviance, and prediction functions for ZINB regression.
Gradient Descent LASSO with Stability Selection
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 )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 )
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? |
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. |
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.
Extract Log-Likelihood
## S3 method for class 'gradLasso' logLik(object, ...)## S3 method for class 'gradLasso' logLik(object, ...)
object |
A gradLasso fitted object. |
... |
Additional arguments. |
An object of class logLik.
Plot CV results (Standalone)
## S3 method for class 'cv.gradLasso' plot(x, ...)## S3 method for class 'cv.gradLasso' plot(x, ...)
x |
A cv.gradLasso fitted object. |
... |
Additional arguments passed to plot. |
Invisibly returns NULL.
Diagnostic plots for gradLasso objects (Stability, CV, Residuals).
## S3 method for class 'gradLasso' plot(x, which = c(1L:5L), ...)## S3 method for class 'gradLasso' plot(x, which = c(1L:5L), ...)
x |
A gradLasso fitted object. |
which |
Integer vector specifying which plots to draw (1:5). |
... |
Additional arguments passed to plotting functions. |
Invisibly returns NULL.
Predict method for gradLasso
## S3 method for class 'gradLasso' predict(object, newdata, type = c("response", "link", "count", "zero"), ...)## S3 method for class 'gradLasso' predict(object, newdata, type = c("response", "link", "count", "zero"), ...)
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. |
A vector or matrix of predictions.
Print CV results
## S3 method for class 'cv.gradLasso' print(x, ...)## S3 method for class 'cv.gradLasso' print(x, ...)
x |
A cv.gradLasso fitted object. |
... |
Additional arguments passed to print. |
Invisibly returns the input object.
Print method for gradLasso object
## S3 method for class 'gradLasso' print(x, ...)## S3 method for class 'gradLasso' print(x, ...)
x |
A gradLasso fitted object. |
... |
Additional arguments passed to print. |
Invisibly returns the input object.
Print method for summary
## S3 method for class 'summary.gradLasso' print(x, ...)## S3 method for class 'summary.gradLasso' print(x, ...)
x |
A summary.gradLasso object. |
... |
Additional arguments passed to print. |
Invisibly returns the input object.
Extract Residuals
## S3 method for class 'gradLasso' residuals(object, ...)## S3 method for class 'gradLasso' residuals(object, ...)
object |
A gradLasso fitted object. |
... |
Additional arguments. |
A numeric vector of residuals.
Generates synthetic data for Gaussian, Binomial, Negative Binomial, or ZINB models with correlated predictors.
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 )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 )
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). |
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
## S3 method for class 'gradLasso' summary(object, ...)## S3 method for class 'gradLasso' summary(object, ...)
object |
A gradLasso fitted object. |
... |
Additional arguments passed to methods. |
A list containing the coefficient table, fit statistics (AIC/BIC), and stability selection results.