% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ild_msm_history.R
\name{ild_build_msm_history}
\alias{ild_build_msm_history}
\title{Build MSM lagged history columns from a spec}
\usage{
ild_build_msm_history(data, spec, mode = NULL, max_gap = NULL)
}
\arguments{
\item{data}{An ILD object.}

\item{spec}{Object from [ild_msm_history_spec()].}

\item{mode}{Optional override for \code{spec$mode}.}

\item{max_gap}{Optional override for \code{spec$max_gap}.}
}
\value{
ILD object with lagged columns added; attributes include
  \code{ild_msm_history_manifest} (tibble with \code{variable}, \code{lag},
  \code{column}).
}
\description{
Applies [ild_lag()] repeatedly according to an [ild_msm_history_spec()] and
records a manifest under \code{attr(x, "ild_msm_history_manifest")}.
}
\examples{
d <- ild_simulate(n_id = 6, n_obs_per = 5, seed = 1)
d$stress <- rnorm(nrow(d))
d$trt <- rbinom(nrow(d), 1, 0.4)
d <- ild_prepare(d, id = "id", time = "time")
hs <- ild_msm_history_spec(c("stress", "trt"), lags = 1:2)
d2 <- ild_build_msm_history(d, hs)
attr(d2, "ild_msm_history_manifest")
}
