R/JAGS-formula-coefficient-density.R
JAGS_formula_coefficient_transform.RdJAGS_formula_coefficient_transform() exposes the declared fixed-coefficient
transformation used by transform_scale_samples(). It records fitted
sources, original-scale targets, named source/output transforms, exact
nonzero dependencies, and parameter-map structural metadata.
JAGS_formula_prior_density() constructs the induced marginal prior measure
for one target, or for a weighted combination of targets, through
BayesTools' deterministic prior-density context and linear-density algebra.
The result can be passed directly to prior_density_ordinate(). Fitted
coefficient priors are raw; multiply_by belongs to their compiled formula
contribution. Original raw coefficients use
\(z'_j = \sum_k A_{jk} z_k m_k / m_j\) on one immutable fitted state.
Identical canonical multipliers cancel before division, including zero;
declared zero contributions require no irrelevant state. A different needed
zero denominator refuses the requested numeric vector, without row repair.
The numerical grid of a weighted combination resolves its narrowest
continuous component (64 knots per robust scale of its prior times its
absolute weight), except that a simple component whose demanded spacing is
below .Machine$double.eps times the largest absolute coordinate of the
combination's range cannot be represented on that grid. Such a component,
e.g. the weight of a centered predictor equal to its mean, is a point at its
mean and does not set the grid spacing; a component whose spacing the grid
can resolve does.
Finite matrix rows are static raw maps. Dynamic rows are entirely NA and
retain finite basis_matrix, canonical multipliers, true state dependencies,
and a raw_affine, contribution_affine, or unavailable prior recipe.
Compatible weighted requests share one context; declared point siblings may
add a constant offset. Incompatible recipes refuse with
"incompatible_prior_recipes"; unsupported stochastic denominators refuse
with "state_dependent_map". Unsupported dependence/products remain explicit.
Uncanceled subnormal static ratio weights retain their static classification,
but draw and declared-point evaluation use the original value-aware arithmetic.
Continuous laws whose reused scale cannot retain that map have reason
numerical_scale_unavailable; usable draws and certified point laws remain.
JAGS_formula_internal_coordinate_priors() returns exact scalar priors for
stochastic formula coordinates that are intentionally absent from the
ordinary fitted prior_list. Currently these are the independent beta
primitives used by compiled LKJ random-effect blocks.
JAGS_formula_internal_coordinate_priors(fit)
JAGS_formula_coefficient_transform(fit, parameter, target_scale = "original")
JAGS_formula_coefficient_transform_schema()
JAGS_formula_prior_density(
fit,
parameter,
target = NULL,
target_scale = "original",
context = NULL,
weights = NULL
)fitted object created by JAGS_fit().
scalar formula parameter name.
requested coefficient scale. The current schema supports
only "original".
exact target coordinate from the transformation object.
Supply exactly one of target and weights.
optional BayesTools prior-density context. This is useful for
product-space or conditional prior mixtures; when NULL, the fitted
prior_list is used.
named numeric vector of weights over target_names of the
transformation object; the density is that of the weighted combination
of those targets. Supply exactly one of target and weights.
JAGS_formula_coefficient_transform() returns a
BayesTools_formula_coefficient_transform list (schema version 4). Its
targets data frame has one row per original-scale target with the
structural_status, fixed_value and reason of the target, its
map_type ("identity": the target is its own fitted source, including a
log-transformed source with an exp output; "affine": a linear
combination of fitted sources; "exp_affine": exp of a linear combination
of identity and log-transformed sources; "state_dependent": a map requiring
fitted multiplier states; "unsupported": any other map),
and the support of the map (a list column of c(lower, upper):
c(0, Inf) for maps with an exp output and c(-Inf, Inf) otherwise; the
prior support of a target can be narrower).
JAGS_formula_coefficient_transform_schema() returns field descriptions.
JAGS_formula_prior_density() returns a prior_linear_density accepted by
prior_density_ordinate(). An unavailable density stops with an error of
class BayesTools_formula_prior_density_unavailable (also
BayesTools_formula_transform_unavailable) whose field reason names the
cause, e.g. "unknown_target", "missing_source_coordinates", or
"nonlinear_map" for a weighted combination with a target whose map is not
linear in the fitted coefficients. Declared measure limitations additionally
inherit BayesTools_formula_measure_unavailable; generic context/program
failures and numeric transformation failures retain their strict boundary.
Numeric refusal reasons include "zero_multiplier_denominator",
"missing_multiplier_state", and "nonfinite_transform". Formula-design 7,
unscale-design 2, and transform 4 require refitting older stored formats;
readers never reconstruct missing fitted declaration ownership.
A requested parameter without a persisted formula design stops with
BayesTools_formula_transform_unavailable and reason
"missing_formula_design", also when requested through either prior-density
route.
JAGS_formula_internal_coordinate_priors() returns a uniquely named list of
scalar prior() objects keyed by concrete fitted coordinate.