% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/calculate_pvc.R
\name{stepwise_pcv}
\alias{stepwise_pcv}
\title{Stepwise Proportional Change in Variance (PCV)}
\usage{
stepwise_pcv(data, outcome, vars, engine = "lme4", family = "gaussian")
}
\arguments{
\item{data}{Data frame with observations. Ensure `make_strata()` was run first
so the `stratum` variable exists.}

\item{outcome}{Character string; the dependent variable.}

\item{vars}{Character vector; predictors (strata groupings & covariates) to
add sequentially to the model.}

\item{engine}{Modeling engine ("lme4" or "brms"). Default is "lme4".}

\item{family}{Error distribution and link function. Default is "gaussian".}
}
\value{
A data.frame showing the sequential models, the between-stratum
  variance at each step, and both the step-specific and total PCV.
}
\description{
Estimates the proportional change in variance (PCV) sequentially by fitting
intermediate (partially-adjusted) models. It adds each predictor variable
one-by-one to gauge its unique contribution in explaining between-stratum
inequalities.
}
\details{
All models are fit on the complete cases for `outcome`, `stratum`, and all
variables in `vars` so that each sequential variance comparison uses the same
analytic sample.
}
\examples{
\donttest{
strata_result <- make_strata(maihda_sim_data, c("gender", "race"))
stepwise_pcv(strata_result$data, "health_outcome", c("gender", "race", "age"))
}
}
