SSGL {sparseGAM} | R Documentation |
Spike-and-Slab Group Lasso Regression
Description
This is a stand-alone function for group-regularized regression models in the exponential dispersion family with the spike-and-slab group lasso (SSGL) penalty. Let y_i
denote the i
th response and x_i
denote a p
-dimensional vector of covariates. We fit models of the form,
g(E(y_i)) = \beta_0 + x_i^T \beta, i = 1, ..., n,
where g
is a monotone increasing link function. 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.
If the covariates in each x_i
are grouped according to known groups g=1, ..., G
, then this function may estimate some of the G
groups of coefficients as all zero, depending on the amount of regularization.
Another implementation of the SSGL model for Gaussian regression models is available on Github at https://github.com/jantonelli111/SSGL. This package sparseGAM
also implements the SSGL model for binomial, Poisson, negative binomial, and gamma regression.
Usage
SSGL(y, X, X.test, groups,
family=c("gaussian","binomial","poisson","negativebinomial","gamma"),
nb.size=1, gamma.shape=1, weights, nlambda0=20, lambda0, lambda1, a, b,
max.iter=100, tol = 1e-6, print.iter=TRUE)
Arguments
y |
|
X |
|
X.test |
|
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. |
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.iter |
Boolean variable for whether or not to print the current |
Value
The function returns a list containing the following components:
lambda0 |
|
beta0 |
|
beta |
|
mu.pred |
|
classifications |
|
loss |
vector of either the residual sum of squares ( |
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(100*10), nrow=100)
n = dim(X)[1]
groups = c("A","A","A","B","B","B","C","C","D","D")
groups = as.factor(groups)
true.beta = c(-2.5,1.5,1.5,0,0,0,2,-2,0,0)
## Generate responses from Gaussian distribution
y = crossprod(t(X),true.beta) + rnorm(n)
## Generate test data
n.test = 50
X.test = matrix(runif(n.test*10), nrow=n.test)
## Fit SSGL model with 10 spike hyperparameters
## Note that if user does not specify lambda0, the SSGL function chooses a grid automatically.
SSGL.mod = SSGL(y, X, X.test, groups, family="gaussian", lambda0=seq(from=50,to=5,by=-5))
## Regression coefficient estimates
SSGL.mod$beta
# Predicted n.test-dimensional vectors mu=E(Y.test) based on test data, X.test.
# The kth column of 'mu.pred' corresponds to the kth entry in 'lambda.'
SSGL.mod$mu.pred
# Classifications of the 8 groups. The kth column of 'classifications'
# corresponds to the kth entry in 'lambda.'
SSGL.mod$classifications
## Example with binomial regression
## Generate binary responses
eta = crossprod(t(X), true.beta)
y = rbinom(n, size=1, prob=1/(1+exp(-eta)))
## Fit SSGL model with 10 spike hyperparameters
## Note that if user does not specify lambda0, the SSGL function chooses a grid automatically.
SSGL.mod = SSGL(y, X, X.test, groups, family="binomial",
lambda0=seq(from=10,to=1,by=-1))
## Predicted probabilities of success mu=E(Y.test) based on test data, X.test
SSGL.mod$mu.pred
## Classifications of the 8 groups.
SSGL.mod$classifications