% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/JAGS-formula.R
\name{transform_prior_samples}
\alias{transform_prior_samples}
\title{Transform prior samples to original scale}
\usage{
transform_prior_samples(
  fit,
  n_samples = 10000,
  seed = NULL,
  formula_scale = NULL
)
}
\arguments{
\item{fit}{a fitted model object with \code{prior_list} and optionally
\code{formula_scale} attributes}

\item{n_samples}{number of samples to generate (default: 10000)}

\item{seed}{random seed for reproducibility (optional)}

\item{formula_scale}{optional nested list containing standardization information.
If not provided, extracted from \code{fit} attribute.}
}
\value{
A matrix of prior samples on the original (unscaled) scale, with
columns matching the structure of posterior samples.
}
\description{
Generate prior samples and transform them using the same
matrix transformation as posterior samples. This is the correct approach for
visualizing priors on the original (unscaled) scale, especially for the intercept
which depends on contributions from multiple coefficient priors.
}
\details{
When models use auto-scaling (standardizing predictors), the posterior
samples are on the standardized scale. To correctly visualize priors on the
original scale, we cannot simply apply a linear transformation to individual
priors because the intercept on the original scale is a weighted sum of
multiple priors:

\deqn{\beta_0^{orig} = \beta_0^* - \sum_i \frac{\mu_i}{\sigma_i} \beta_i^*}

This function generates samples from ALL priors simultaneously and applies
the same matrix transformation used for posterior samples, which correctly
handles the intercept and all other parameters.
}
\examples{
# With a fitted model that used formula_scale:
# prior_samples <- transform_prior_samples(fit, n_samples = 10000)
# This can then be used with density() or for custom plotting

}
\seealso{
\code{\link[=transform_scale_samples]{transform_scale_samples()}} \code{\link[=plot_posterior]{plot_posterior()}}
}
