% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data-preparation.R
\name{prepare_dcvar_data}
\alias{prepare_dcvar_data}
\title{Prepare data for the DC-VAR model}
\usage{
prepare_dcvar_data(
  data,
  vars,
  time_var = "time",
  standardize = TRUE,
  margins = "normal",
  skew_direction = NULL,
  prior_mu_sd = 2,
  prior_phi_sd = 0.5,
  prior_sigma_eps_rate = 1,
  prior_sigma_omega_rate = 0.1,
  prior_rho_init_sd = 1,
  allow_gaps = FALSE
)
}
\arguments{
\item{data}{A data frame with time series observations.}

\item{vars}{Character vector of two variable names to model.}

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

\item{standardize}{Logical; whether to z-score variables (default: \code{TRUE}).}

\item{margins}{Character string specifying the marginal distribution.
One of \code{"normal"} (default), \code{"exponential"}, \code{"skew_normal"}, or \code{"gamma"}.}

\item{skew_direction}{Integer vector of length D indicating skew direction
for asymmetric margins. Each element must be \code{1} (right-skewed) or \code{-1}
(left-skewed). Required for \code{"exponential"} and \code{"gamma"} margins.}

\item{prior_mu_sd}{Prior SD for intercepts: \code{mu ~ normal(0, prior_mu_sd)}.}

\item{prior_phi_sd}{Prior SD for VAR coefficients: \code{Phi ~ normal(0, prior_phi_sd)}.}

\item{prior_sigma_eps_rate}{Prior mean for innovation SDs:
\code{sigma_eps ~ exponential(1/prior_sigma_eps_rate)}. Default \code{1} gives
\code{exponential(1)} with prior mean 1.}

\item{prior_sigma_omega_rate}{Prior mean for rho process SD:
\code{sigma_omega ~ exponential(1/prior_sigma_omega_rate)}. Default \code{0.1} gives
\code{exponential(10)} with prior mean 0.1.}

\item{prior_rho_init_sd}{Prior SD for initial rho on Fisher-z scale.}

\item{allow_gaps}{Logical; if \code{FALSE} (default), interior missing values
cause an error. If \code{TRUE}, they produce a warning and are removed.}
}
\value{
A named list suitable as Stan data input.
}
\description{
Transforms a data frame into a list suitable for the DC-VAR Stan model.
Handles sorting, missing values, and optional standardization.
}
\section{Prior naming conventions}{

Parameters ending in \verb{_sd} specify normal prior standard deviations
(location parameters). Parameters ending in \verb{_rate} specify exponential
prior means (scale parameters), where the exponential rate is
\verb{1/prior_*_rate}. The constant and HMM models use \code{prior_z_rho_sd}
(normal prior on the Fisher-z scale), while the DC-VAR model uses
\code{prior_sigma_omega_rate} (exponential prior on the random-walk SD)
because the two quantities have fundamentally different roles.
}

