% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ild_acf.R
\name{ild_acf}
\alias{ild_acf}
\title{Autocorrelation function for ILD variables or model residuals}
\usage{
ild_acf(x, ..., by_id = FALSE)
}
\arguments{
\item{x}{Either an ILD object (see [is_ild()]) or a fitted model from [ild_lme()].}

\item{...}{When \code{x} is ILD data, the variable(s) to compute ACF on (tidy-select; one variable). Ignored when \code{x} is a fit.}

\item{by_id}{Logical. If \code{TRUE}, also return per-person ACF in \code{acf_by_id} (default \code{FALSE}).}
}
\value{
A list with \code{acf}: a tibble with columns \code{lag} and \code{acf} (pooled). If \code{by_id = TRUE}, \code{acf_by_id} is a named list of tibbles (one per person).
}
\description{
Computes ACF on a variable in ILD data or on residuals from an [ild_lme()] fit.
Use this to check whether AR1 is appropriate before fitting models. ACF is
computed over the ordered observation sequence (pooled or within person); it
does not adjust for irregular time gaps.
}
\examples{
d <- ild_simulate(n_id = 5, n_obs_per = 10, seed = 1)
x <- ild_prepare(d, id = "id", time = "time")
ild_acf(x, "y")
fit <- ild_lme(y ~ 1 + (1 | id), data = x, ar1 = FALSE, warn_no_ar1 = FALSE)
ild_acf(fit)
}
