SSGL: Estimate grouped spike and slab lasso regression model

Description Usage Arguments Value Examples

View source: R/Main.R

Description

This function takes in an outcome and covariates, and estimates the posterior mode of the spike and slab group lasso penalty

Usage

1
2
3
4
SSGL(Y, X, lambda1, lambda0, groups, a = 1, b = length(unique(groups)),
  updateSigma = TRUE, M = 10, error = 0.001, betaStart = rep(0,
  dim(X)[2]), sigmasqStart, theta, printWarnings = TRUE,
  forceGroups = c())

Arguments

Y

The outcome to be analyzed

X

An n by p matrix of covariates

lambda1

Prior parameter for the slab component of the prior

lambda0

Prior parameter for the spike component of the prior

groups

A vector of length p denoting which group each covariate is in

a

First hyperparameter for the beta prior denoting the prior probability of being in the slab

b

Second hyperparameter for the beta prior denoting the prior probability of being in the slab

M

Positive number less than p indicating how often to update theta and sigma. There is no need to change this unless trying to optimize computation time

betaStart

Starting values for beta vector. There is no need to change this unless for some specific reason

theta

Value of the sparsity parameter theta. There is no need to select a value for this parameter unless the sparsity is known a priori. If left blank, the function will update theta automatically

printWarnings

Print warning messages about whether the optimization has converged

forceGroups

A vector containing the indices of any groups you wish to automatically include in the model and not penalize

UpdateSigma

True or False indicating whether to estimate the residual variance

sigmaStart

Starting value for sigma. There is no need to change this unless for some specific reason

Value

A list of values containing the regression coefficients, the intercept, the estimate of the residual variance (this is simply the marginal variance of Y if UpdateSigma=FALSE), An estimate of theta the prior probability of entering into the slab, and the number of iterations it took to converge

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## Here we generate 200 samples from 100 covariates
n = 200
G = 100
x = mvtnorm::rmvnorm(n, sigma=diag(G))


X = matrix(NA, nrow=n, ncol=G*2)

for (g in 1 : G) {
  X[,2*(g-1) + 1] = x[,g]
  X[,2*g] = x[,g]^2
}

Y = 200 + x[,1] + x[,2] + 0.6*x[,2]^2 + rnorm(n, sd=1)

## Now fit model for chosen lambda0 and lambda1 values
modSSGL = SSGL(Y=Y, X=X, lambda1=.1, lambda0=10, 
groups = rep(1:G, each=2))

modSSGL

jantonelli111/SSGL documentation built on March 9, 2020, 9:45 p.m.