Description Usage Arguments Value References Examples
This function implements sparse Bayesian generalized additive models (GAMs) with the spikeandslab group lasso (SSGL) penalty. Let y_i denote the ith response and x_i denote a pdimensional vector of covariates. GAMs are of the form,
g(E(y_i)) = β_0 + ∑_{j=1}^{p} f_j (x_{ij}), 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. With the SSGL penalty, some of the univariate functions f_j(x_j) will be estimated as \hat{f}_j(x_j) = 0, depending on the size of the spike hyperparameter λ_0 in the SSGL prior. The functions f_j(x_j), j = 1, ..., p, are modeled using Bspline basis expansions.
There is another implementation of sparse Gaussian GAMs with the SSGL penalty available at https://github.com/jantonelli111/SSGL, which uses natural cubic splines as the basis functions. This package sparseGAM
uses Bspline basis functions and also implements sparse GAMs with the SSGL penalty for binomial, Poisson, negative binomial, and gamma regression.
For implementation of sparse frequentist GAMs with the group LASSO, group SCAD, and group MCP penalties, use the SFGAM
function.
1 2 3 4 
y 
n \times 1 vector of responses for training data. 
X 
n \times p design matrix for training data, where the jth column of 
X.test 
n_{test} \times p design matrix for test data to calculate predictions. 
df 
number of Bspline basis functions to use in each basis expansion. Default is 
family 
exponential dispersion family. Allows for 
nb.size 
known size parameter α in NB(α,μ_i) distribution for negative binomial responses. Default is 
gamma.shape 
known shape parameter ν in Gamma(μ_i,ν) distribution for gamma responses. Default is 
nlambda0 
number of spike hyperparameter L. Default is 
lambda0 
grid of L spike hyperparameters λ_0. The user may specify either a scalar or a vector. If the user does not provide this, the program chooses the grid automatically. 
lambda1 
slab hyperparameter λ_1 in the SSGL prior. Default is 
a 
shape hyperparameter for the Beta(a,b) prior on the mixing proportion in the SSGL prior. Default is 
b 
shape hyperparameter for the Beta(a,b) prior on the mixing proportion in the SSGL prior. Default is 
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 
The function returns a list containing the following components:
lambda0 
L \times 1 vector of spike hyperparameters 
f.pred 
List of L n_{test} \times p matrices, where the kth matrix in the list corresponds to the kth spike hyperparameter in 
mu.pred 
n_{test} \times L matrix of predicted mean response values μ_{test} = E(Y_{test}) based on the test data in 
classifications 
p \times L matrix of classifications. An entry of "1" indicates that the corresponding function was classified as nonzero, and an entry of "0" indicates that the function was classified as zero. The kth column of 
beta0 
L \times 1 vector of estimated intercepts. The kth entry in 
beta 
dp \times L matrix of estimated basis coefficients. The kth column in 
loss 
vector of either the residual sum of squares ( 
Bai R. (2021). "Spikeandslab group lasso for consistent Bayesian estimation and variable selection in nonGaussian generalized additive models." arXiv preprint arXiv:2007.07021.
Bai, R., Moran, G. E., Antonelli, J. L., Chen, Y., and Boland, M.R. (2021). "Spikeandslab group lassos for grouped regression and sparse generalized additive models." Journal of the American Statistical Association, in press.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27  ## Generate data
set.seed(12345)
X = matrix(runif(100*5), nrow=100)
n = dim(X)[1]
y = 3*sin(2*pi*X[,1])3*cos(2*pi*X[,2]) + rnorm(n)
## Test data with 30 observations
X.test = matrix(runif(30*5), nrow=30)
## Fit sparse Bayesian generalized additive model to data with the SSGL penalty
## and 5 spike hyperparameters
SBGAM.mod = SBGAM(y, X, X.test, family="gaussian", lambda0=seq(from=50,to=10,by=10))
## The model corresponding to the 1st spike hyperparameter
SBGAM.mod$lambda[1]
SBGAM.mod$classifications[,1]
## Plot first function f_1(x_1) in 2nd model
x1 = X.test[,1]
## Estimates of all 20 function evaluations on test data
f.hat = SBGAM.mod$f.pred[[1]]
## Extract estimates of f_1
f1.hat = f.hat[,1]
## Plot X_1 against f_1(x_1)
plot(x1[order(x1)], f1.hat[order(x1)], xlab=expression(x[1]),
ylab=expression(f[1](x[1])))

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.