ssvs {SSVS}R Documentation

Perform SSVS for continuous and binary outcomes

Description

For continuous outcomes, a basic Gibbs sampler is used. For binary outcomes, BoomSpikeSlab::logit.spike() is used.

Usage

ssvs(
  data,
  y,
  x,
  continuous = TRUE,
  inprob = 0.5,
  runs = 20000,
  burn = 5000,
  a1 = 0.01,
  b1 = 0.01,
  prec.beta = 0.1,
  progress = TRUE
)

Arguments

data

The dataframe used to extract predictors and response values

y

The response variable

x

The set of predictor variables

continuous

If TRUE, treat the response variable as continuous. If FALSE, treat the response variable as binary.

inprob

Prior inclusion probability value, which applies to all predictors. The prior inclusion probability reflects the prior belief that each predictor should be included in the model. A prior inclusion probability of .5 reflects the belief that each predictor has an equal probability of being included or excluded. Note that a value of .5 also implies a prior belief that the true model contains half of the candidate predictors. The prior inclusion probability will influence the magnitude of the marginal inclusion probabilities (MIPs), but the relative pattern of MIPs is expected to remain fairly consistent, see Bainter et al. (2020) for more information.

runs

Total number of iterations (including burn-in). Results are based on the Total - Burn-in iterations.

burn

Number of burn-in iterations. Burn-in iterations are discarded warmup iterations used to achieve MCMC convergence. You may increase the number of burn-in iterations if you are having convergence issues.

a1

Prior parameter for Gamma(a,b) distribution on the precision (1/variance) residual variance. Only used when continuous = TRUE.

b1

Prior parameter for Gamma(a,b) distribution on the precision (1/variance) residual variance. Only used when continuous = TRUE.

prec.beta

Prior precision (1/variance) for beta coefficients. Only used when continuous = TRUE.

progress

If TRUE, show progress of the model creation. When continuous = TRUE, progress plots will be created for every 1000 iterations. When continuous = FALSE, 10 progress messages will be printed. Only used when continuous = TRUE.

Value

An SSVS object that can be used in summary() or plot().

Examples


# Example 1: continuous response variable
outcome <- "qsec"
predictors <- c("cyl", "disp", "hp", "drat", "wt", "vs", "am", "gear", "carb", "mpg")
results <- ssvs(data = mtcars, x = predictors, y = outcome, progress = FALSE)

# Example 2: binary response variable
library(AER)
data(Affairs)
Affairs$hadaffair[Affairs$affairs > 0] <- 1
Affairs$hadaffair[Affairs$affairs == 0] <- 0
outcome <- "hadaffair"
predictors <- c("gender", "age", "yearsmarried", "children", "religiousness",
"education", "occupation", "rating")
results <- ssvs(data = Affairs, x = predictors, y = outcome, continuous = FALSE, progress = FALSE)


[Package SSVS version 2.0.0 Index]