% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ild_crosslag.R
\name{ild_crosslag}
\alias{ild_crosslag}
\title{Cross-lag model: lag predictor then fit outcome ~ lag}
\usage{
ild_crosslag(
  data,
  outcome,
  predictor,
  lag = 1L,
  mode = c("gap_aware", "index", "time_window"),
  max_gap = NULL,
  ar1 = FALSE,
  include_diagnostics = FALSE,
  ...
)
}
\arguments{
\item{data}{An ILD object (see [is_ild()]).}

\item{outcome}{Character or symbol. Name of the outcome variable (e.g. \code{"mood"}).}

\item{predictor}{Character or symbol. Name of the predictor to lag (e.g. \code{"stress"}).}

\item{lag}{Integer. Lag order (default 1).}

\item{mode}{Character. Passed to [ild_lag()]: \code{"index"}, \code{"gap_aware"} (default), or \code{"time_window"}.}

\item{max_gap}{Numeric or NULL. Passed to [ild_lag()] when \code{mode = "gap_aware"}.}

\item{ar1}{Logical. If \code{TRUE}, fit with [ild_lme()] using AR1/CAR1 (default \code{FALSE}).}

\item{include_diagnostics}{Logical. If \code{TRUE}, attach [ild_diagnostics()] to the return (default \code{FALSE}).}

\item{...}{Passed to [ild_lme()].}
}
\value{
A list: \code{fit} (fitted model), \code{lag_term} (one-row tibble from [tidy_ild_model()] for the lag variable),
  \code{lag_check} (tibble from [ild_check_lags()]), \code{data} (ILD with lag column), and optionally \code{diagnostics}.
}
\description{
One-call pipeline: [ild_lag()] the predictor, [ild_check_lags()] to audit,
then [ild_lme()] to fit outcome on the lagged predictor. Returns the fit,
the lag-term coefficient (estimate, CI, p), and lag validity check.
}
\examples{
d <- ild_simulate(n_id = 10, n_obs_per = 8, seed = 1)
x <- ild_prepare(d, id = "id", time = "time")
out <- ild_crosslag(x, "y", "y", lag = 1, ar1 = FALSE, warn_no_ar1 = FALSE)
out$lag_term
out$lag_check
}
