View source: R/posterior_draws_joint.R
| tulpa_posterior_draws.tulpa_nested_laplace_joint | R Documentation |
The tulpa_posterior_draws() method for a joint nested-Laplace fit
(tulpa_nested_laplace_joint()). Each draw picks an outer-grid cell
k ~ Categorical(weights) and then samples the inner latent vector from the
constrained Gaussian N(m_k, V_k) at that cell, where m_k is the cell's
inner mode and V_k is the inner-Laplace covariance with the ICAR / BYM2
sum-to-zero field constraint imposed (conditioning by kriging). The draws
are i.i.d. samples from sum_k weights_k * N(m_k, V_k).
## S3 method for class 'tulpa_nested_laplace_joint'
tulpa_posterior_draws(fit, idx = NULL, n = 1000, ...)
fit |
A |
idx |
Optional integer vector of 1-based latent indices to return.
|
n |
Number of posterior draws (default 1000). |
... |
Unused; for S3 compatibility. |
The constrained draw at cell k uses the sparse Cholesky of the stored
precision Q_k and the conditioning-by-kriging correction
z_c = z - Q_k^{-1} A^\top (A Q_k^{-1} A^\top)^{-1} A z,
where z ~ N(0, Q_k^{-1}) and A stacks the field sum-to-zero rows (one for
an ICAR / CAR field; two – structured and unstructured – for a BYM2 field;
one per spatial block in a multi-block fit). The returned draw is
m_k + z_c, restricted to idx. Because m_k already satisfies the
constraint (the inner solve centres the field), the mean is left unchanged
and only the covariance is constrained, so the per-cell marginal matches the
inner-Laplace constrained covariance exactly.
Cells with zero outer-grid weight (e.g. pruned cells) or no stored Q are
dropped and the remaining weights renormalized. A degenerate single-cell
grid (quadrature ESS 1) returns draws from that cell's N(m_1, V_1).
A numeric matrix [n x length(idx)] of latent draws, one row per
draw, columns named x<idx>. Carries attr(., "draws_kind") = "iid"
(consistent with the draws-provenance gate), attr(., "cells") – the
outer-grid cell index each row was drawn from – attr(., "theta"), the
hyperparameter half of the same rows continuized within each row's own cell
(tulpa_hyper_draws()) – and attr(., "scope") = "latent".
tulpa_posterior_draws(), tulpa_nested_laplace_joint(),
posterior_sample()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.