R/hypothesis-linear-target.R
hypothesis_linear_target.RdWhen structured quantity labels are available, hypothesis tables display the compiled combination's label rather than its internal scalar name. Compiles point and simple region statements that all refer to one linear combination \(t = \sum_l c_l L_l\) of levels \(L_l\) of the same parameter of one marginal posterior, e.g. a difference of two levels, a scaled level, or a weighted average of several levels. The returned scalar marginal posterior of \(t\) retains the exact joint-prior density and the structural conditioning metadata needed by downstream inference methods (e.g. precomputed posterior-ordinate estimators that need the combined linear weights).
Every referenced level must have one fixed named linear-weight row over the
fitted coordinates and a declared posterior-atom status, and the levels
must share a joint prior context and conditioning event. The prior density
of \(t\) is the joint-context density at the combined weights
\(\sum_l c_l w_l\) shifted by the combined level offsets: on the fitted
scale it equals parameter_prior_density() at those coordinate weights,
and on the original scale of scaled formula coefficients
JAGS_formula_prior_density() with the corresponding weights. It must be
atom-free; by absolute continuity the posterior of \(t\) is then
atom-free as well. Affine transformations already applied to the marginal
levels retain their scale and offset; nonlinear transformed marginal levels,
nonlinear expressions, row-varying level weights, and statements about
different combinations are rejected.
hypothesis_linear_target(posterior, hypothesis, parameter)a factor-like marginal posterior containing the referenced levels.
hypothesis text or a BayesTools_hypothesis_ast. Each
side is a point statement (=, !=) or a simple comparison (<, <=,
>, >=) whose expressions are linear in the level references: sums and
differences of level references and numbers, level references multiplied
or divided by numbers, and parentheses.
exact parameter root used by the level references.
A list with posterior, hypothesis, parameter, and weights.
posterior is a scalar marginal_posterior of the linear combination
whose draw metadata (posterior_metadata()) hold the combined
linear_weights and linear_offset, its prior_density and
prior_context, declared (empty) atoms, the condition of the
levels, and, when the levels carry label parts, quantities labelling
the target by the combination of the levels' labels (e.g.
(mu) 2*f[A] - f[C], see parameter_labels()); hypothesis is an equivalent AST written against that scalar
target, parameter its name, and weights the combined linear weights.
A target that cannot be certified stops with an error of class
BayesTools_linear_target_unavailable (also
BayesTools_hypothesis_target) whose field reason is
"posterior_atoms" (the target's prior is not structurally atom-free),
"atom_declarations" (a level lacks its posterior-atom declaration),
"prior_context" (no valid joint prior context, including level weights
on columns the joint prior context does not contain), "weight_space"
(the levels' linear weights are in different weight spaces), or
"component_alignment" (the repeated mixture component keys of the
levels do not match the original posterior rows). A reference to a
level that posterior does not contain stops with an error of class
BayesTools_parameter_not_found (also
BayesTools_parameter_resolution_error), as in hypothesis_BF().
A translated threshold is the correctly rounded quotient of the statement's
value and divisor. Numerical loss in coefficients, or a threshold quotient
that is not finite, underflows or is subnormal, stops with
BayesTools_hypothesis_numerical_unavailable (also
BayesTools_hypothesis_ordinate, BayesTools_numerical_unavailable, and
BayesTools_numerical_condition). Unrepresentable target units are
unavailable; the compiler does not round or clamp them into a valid target.