% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data-preparation.R
\name{prepare_sem_data}
\alias{prepare_sem_data}
\title{Prepare data for the SEM copula VAR model}
\usage{
prepare_sem_data(
  data,
  indicators,
  J = NULL,
  lambda = NULL,
  sigma_e = NULL,
  margins = "normal",
  skew_direction = NULL,
  time_var = "time",
  prior_mu_sd = 0.25,
  prior_phi_sd = 0.5,
  prior_sigma_sd = 0.5,
  prior_rho_sd = 0.75,
  tv_phi = FALSE,
  tv_sigma = FALSE,
  prior_sigma_omega_rate = 0.1,
  prior_tau_phi_rate = 0.025,
  prior_tau_sigma_rate = 0.05,
  tv_sigma_k = 8,
  method = c("indicator", "naive")
)
}
\arguments{
\item{data}{A data frame with time series of indicator variables.}

\item{indicators}{A list of two character vectors, each naming J indicator
columns per latent variable.}

\item{J}{Number of indicators per latent variable.}

\item{lambda}{Numeric vector of length J with fixed factor loadings.}

\item{sigma_e}{Fixed measurement error SD (scalar).}

\item{margins}{Latent innovation margin specification. A single string
applies the same family to both latent variables. Normal and exponential
use specialised Stan data contracts; skew-normal, gamma, and length-2
per-variable specs use the generic \code{sem_mixed} / \code{sem_naive_mixed} Stan
model with per-dimension family codes.}

\item{skew_direction}{Integer vector of length 2 of +1/-1. Required whenever
any dimension uses an \code{"exponential"} or \code{"gamma"} margin.}

\item{time_var}{Name of the time column (default: \code{"time"}).}

\item{prior_mu_sd}{Prior SD for intercepts.}

\item{prior_phi_sd}{Prior SD for VAR coefficients.}

\item{prior_sigma_sd}{Prior SD for the lognormal prior on the latent
innovation scale parameter.}

\item{prior_rho_sd}{Prior SD for rho_raw.}

\item{tv_phi}{Selects which latent VAR(1) coefficients vary over time.
See \code{\link[=dcvar]{dcvar()}} for accepted selectors.}

\item{tv_sigma}{Logical; if \code{TRUE}, latent innovation scales evolve over time.}

\item{prior_sigma_omega_rate}{Prior mean for the Fisher-z rho random-walk SD
used by TV SEM fits.}

\item{prior_tau_phi_rate}{Prior mean for Phi random-walk innovation SDs.}

\item{prior_tau_sigma_rate}{Prior mean for log-scale random-walk SDs.}

\item{tv_sigma_k}{Soft-barrier sharpness for time-varying exponential/gamma
scales.}

\item{method}{Character string: \code{"indicator"} for the fixed measurement
model or \code{"naive"} for row-mean factor scores.}
}
\value{
A named list suitable as Stan data input.
}
\description{
Transforms a data frame of indicator variables into a list suitable for
the SEM copula Stan model. The measurement model parameters (lambda,
sigma_e) are fixed and passed through to Stan.
}
