% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/SSVS.R
\name{ssvs}
\alias{ssvs}
\title{Perform SSVS for continuous and binary outcomes}
\usage{
ssvs(
  data,
  y,
  x,
  continuous = TRUE,
  prior.probs = 0.5,
  inprob = NULL,
  force.in = NULL,
  runs = 20000,
  burn = 5000,
  a1 = 0.01,
  b1 = 0.01,
  prec.beta = 0.1,
  progress = TRUE
)
}
\arguments{
\item{data}{The dataframe used to extract predictors and response values}

\item{y}{The response variable}

\item{x}{The set of predictor variables}

\item{continuous}{If \code{TRUE}, treat the response variable as continuous. If
\code{FALSE}, treat the response variable as binary.}

\item{prior.probs}{Numeric vector or scalar specifying the prior probability
that each predictor variable is included in the model. If a scalar, the value is
replicated for all variables. If a vector, must have legnth equal to length(x).
Each value must be between 0 and 1. Setting a prior probability to 1.0 forces
that variable to always be included. The default prior inclusion probability is
.5 for all predictors. The prior inclusion probabilities will influence the
magnitude of the marginal inclusion probabilities (MIPs), but the relative pattern of
MIPs is expected to remain fairly consistent.}

\item{inprob}{\strong{Deprecated}; use \code{prior.probs} instead.
If provided, this overrides \code{prior.probs} (with a warning).}

\item{force.in}{Character vector specifying variables that should always be
included in the model. This is a convenience parameter that sets prior.probs = 1.0
for the specified variables. If both prior.probs and force.in are provided,
force.in takes precedence and will override probabilities for those variables.
Default is NULL.}

\item{runs}{Total number of iterations (including burn-in). Results are based on
the Total - Burn-in iterations.}

\item{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.}

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

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

\item{prec.beta}{Prior precision (1/variance) for beta coefficients.
Only used when \code{continuous = TRUE}.}

\item{progress}{If \code{TRUE}, show progress of the model creation. When \code{continuous = TRUE},
progress plots will be created for every 1000 iterations. When \code{continuous = FALSE},
10 progress messages will be printed.
Only used when \code{continuous = TRUE}.}
}
\value{
An ssvs object that can be used in
\code{\link[=summary.ssvs]{summary()}} or \code{\link[=plot.ssvs]{plot()}}.
}
\description{
For continuous outcomes, a basic Gibbs sampler is used. For binary
outcomes, \code{\link[BoomSpikeSlab:logit.spike]{BoomSpikeSlab::logit.spike()}} is used.
}
\examples{
\donttest{
# Example 1: Continuous response variable, uniform prior
outcome <- "qsec"
predictors <- c("cyl", "disp", "hp", "drat", "wt", "vs", "am", "gear", "carb", "mpg")
results <- ssvs(data = mtcars, x = predictors, y = outcome,
prior.probs = .5, #same for all predictors
progress = FALSE)

#' # Example 2: Continuous response variable, variable-specific priors
outcome <- "mpg"
predictors <- c("cyl", "disp", "hp", "wt")
prior.probs = c(0.7, 0.5, 0.2, 0.2) # Different prior probability for each
results <- ssvs(data = mtcars, x = predictors, y = outcome,
progress = FALSE)

# Example 3: 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)

#' # Example 4: Binary response variable with forced inclusion of select predictors
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, force.in = c("children", "rating"),
continuous = FALSE, progress = FALSE)
}
}
