% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/JAGS-formula.R
\name{transform_scale_samples}
\alias{transform_scale_samples}
\title{Transform standardized posterior samples back to original scale}
\usage{
transform_scale_samples(fit, formula_scale = NULL)
}
\arguments{
\item{fit}{a fitted model object with \code{formula_scale} attribute, or
a matrix of posterior samples}

\item{formula_scale}{nested list containing standardization information keyed by
parameter name. Each parameter entry contains scaling info (mean and sd) for
each standardized predictor, e.g., \code{list(mu = list(mu_x1 = list(mean = 0, sd = 1)))}.
If \code{fit} is provided and has a \code{formula_scale} attribute, this will be used automatically.}
}
\value{
\code{transform_scale_samples} returns posterior samples transformed
back to the original predictor scale.
}
\description{
Transforms posterior samples from standardized continuous
predictors back to the original scale. This function is used when predictors
were standardized during model fitting via the \code{formula_scale} parameter.
}
\details{
The function transforms regression coefficients and intercepts
to account for predictor standardization using a combinatorial approach that
correctly handles interactions of any order.

For a k-way interaction between standardized predictors, the expansion of
\eqn{\prod_{i} (x_i - \mu_i)/\sigma_i} contributes to all lower-order terms.
The contribution to a target term T from a source term S (where T is a subset
of S's scaled components) is:
\deqn{(-1)^{|extra|} \cdot \prod_{i \in extra} \mu_i / \prod_{i \in S_{scaled}} \sigma_i}
where \eqn{extra = S_{scaled} \setminus T_{scaled}}.
}
\seealso{
\code{\link[=JAGS_formula]{JAGS_formula()}} \code{\link[=JAGS_fit]{JAGS_fit()}}
}
