Skip to contents

Turns a fitted flexyBayes object into a log-posterior producer: a vectorised, domain-safe, unnormalised log-posterior callable that proxymix::from_fb_posterior() compresses into a closed-form Gaussian-mixture proxy. It is the single inference-result outflow from flexyBayes, the contract is the log-density, not the draws, so the returned object is addressed purely through its callable.

Usage

fb_log_posterior(fit, ...)

# Default S3 method
fb_log_posterior(fit, ...)

# S3 method for class 'flexybayes_brms'
fb_log_posterior(fit, ...)

# S3 method for class 'flexybayes_inla'
fb_log_posterior(fit, ...)

Arguments

fit

A fitted flexyBayes object. Every current backend class abstains, the generic and its methods are retained so a consumer can dispatch on the abstention instead of discovering the gap by a missing method.

...

Reserved for future producer options. Currently unused.

Value

Does not return on any current backend: it raises a classed fb_c4_unavailable condition naming the backend and the reason.

Details

The returned value is a bare callable function(theta_matrix) -> numeric. Its input is a numeric matrix whose rows index independent parameter draws and whose columns index parameters, in attr(., "parameter_names") order, on the natural (constrained) scale. Its output is a length-nrow(theta_matrix) numeric vector of log p(theta | data) + const (unnormalised). The callable is vectorised, side-effect free, and domain-safe: a row outside the parameters' support returns -Inf instead of raising an error (the consumer probes it at construction). It carries, as attributes:

parameter_names

Character vector naming the parameters. Its length fixes the proxy's ambient dimension. Vector-valued targets are flattened in column-major order with index suffixes (e.g. beta[1,1], beta[2,1]).

log_normalizer

The log normalising constant log Z, the log of the integral of the unnormalised density. For a posterior this is the log marginal likelihood, generally unknown, so this is NA_real_ and the consumer reports a shifted (not absolute) divergence.

support_lower, support_upper

Length-n_dim numeric support bounds taken from the model's parameter constraints (NA for an unbounded coordinate). A variance / scale parameter is bounded below by zero, for instance. Used only to centre and scale the consumer's default importance proposal.

draws

An n by n_dim numeric matrix of the fit's posterior draws on the natural scale, column-aligned to parameter_names. Used only to seed the consumer's default proposal. Never required.

Backend support. No active backend produces a real C4 log-density today. The brms and INLA backends both abstain with an informative condition: brms's log-density lives on the Stan unconstrained scale with a version-fragile name mapping, and INLA's posterior is a deterministic approximation, not a sampling log-density. Abstaining is preferred to emitting a plausible-but-wrong log-density.

Acyclic note. A consumer such as proxymix uses this callable without depending on flexyBayes, flexyBayes does not list proxymix in Imports or Suggests. The cross-package demonstration lives in a separate integration harness, not in this package, preserving the acyclic dependency graph.

Lifecycle

No active backend produces a real C4 log-density. Both flexybayes_brms and flexybayes_inla fits abstain with the classed condition fb_c4_unavailable, for the reasons given above. The generic and its methods are retained so a consumer can dispatch on the abstention instead of discovering the gap by a missing method.

See also

proxymix::from_fb_posterior() for the consumer (compresses the returned callable into a Gaussian-mixture proxy).