Construct and inspect posterior-density and posterior-ordinate attributes in the schema consumed by Savage_Dickey_BF and hypothesis_BF.

posterior_density_attribute(
  x,
  y,
  method,
  density_method,
  diagnostics = NULL,
  support = NULL,
  ...
)

posterior_ordinate_attribute(
  value,
  ordinate,
  method,
  density_method,
  diagnostics = NULL,
  ...
)

posterior_ordinate_append(existing, ordinate)

posterior_ordinate_supports_bf(ordinate, validator = NULL)

posterior_ordinate_has_value(ordinate, value)

Arguments

x

numeric density grid locations. Heights at repeated locations are averaged when the attribute is read.

y

numeric density grid heights.

method

estimator label stored in the attribute.

density_method

public density method label stored in the attribute.

diagnostics

optional estimator diagnostics.

support

optional exact support metadata for the density scale, created with posterior_support_attribute(). KDE boundary reflection uses only interval-capable support; support with exact = FALSE (plotting or integration limits rather than true support boundaries) is not used to exclude a null hypothesis.

...

additional named metadata fields, for example parameter, conditional, or conditional_rule.

value

numeric null-hypothesis value or values.

ordinate

for posterior_ordinate_attribute(), numeric posterior ordinate height or heights; for posterior_ordinate_append(), a posterior-ordinate attribute to append.

existing

existing posterior-ordinate attribute or NULL.

validator

optional function for stricter method-specific BF support checks. It is called only after the generic BayesTools schema is valid.

Value

posterior_density_attribute() returns a list suitable for the posterior_density metadata of posterior draws (posterior_metadata()).

posterior_ordinate_attribute() returns a list suitable for the posterior_ordinate metadata of posterior draws (posterior_metadata()).

posterior_ordinate_append() returns a posterior-ordinate attribute container that may hold multiple ordinates.

posterior_ordinate_supports_bf() and posterior_ordinate_has_value() return scalar logical values.

Details

Additional metadata must be named and cannot replace structural schema fields. Posterior ordinate values are unique so a point-null lookup maps to at most one stored ordinate. When a validator is supplied to posterior_ordinate_supports_bf(), it is applied to matching ordinate entries rather than to the multi-ordinate container as a whole. The support field is used to check whether exact support excludes a requested point-null value and, when a kernel-density fallback must be computed from posterior samples, to supply boundary reflection. It must describe the true posterior support on the same scale as x, not the finite range of an estimator grid.

The objects returned by these constructors are the only accepted posterior density and ordinate metadata: other objects set as posterior_density or posterior_ordinate metadata of posterior draws (posterior_metadata()) are rejected with an error. An unclassed list of such objects, named by parameter or level, can hold the metadata of several parameters or levels. The fields used to match the metadata to posterior samples are parameter, conditional, conditional_rule, and condition_key. Multi-ordinate matching validates the original attributes and filters each single attribute by its own parameter and condition metadata before exact-null lookup. Container metadata do not replace incompatible child metadata. Compatible entries at other null values remain relevant metadata and retain the existing refusal when the requested null is absent.

A stored density describes only the continuous part of the posterior: for a posterior with point masses, its heights integrate to the continuous mass. The point masses are the posterior atoms of the draws, which are declared only in their atoms metadata with posterior_atom_attribute(); densities do not carry point masses.