| tulpa_criteria | R Documentation |
Turn an [n_draws x n_obs] pointwise log-likelihood into the standard
Bayesian goodness-of-fit currency: WAIC, DIC, conditional predictive
ordinates (CPO) and their sum LPML, PSIS-LOO, all from one matrix. PSIS-LOO
reuses the native tulpa_psis() smoothing, so the CPO and LOO numbers are
the same computation (CPO_i = exp(elpd_loo_i), LPML = elpd_loo). The
input may be a matrix or a streaming tulpa_loglik() so EVA-scale fits are
processed in observation blocks.
tulpa_criteria(
log_lik,
criteria = c("waic", "loo", "cpo", "lpml", "dic"),
loglik_at_mean = NULL,
group = NULL,
chunk_size = NULL,
pointwise = FALSE
)
## S3 method for class 'tulpa_criteria'
print(x, digits = 1, ...)
log_lik |
An |
criteria |
Which criteria to compute. Any of |
loglik_at_mean |
Optional length- |
group |
Optional length- |
chunk_size |
Number of observation columns to process per block. The default streams the whole matrix at once when materialized, else picks a block sized to a few million entries. |
pointwise |
If |
x |
A |
digits |
Decimal places printed. |
... |
Ignored. |
p_waic is the well-known positively-biased variance estimator at low draw
counts; the result records n_draws and the count of observations with
p_waic_i > 0.4 (the loo heuristic for an unreliable WAIC), and the
PSIS-LOO elpd_loo is the more stable figure to report when that count is
non-trivial.
The LOO unit is whatever one column of log_lik holds. If the consumer
built the matrix with one column per row (plot / visit), the default is
per-row LOO; if a column already carries a whole group's compressed
likelihood, leaving it out drops that group and pareto_k can blow up by
construction. The group argument makes the unit explicit: supply it to
aggregate columns into folds and report leave-one-group-out CV (LOGO-CV)
instead, a different and deliberate estimand.
A tulpa_criteria object: a list with the requested scalar scores
(each estimate paired with its standard error where defined),
n_draws / n_obs, the PSIS pareto_k summary, and – when
pointwise = TRUE – a pointwise data frame.
Vehtari, Gelman & Gabry (2017). Practical Bayesian model evaluation using leave-one-out cross-validation and WAIC. Statistics and Computing 27(5):1413-1432. Watanabe (2010). Spiegelhalter et al. (2002). Geisser & Eddy (1979).
tulpa_psis() for the smoothing core, tulpa_pit() for the
probability-integral-transform companion, compare_models() for
model comparison.
# A draws x observations log-likelihood matrix (here built directly;
# in practice extracted from a fitted model's posterior draws).
set.seed(1)
y <- rnorm(40)
mu <- matrix(rnorm(200 * 40, sd = 0.2), 200, 40)
ll <- dnorm(matrix(y, 200, 40, byrow = TRUE), mean = mu, log = TRUE)
tulpa_criteria(ll)
tulpa_criteria(ll, criteria = "waic", pointwise = TRUE)$pointwise[1:3, ]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.