| loo.clmstan | R Documentation |
Computes approximate leave-one-out cross-validation (LOO-CV) for a fitted cumulative link model using Pareto smoothed importance sampling (PSIS).
## S3 method for class 'clmstan'
loo(x, ..., r_eff = NULL, cores = getOption("mc.cores", 1), save_psis = FALSE)
x |
A |
... |
Additional arguments passed to |
r_eff |
A vector of relative effective sample sizes for each observation,
or |
cores |
The number of cores to use for parallel computation.
Defaults to |
save_psis |
If |
The function extracts the log-likelihood matrix (log_lik) computed in
the generated quantities block of the Stan model and passes it to
loo.
Pareto k diagnostics: Observations with high Pareto k values
(k > 0.7) indicate potential problems with the LOO approximation for those
observations. Use plot() on the returned object to visualize the
Pareto k values.
Model comparison: Use loo_compare to compare
multiple models. Models with higher elpd_loo are preferred.
An object of class c("psis_loo", "loo") containing:
estimates: A matrix with columns Estimate and SE
for elpd_loo, p_loo, and looic.
pointwise: A matrix with pointwise contributions.
diagnostics: A list with Pareto k values and effective
sample sizes for each observation.
waic.clmstan for WAIC computation,
loo for details on the LOO algorithm,
loo_compare for model comparison.
## Not run:
fit <- clm_stan(rating ~ temp, data = wine)
loo_result <- loo(fit)
print(loo_result)
plot(loo_result)
# Compare two models
fit1 <- clm_stan(rating ~ temp, data = wine, link = "logit")
fit2 <- clm_stan(rating ~ temp, data = wine, link = "probit")
loo::loo_compare(loo(fit1), loo(fit2))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.