% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/nl_icc.R
\name{nl_icc}
\alias{nl_icc}
\title{Intraclass correlation coefficients for a multilevel nl_fit model}
\usage{
nl_icc(object, include_residual = TRUE)
}
\arguments{
\item{object}{An \code{nl_fit} object returned by \code{\link{nl_fit}}
that was fitted with one or more \code{cluster} variables (i.e., a
multilevel model fitted via \code{lme4::lmer()} or
\code{lme4::glmer()}).}

\item{include_residual}{Logical; if \code{TRUE} (default), includes the
residual variance component \code{ICC_resid} in the output so that all
values sum to 1.}
}
\value{
A named numeric vector of ICCs, one per grouping factor (named
\code{ICC_<groupname>}) plus \code{Residual} for the residual variance
(when \code{include_residual = TRUE}). All values sum to 1.
}
\description{
Extracts variance components from a multilevel \code{nl_fit} object and
computes intraclass correlation coefficients (ICCs) for each grouping
level plus the residual.

The ICC for grouping factor \eqn{g} is defined as:
\deqn{ICC_g = \frac{\sigma^2_g}{\sum_j \sigma^2_j + \sigma^2_\epsilon}}
}
\examples{
\dontrun{
fit <- nl_fit(
  data    = mydata,
  y       = "math_score",
  x       = "SES",
  cluster = c("id", "schid"),
  df      = 4
)
nl_icc(fit)
}

}
\seealso{
\code{\link{nl_fit}}
}
