% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ild_decomposition.R
\name{ild_decomposition}
\alias{ild_decomposition}
\title{Within-person and between-person variance decomposition}
\usage{
ild_decomposition(x, ..., plot = FALSE)
}
\arguments{
\item{x}{An ILD object (see [is_ild()]).}

\item{...}{Variables to decompose (tidy-select). Must be numeric.}

\item{plot}{Logical. If \code{TRUE}, return a list with \code{table} and \code{plot} (WP vs BP density overlay). Default \code{FALSE}.}
}
\value{
A tibble with columns \code{variable}, \code{wp_var}, \code{bp_var}, \code{ratio} (wp_var / bp_var; \code{Inf} if bp_var is 0). If \code{plot = TRUE}, a list with \code{table} and \code{plot} (ggplot).
}
\description{
Reports WP and BP variance and their ratio for selected variables. Use as a
diagnostic and teaching tool: large ratio suggests within-person variance
dominates; small ratio suggests between-person differences dominate. Helps
avoid conflating WP and BP effects in modeling.
}
\examples{
d <- ild_simulate(n_id = 10, n_obs_per = 8, seed = 1)
x <- ild_prepare(d, id = "id", time = "time")
ild_decomposition(x, y)
}
