% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/lav_vif.R
\name{lav_vif}
\alias{lav_vif}
\alias{print.lav_vif}
\alias{summary.lav_vif}
\title{Variance Inflation Factors for 'lavaan' Structural Predictors}
\usage{
lav_vif(
  fit,
  data = NULL,
  quiet = TRUE
)

\method{print}{lav_vif}(x, digits = 3, cutoff = c(5, 10), ...)

\method{summary}{lav_vif}(object, ...)
}
\arguments{
\item{fit}{A fitted \code{lavaan} object.}

\item{data}{Optional. The data frame used to fit \code{fit}. If \code{NULL},
the function attempts to extract the data from \code{fit} via
\code{lavInspect(fit, "data")}. For multigroup models, grouped data are
reconstructed into a single data frame when possible.}

\item{quiet}{Logical. If \code{TRUE} suppresses lavaan refit messages.}

\item{x}{A 'lav_vif' object.}

\item{digits}{Integer number of digits to print.}

\item{cutoff}{Numeric length-2 thresholds used to flag VIF values.}

\item{...}{Passed to `print.lav_vif()` (e.g., `digits`, `cutoff`).}

\item{object}{A 'lav_vif' object.}
}
\value{
A list with:
\itemize{
  \item \code{vif_table}: data.frame with columns
        \code{outcome}, \code{predictor}, \code{group}, \code{r2_predictor},
        \code{vif}, \code{k_predictors}.
  \item \code{outcome_r2}: data.frame with \eqn{R^2} per eligible endogenous
        \code{outcome} and \code{group} from the original \code{fit}.
}
}
\description{
Compute VIF for each predictor that appears in structural regressions
with two or more predictors, refitting the necessary sub-models so that
latent predictors are handled at the latent level (i.e., with their original
measurement models). It returns also the \eqn{R^2} of each eligible endogenous variable 
from the original fit for context.
}
\details{
Each auxiliary refitted model includes the measurement structure for latent 
predictors, rebuilt from the original model syntax, together with observed 
residual covariances among the involved indicators when specified in the 
original model. Then, regresses the focal predictor on the remaining predictors 
at the latent level when applicable.

\eqn{\mathrm{VIF}_i = 1 / (1 - R_i^2)} generalizes VIF to SEM while respecting 
measurement models.
  
The function reuses the estimator, missing-data handling, and several options 
from \code{fit}. 
In multigroup models, VIF is computed separately within each group. 
Higher-order latent predictors are supported by recursively rebuilding
lower-order measurement blocks in the auxiliary refitted models.
}
\examples{
set.seed(42)
x1 <- rnorm(100); x2 <- 0.85*x1 + rnorm(100, sd = sqrt(1 - 0.85^2)); x3 <- rnorm(100)
y <- 0.5*x1 + 0.3*x2 + 0.1*x3 + rnorm(100, sd = 0.7)
dataset <- data.frame(y, x1, x2, x3)
fit <- lavaan::sem("y ~ x1 + x2 + x3", data = dataset)
lav_vif(
fit = fit,
data = dataset)

}
\references{
Fox, J., & Monette, G. (1992). Generalized collinearity diagnostics.
\emph{Journal of the American Statistical Association}, \emph{87}(417),
178-183. \doi{10.1080/01621459.1992.10475190}

Belsley, D. A., Kuh, E., & Welsch, R. E. (1980).
\emph{Regression diagnostics: Identifying influential data and sources of
collinearity}. Wiley.
}
