% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ols-stepaic-both-regression.R
\name{ols_step_both_sbc}
\alias{ols_step_both_sbc}
\alias{ols_step_both_sbc.default}
\alias{plot.ols_step_both_sbc}
\title{Stepwise SBC regression}
\usage{
ols_step_both_sbc(model, ...)

\method{ols_step_both_sbc}{default}(
  model,
  include = NULL,
  exclude = NULL,
  progress = FALSE,
  details = FALSE,
  steps = NULL,
  ...
)

\method{plot}{ols_step_both_sbc}(x, print_plot = TRUE, details = TRUE, digits = 3, ...)
}
\arguments{
\item{model}{An object of class \code{lm}.}

\item{...}{Other arguments.}

\item{include}{Character or numeric vector; variables to be included in selection process.}

\item{exclude}{Character or numeric vector; variables to be excluded from selection process.}

\item{progress}{Logical; if \code{TRUE}, will display variable selection progress.}

\item{details}{Logical; if \code{TRUE}, details of variable selection will
be printed on screen.}

\item{steps}{Number of steps after which the stepwise procedures should stop.}

\item{x}{An object of class \code{ols_step_both_*}.}

\item{print_plot}{logical; if \code{TRUE}, prints the plot else returns a plot object.}

\item{digits}{Number of decimal places to display.}
}
\value{
List containing the following components:

\item{model}{final model; an object of class \code{lm}}
\item{metrics}{selection metrics}
\item{others}{list; info used for plotting and printing}
}
\description{
Build regression model from a set of candidate predictor variables by
entering and removing predictors based on schwarz bayesian criterion, in a
stepwise manner until there is no variable left to enter or remove any more.
}
\examples{
\dontrun{
# stepwise regression
model <- lm(y ~ ., data = stepdata)
ols_step_both_sbc(model)

# stepwise regression plot
model <- lm(y ~ ., data = stepdata)
k <- ols_step_both_sbc(model)
plot(k)

# selection metrics
k$metrics

# final model
k$model

# include or exclude variables
# force variable to be included in selection process
model <- lm(y ~ ., data = stepdata)

ols_step_both_sbc(model, include = c("x6"))

# use index of variable instead of name
ols_step_both_sbc(model, include = c(6))

# force variable to be excluded from selection process
ols_step_both_sbc(model, exclude = c("x2"))

# use index of variable instead of name
ols_step_both_sbc(model, exclude = c(2))

# include & exclude variables in the selection process
ols_step_both_sbc(model, include = c("x6"), exclude = c("x2"))

# use index of variable instead of name
ols_step_both_sbc(model, include = c(6), exclude = c(2))

# steps
ols_step_both_sbc(model, steps = 3)
}

}
\references{
Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics with S. Fourth edition. Springer.
}
\seealso{
Other both direction selection procedures: 
\code{\link{ols_step_both_adj_r2}()},
\code{\link{ols_step_both_aic}()},
\code{\link{ols_step_both_r2}()},
\code{\link{ols_step_both_sbic}()}
}
\concept{both direction selection procedures}
