Fits elastic net regularization using glmnet with cross-validation to select the optimal regularization parameter. Formats output to be compatible with gSuSiE result structure.
Usage
run_glmnet(
X,
y,
family = gaussian(),
alpha = 1,
standardize = TRUE,
nfolds = 10
)Arguments
- X
Design matrix of predictors (n × p).
- y
Response vector or survival object.
- family
Response family. Can be gaussian(), binomial(), poisson(), Gamma(), or "cox" for Cox regression.
- alpha
Elastic net mixing parameter: 0 = ridge, 1 = lasso, 0 < alpha < 1 = elastic net.
- standardize
Logical. Should variables be standardized? Default TRUE.
- nfolds
Number of cross-validation folds. Default 10.
Value
A list containing:
- cs
List with 'sets' component containing singleton credible sets for selected variables
- theta
Vector of estimated coefficients (excluding intercept)
- pip
Binary vector indicating variable selection (1 = selected, 0 = not selected)
- lambda_1se
Lambda value within 1 standard error of minimum CV error
- lambda_min
Lambda value that minimizes CV error
- selected
Indices of selected variables
Details
This function serves as a wrapper around glmnet::cv.glmnet to provide
output compatible with gSuSiE results. Uses lambda.1se for coefficient estimation,
which provides more conservative variable selection than lambda.min.