% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/simulate_inad.R
\name{simulate_inad}
\alias{simulate_inad}
\title{Simulate INAD antedependence series}
\usage{
simulate_inad(
  n_subjects,
  n_time,
  order = 1L,
  thinning = c("binom", "pois", "nbinom"),
  innovation = c("pois", "bell", "nbinom"),
  alpha = NULL,
  theta = NULL,
  nb_inno_size = 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{thinning}{thinning operator, one of \code{"binom"}, \code{"pois"}, \code{"nbinom"}}

\item{innovation}{innovation distribution, one of \code{"pois"}, \code{"bell"},
\code{"nbinom"}}

\item{alpha}{thinning parameter or vector or matrix; if \code{NULL}, defaults
are used depending on the order}

\item{theta}{innovation parameter or vector; if \code{NULL}, defaults are used
depending on the innovation type. For Poisson and negative binomial
innovations, \code{theta} is the innovation mean parameter. For Bell
innovations, \code{theta} is the Bell rate parameter, with innovation mean
\code{theta * exp(theta)}.}

\item{nb_inno_size}{size (dispersion) parameter for negative binomial innovations
when \code{innovation = "nbinom"}; must be positive. If \code{NULL}, defaults to 1.
Larger values correspond to less overdispersion (approaching Poisson as
size -> Inf).}

\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 c(0, x, ..., x) with length equal to the
number of blocks}

\item{seed}{optional random seed for reproducibility}
}
\value{
integer matrix of counts with dimension \code{n_subjects} by \code{n_time}
}
\description{
Generate longitudinal count data from an INAD model using a thinning
operator and an innovation distribution.
}
\details{
Time 1 observations are generated from the innovation distribution alone.
For times 2 to \code{n_time}, counts are generated as thinning of previous
counts plus independent innovations. When \code{order = 0}, all time points
are generated from the innovation distribution and the thinning operator
and \code{alpha} are ignored.

If \code{blocks} is provided, innovations include a block effect. For Poisson and
negative binomial innovations, the innovation mean is \code{theta[t] + tau[blocks[i]]}.
For Bell innovations, the innovation mean is \code{theta[t] * exp(theta[t]) + tau[blocks[i]]}.
}
\examples{
y <- simulate_inad(
  n_subjects = 20,
  n_time = 6,
  order = 1,
  thinning = "binom",
  innovation = "pois",
  alpha = 0.3,
  theta = 2,
  seed = 42
)
dim(y)
}
