Computes per-parameter effective sample size (ESS) and, when multiple runs are available, the upper limit of the Gelman-Rubin potential scale reduction factor (R-hat), using the coda package.
Arguments
- treeppl_out
A tibble produced by
tp_parse_mcmc(), in either long or wide format.
Value
A tibble with one row per parameter, containing:
- parameter
Parameter name.
- ess
Effective sample size, pooled across all runs.
- rhat_upper
Upper limit of the Gelman-Rubin R-hat statistic. Only computed when
treeppl_outcontains more than one run; otherwiseNA, with a message explaining why.
Details
Output produced from an unnamed return type in TreePPL (.tppl file) is not
supported and will raise an error, since there is no reliable way to
distinguish multiple parameters.
Examples
if (FALSE) { # \dontrun{
# CRBD model using MCMC
run_mcmc <- tp_run(
sampler = tp_compile(model = "crbd", method = "mcmc", iterations = 10),
data = tp_data(data_input = "crbd"),
n_runs = 2,
n_processes = 2
)
# tp_run() already returns the output of tp_parse_mcmc(), so we can call
# tp_mcmc_convergence() directly:
tp_mcmc_convergence(run_mcmc)
} # }