% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/simulate_gau.R
\name{simulate_gau}
\alias{simulate_gau}
\title{Simulate Gaussian antedependence series}
\usage{
simulate_gau(
  n_subjects,
  n_time,
  order = 1L,
  mu = NULL,
  phi = NULL,
  sigma = NULL,
  blocks = NULL,
  tau = 0,
  seed = NULL
)
}
\arguments{
\item{n_subjects}{number of subjects}

\item{n_time}{number of time points}

\item{order}{antedependence order, 0, 1 or 2}

\item{mu}{mean parameter; \code{NULL}, scalar, or length \code{n_time}}

\item{phi}{dependence parameter; ignored when \code{order = 0}.
For \code{order = 1}, \code{NULL}, scalar, or length \code{n_time}.
For \code{order = 2}, \code{NULL} or a 2 by \code{n_time} matrix.}

\item{sigma}{innovation standard deviation; \code{NULL}, scalar, or length \code{n_time}}

\item{blocks}{integer vector of length \code{n_subjects} indicating block membership
for each subject; if \code{NULL}, no block effect is applied}

\item{tau}{group effect vector indexed by block; \code{tau[1]} is forced to 0.
If scalar x, it is expanded to \code{c(0, x, ..., x)} with length equal to the
number of blocks}

\item{seed}{optional random seed for reproducibility}
}
\value{
numeric matrix with dimension \code{n_subjects} by \code{n_time}
}
\description{
Generate longitudinal continuous data from a Gaussian antedependence (AD)
model of order 0, 1, or 2 using a conditional regression on predecessors.
}
\details{
For \code{order = 0}, each time point is generated independently as
\code{Y[, t] = mu[t] + tau[block] + eps}, with \code{eps ~ N(0, sigma[t]^2)}.

For \code{order = 1}, for \code{t >= 2}:
\verb{Y[, t] = m_t + phi[t] * (Y[, t - 1] - m_\{t-1\}) + eps_t},
where \code{m_t = mu[t] + tau[block]} and \code{eps_t ~ N(0, sigma[t]^2)}.

For \code{order = 2}, for \code{t >= 3}:
\verb{Y[, t] = m_t + phi[1, t] * (Y[, t - 1] - m_\{t-1\}) + phi[2, t] * (Y[, t - 2] - m_\{t-2\}) + eps_t}.

If \code{blocks} is provided, each subject s belongs to a block and receives a
mean shift \code{tau[blocks[s]]}. \code{tau[1]} is forced to 0.
}
\examples{
y <- simulate_gau(
  n_subjects = 20,
  n_time = 6,
  order = 1,
  phi = 0.4,
  seed = 42
)
dim(y)
}
