% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ild_plot.R
\name{ild_plot}
\alias{ild_plot}
\title{ILD-specific plots}
\usage{
ild_plot(
  x,
  type = c("trajectory", "heatmap", "gaps", "missingness", "fitted", "fitted_vs_actual",
    "predicted_trajectory", "residual_acf"),
  var = NULL,
  id_var = ".ild_id",
  time_var = c(".ild_time_num", ".ild_seq"),
  max_ids = 20L,
  seed = 42L,
  facet_by = NULL,
  ...
)
}
\arguments{
\item{x}{An ILD tibble or a fitted [ild_lme()] model.}

\item{type}{Character (or vector). One or more of: `"trajectory"`, `"heatmap"`,
`"gaps"`, `"missingness"`, `"fitted"` or `"fitted_vs_actual"` (requires fitted model),
`"predicted_trajectory"` (observed and fitted lines vs time; requires fitted model),
`"residual_acf"` (requires fitted model; ACF is over observation sequence, not adjusted for
irregular time gaps). If length > 1, returns a named list of ggplots.}

\item{var}{For `trajectory` or `heatmap`, the variable to plot (optional;
if missing and only one non-.ild_* column exists, it is used).}

\item{id_var}{For trajectory, variable used for grouping (default `.ild_id`).}

\item{time_var}{For trajectory/gaps/`predicted_trajectory`, x-axis: `.ild_time_num` or `.ild_seq`.}

\item{max_ids}{For trajectory and `predicted_trajectory`, max number of persons to plot (sampled if
larger; default 20). Set to `Inf` to plot all.}

\item{seed}{Integer. Seed for sampling ids when `max_ids` is set (default 42).}

\item{facet_by}{Optional character: name of a column in the ILD (e.g. cluster or site) to pass to
[ggplot2::facet_wrap()] for `trajectory`, `heatmap`, `gaps`, and `predicted_trajectory`.}

\item{...}{Unused.}
}
\value{
A single ggplot when `length(type) == 1`, or a named list of ggplots when `length(type) > 1`.
}
\description{
Produces trajectory (spaghetti), heatmap, gaps, and (if a fitted model
is provided) fitted vs actual and residual ACF. Works for both lmerMod and
lme (ild_lme with ar1 = TRUE).
}
\examples{
x <- ild_prepare(ild_simulate(n_id = 3, n_obs_per = 6, seed = 1), id = "id", time = "time")
fit <- ild_lme(y ~ 1 + (1 | id), data = x, ar1 = FALSE, warn_no_ar1 = FALSE)
ild_plot(fit, type = "fitted_vs_actual")
ild_plot(fit, type = c("fitted_vs_actual", "residual_acf"))
}
