cv.SSGL {sparseGAM} | R Documentation |
Cross-Validation for Spike-and-Slab Group Lasso Regression
Description
This function implements K
-fold cross-validation for group-regularized regression in the exponential dispersion family with the spike-and-slab group lasso (SSGL) penalty. The identity link function is used for Gaussian regression, the logit link is used for binomial regression, and the log link is used for Poisson, negative binomial, and gamma regression.
Usage
cv.SSGL(y, X, groups,
family=c("gaussian","binomial","poisson","negativebinomial","gamma"),
nb.size=1, gamma.shape=1, weights, nfolds=5, nlambda0=20,
lambda0, lambda1, a, b, max.iter=100, tol=1e-6, print.fold=TRUE)
Arguments
y |
|
X |
|
groups |
|
family |
exponential dispersion family. Allows for |
nb.size |
known size parameter |
gamma.shape |
known shape parameter |
weights |
group-specific, nonnegative weights for the penalty. Default is to use the square roots of the group sizes. |
nfolds |
number of folds |
nlambda0 |
number of spike hyperparameters |
lambda0 |
grid of |
lambda1 |
slab hyperparameter |
a |
shape hyperparameter for the |
b |
shape hyperparameter for the |
max.iter |
maximum number of iterations in the algorithm. Default is |
tol |
convergence threshold for algorithm. Default is |
print.fold |
Boolean variable for whether or not to print the current fold in the algorithm. Default is |
Value
The function returns a list containing the following components:
lambda0 |
|
cve |
|
cvse |
|
lambda0.min |
value of |
References
Bai R. (2021). "Spike-and-slab group lasso for consistent Bayesian estimation and variable selection in non-Gaussian generalized additive models." arXiv pre-print arXiv:2007.07021.
Bai, R., Moran, G. E., Antonelli, J. L., Chen, Y., and Boland, M.R. (2021). "Spike-and-slab group lassos for grouped regression and sparse generalized additive models." Journal of the American Statistical Association, in press.
Examples
## Generate data
set.seed(12345)
X = matrix(runif(30*6), nrow=30)
n = dim(X)[1]
groups = c(1,1,1,2,2,3)
true.beta = c(-1.5,0.5,-1.5,0,0,0)
## Generate responses from Gaussian distribution
y = crossprod(t(X), true.beta) + rnorm(n)
## K-fold cross-validation for 3 choices of lambda0
## Note that if user does not specify lambda0, cv.SSGL chooses a grid automatically.
ssgl.mods = cv.SSGL(y, X, groups, family="gaussian", lambda0=seq(from=10,to=2,by=-4))
## Plot cross-validation curve
plot(ssgl.mods$lambda0, ssgl.mods$cve, type="l", xlab="lambda0", ylab="CVE")
## lambda which minimizes mean CVE
ssgl.mods$lambda0.min
## Example with Poisson regression
## Generate count responses
eta = crossprod(t(X), true.beta)
y = rpois(n,exp(eta))
## K-fold cross-validation with 4 choices of lambda0
## Note that if user does not specify lambda0, cv.SSGL chooses a grid automatically.
ssgl.poisson.mods = cv.SSGL(y, X, groups, family="poisson", lambda0=seq(from=8,to=2,by=-2))
## Plot cross-validation curve
plot(ssgl.poisson.mods$lambda0, ssgl.poisson.mods$cve, type="l", xlab="lambda0", ylab="CVE")
## lambda which minimizes mean CVE
ssgl.poisson.mods$lambda0.min