Bayesian estimation diagnostics (leverage / influence / prior influence)
Source:R/analysis.R
estimation_diagnostics.RdFit a univariate distribution to a sample with a Bayesian MCMC analysis and compute the three
estimation diagnostics: observation leverage (from the posterior Hessian at the MAP), PSIS-LOO
influence (per-observation Pareto-k), and prior influence (prior-vs-data log-likelihood share).
Wraps the shared C++ BayesianAnalysis diagnostics.
Usage
estimation_diagnostics(
data,
distribution,
sampler = "DEMCz",
iterations = 3000L,
output_length = 10000L,
seed = 12345L,
thinning_interval = -1L,
thin_every = 10L
)Arguments
- data
numeric vector of observations.
- distribution
distribution family name (any name the core distribution factory accepts).
- sampler
MCMC sampler:
"DEMCz"(default),"DEMCzs","ARWMH", or"NUTS".- iterations
number of post-warmup MCMC iterations.
- output_length
number of posterior samples retained.
- seed
PRNG seed for the sampler.
- thinning_interval
MCMC thinning interval;
-1(default) keeps the sampler's own default.- thin_every
prior-influence posterior thinning stride (default
10).
Value
A named list with three sub-lists: leverage (index, leverage, fit_influence,
variance_influence, value arrays; prior_leverage; total_leverage,
total_fit_influence, total_variance_influence), influence (pareto_k, elpd_loo arrays;
count, mean_pareto_k, max_pareto_k, count_pareto_k_above_05/_07/_10,
proportion_problematic, is_reliable), and prior_influence (count,
prior_precision_share, total_prior_log_likelihood, total_data_log_likelihood,
prior_to_data_ratio, is_prior_influential, mean_prior_precision_share).
Examples
peaks <- c(12500, 15300, 8900, 22100, 18700, 14200, 9800, 28500, 17400, 11600)
d <- estimation_diagnostics(peaks, "Normal", iterations = 100, output_length = 200,
seed = 12345, thinning_interval = 1)
d$influence$max_pareto_k
#> [1] 1.5