% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/diagnostics.R
\name{calculate_loo}
\alias{calculate_loo}
\title{Calculate LOO-CV for an mlumr_fit}
\usage{
calculate_loo(object, ...)
}
\arguments{
\item{object}{An \code{mlumr_fit} object.}

\item{...}{Additional arguments passed to \code{\link[loo:loo.array]{loo::loo.array()}}.}
}
\value{
An object of class \code{psis_loo} (see \code{\link[loo:loo]{loo::loo()}}).
}
\description{
Computes approximate leave-one-out cross-validation (PSIS-LOO, Vehtari,
Gelman, Gabry 2017) using the pointwise log-likelihoods stored by the
Stan models. Returns a \code{loo} object from the \code{loo} package.
}
\details{
Pareto-k diagnostics: values > 0.7 indicate observations for which the
PSIS approximation is unreliable; the printed output flags these.
Typical remedies are running more iterations, using \code{moment_match = TRUE},
or (for highly influential AgD rows) refitting without the offending
observation to check sensitivity.
}
\note{
\strong{AgD rows are treated as independent observations.} Each AgD row
contributes one column to the pointwise \code{log_lik} matrix. If two or
more AgD rows come from the same study (e.g. subgroup summaries
within a single trial) the PSIS-LOO approximation does not account
for the within-study clustering; effective sample sizes are
inflated and Pareto-k warnings are understated. For clustered AgD,
corroborate with \code{\link[=prior_sensitivity]{prior_sensitivity()}} or refit omitting suspect
rows to check the influence on the posterior.
}
\examples{
\dontrun{
loo_spfa <- calculate_loo(fit_spfa)
print(loo_spfa)
}
}
