% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/simulate.R
\name{simulate_smoothbp}
\alias{simulate_smoothbp}
\title{Simulate data from the smooth change-point model}
\usage{
simulate_smoothbp(
  n_subj = 20L,
  n_obs = 8L,
  b0 = 5,
  b1 = -0.3,
  b2 = 1.2,
  omega = 3,
  rho = 4,
  sigma = 0.4,
  sigma_u = 0.5,
  tau_range = c(0, 6),
  seed = NULL
)
}
\arguments{
\item{n_subj}{Number of subjects (groups).  Set to \code{1} and
\code{sigma_u = 0} for a single-group simulation.}

\item{n_obs}{Observations per subject.  May be a scalar (same for all
subjects) or a length-\code{n_subj} integer vector for unbalanced designs.}

\item{b0}{Overall intercept.}

\item{b1}{Pre-change-point slope.}

\item{b2}{Change in slope at the change-point.}

\item{omega}{Change-point location (must be positive).}

\item{rho}{Sharpness of the transition (must be positive; larger values
give a sharper kink).}

\item{sigma}{Residual standard deviation.}

\item{sigma_u}{Between-subject SD for random intercepts.  Set to \code{0}
to suppress random effects.  Default \code{0.5}.}

\item{tau_range}{Numeric vector of length 2 giving the range of the time
variable.  Observations are evenly spaced within this range for each
subject.  Default \code{c(0, 6)}.}

\item{seed}{Integer seed for reproducibility.  Sampled randomly if
\code{NULL} (default).}
}
\value{
A \code{data.frame} with columns:
\describe{
\item{\code{subject}}{Subject identifier (factor).}
\item{\code{tau}}{Time variable.}
\item{\code{mu}}{Noise-free conditional mean \eqn{\mu_{ij}}.}
\item{\code{y}}{Observed response.}
}
The attribute \code{"true_params"} is a named list containing the
data-generating values of \code{b0}, \code{b1}, \code{b2}, \code{omega},
\code{rho}, \code{sigma}, \code{sigma_u}, the vector of subject-level
deviations \code{u}, and the \code{seed} used.
}
\description{
Generates synthetic data from the model used by \code{\link{smoothbp}},
including optional between-subject random intercepts.  True parameter values
are stored as the \code{"true_params"} attribute so they can be compared
against posterior estimates.
}
\details{
The data-generating model is:
\deqn{y_{ij} = (b0 + u_j) + b1 \cdot d_{ij} + b2 \cdot d_{ij} \cdot \sigma(d_{ij} \cdot \rho) + \varepsilon_{ij}}
where \eqn{d_{ij} = \tau_{ij} - \omega} and \eqn{\sigma(\cdot)} is the
logistic sigmoid.
}
\examples{
dat <- simulate_smoothbp(
  n_subj = 20, n_obs = 8,
  b0 = 5, b1 = -0.3, b2 = 1.2,
  omega = 3, rho = 4, sigma = 0.4, sigma_u = 0.5,
  seed = 42
)
head(dat)
attr(dat, "true_params")

}
