R/JAGS-formula.R
transform_scale_samples.RdTransforms posterior samples from standardized continuous
predictors back to the original scale. This function is used when predictors
were standardized during model fitting via the formula_scale parameter.
transform_scale_samples(fit, formula_scale = NULL)a fitted model object with formula_scale attribute, or
a matrix of posterior samples
nested list containing standardization information keyed by
parameter name. Each parameter entry contains scaling info (mean and sd) for
each standardized predictor, e.g., list(mu = list(mu_x1 = list(mean = 0, sd = 1))).
If fit is provided and has a formula_scale attribute, this will be used automatically.
transform_scale_samples returns posterior samples transformed
back to the original predictor scale.
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 \(\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: $$(-1)^{|extra|} \cdot \prod_{i \in extra} \mu_i / \prod_{i \in S_{scaled}} \sigma_i$$ where \(extra = S_{scaled} \setminus T_{scaled}\).