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
Observed likelihood factors. LOO and WAIC require a current
fit$log_lik_contract verifying observed-data conditional likelihood
factors. Latent augmented scores, approximate rank/cap diagnostics and
legacy fits without this contract are rejected. Directed cell marginals
do not factorize under nonzero or estimated residual dyad correlation;
joint dyad factors would be needed. Symmetric fits store each unordered
dyad once. Correct marginal predictive scores remain useful and readable
through read_log_lik() even when LOO or WAIC is unavailable.
Chunked log-lik portability. When a lame fit is run 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)
# chains = 1 keeps the example short; the default runs two chains and compares them
fit <- ame(YX_nrm$Y, Xdyad = YX_nrm$X, R = 0, dcor = FALSE,
nscan = 400, burn = 50, odens = 1,
save_log_lik = TRUE, verbose = FALSE, chains = 1)
if (requireNamespace("loo", quietly = TRUE)) {
loo_res <- loo::loo(fit)
print(loo_res)
}
#>
#> Computed from 400 by 9900 log-likelihood matrix.
#>
#> Estimate SE
#> elpd_loo -14414.6 70.6
#> p_loo 189.4 2.7
#> looic 28829.1 141.2
#> ------
#> MCSE of elpd_loo is 0.7.
#> MCSE and ESS estimates assume independent draws (r_eff=1).
#>
#> All Pareto k estimates are good (k < 0.62).
#> See help('pareto-k-diagnostic') for details.
# }