Compute the estimation diagnostics available for a fit: Cook's distance, per-observation
leverage, and observation influence (from the objective's Hessian at the fitted point) for
fit_map() and fit_gmm() fits; leverage, PSIS-LOO Pareto-k, and prior influence for
fit_bayesian() fits. Wraps the shared C++ Diagnostics layer (LeverageDiagnostics,
InfluenceDiagnostics, PriorInfluenceDiagnostics).
Arguments
- fit
a
corehydro_fitfromfit_map(),fit_bayesian(), orfit_gmm().fit_mle()fits are not supported:MaximumLikelihoodhas no posterior to diagnose.
Value
A named list. $cooks_distance and $leverage (one value per observation) and
$observation_influence (an observations-by-parameters matrix) are populated for
fit_map() and fit_gmm() fits. $pareto_k (one per observation), $max_pareto_k, and
$prior_influence/$prior_influence_names (one per parameter) are populated for
fit_bayesian() fits. Fields the fit's target does not support come back empty.
Details
Reruns the fit's own construct through the corresponding C++ diagnostics method rather than
reusing anything cached on fit – for a fit_bayesian() result this reproduces the identical
seeded chain (the construct carries the same explicit warmup/seed/... the original fit
used), so the diagnostics agree with the fit they were computed from.
Examples
peaks <- c(12500, 15300, 8900, 22100, 18700, 14200, 9800, 28500, 17400, 11600)
d <- fit_diagnostics(fit_map(model_univariate("Normal", peaks)))
d$cooks_distance
#> [1] 0 0 0 0 0 0 0 0 0 0