This function compares multiple Bayesian models using PSIS-LOO (Pareto-smoothed importance sampling leave-one-out cross-validation)
from the loo package. It returns a comparison table and a plot of the estimated ELPD (expected log predictive density) with standard errors.
compare_models_loo(..., k = 0.7, name_log = "log_lik")A list with the following elements:
p_looA ggplot object showing elpd_loo values and standard errors for each model.
comparisonA loo_compare table comparing the relative fit of the models.
models_looA named list of individual loo objects for each model.
Two or more stanfit model objects to compare. Each model must include pointwise log-likelihood values (usually named log_lik) stored in the generated quantities or transformed parameters block.
A numeric value specifying the Pareto-k diagnostic threshold. Default is 0.7.
A character string specifying the name of the log-likelihood parameter in the model. Default is "log_lik".
This function performs PSIS-LOO diagnostics on each model, creates a visual summary, and ranks them using loo_compare.
Ensure that each model includes pointwise log-likelihood values named consistently (e.g., "log_lik").