S3 method for loo that uses the per-iteration
pointwise log-likelihood stored on the fit object (fit$log_lik) when
the model was fit with save_log_lik = TRUE. Returns the standard
loo object with Pareto-k diagnostics.
Arguments
- x
A fitted
ameorlameobject that has$log_lik.- ...
Additional arguments forwarded to
loo::loo.matrix(e.g.cores,r_eff).
Details
What log_lik measures. For family in
{normal, binary, cbin, poisson, ordinal} the stored
pointwise log-likelihood is the exact family-specific Y density on
the response scale, so elpd_loo is directly comparable to a
loo() output from Stan / brms fit to the same family. For
the rank likelihood frn the exact marginal
needs GHK Monte Carlo (Halton sequence); on the longitudinal
lame() path you can opt in with log_lik_method =
"observed_ghk", on the cross-sectional ame() path the
fallback is the augmented-Z normal approximation (with a one-time
warning). Inspect fit$log_lik_method on any fit to see which
branch was used.
Chunked log-lik portability. When fit with
save_log_lik = "chunked", the on-disk chunk files default to
tempdir(), which is cleared at the end of the R session.
If you intend to saveRDS() the fit and reload it in a fresh
session, supply an explicit persistent log_lik_path (e.g.
"./loglik_chunks") so the chunks survive the round trip.
Examples
# \donttest{
data(YX_nrm)
fit <- ame(YX_nrm$Y, Xdyad = YX_nrm$X, R = 0,
nscan = 60, burn = 15, odens = 5,
save_log_lik = TRUE, verbose = FALSE)
if (requireNamespace("loo", quietly = TRUE)) {
loo_res <- loo::loo(fit)
print(loo_res)
}
#> Warning: Not enough tail samples to fit the generalized Pareto distribution in some or all columns of matrix of log importance ratios. Skipping the following columns: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ... [9890 more not printed].
#> Warning: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details.
#>
#> Computed from 12 by 9900 log-likelihood matrix.
#>
#> Estimate SE
#> elpd_loo -14389.4 70.7
#> p_loo 157.8 2.6
#> looic 28778.9 141.3
#> ------
#> MCSE of elpd_loo is NA.
#> MCSE and ESS estimates assume independent draws (r_eff=1).
#>
#> Pareto k diagnostic values:
#> Count Pct. Min. ESS
#> (-Inf, 0.07] (good) 0 0.0% <NA>
#> (0.07, 1] (bad) 0 0.0% <NA>
#> (1, Inf) (very bad) 9900 100.0% <NA>
#> See help('pareto-k-diagnostic') for details.
# }