Estimate Pareto k value by fitting a Generalized Pareto Distribution to one or two tails of x. This can be used to estimate the number of fractional moments that is useful for convergence diagnostics. For further details see Vehtari et al. (2022).
pareto_khat(x, ...)
# S3 method for default
pareto_khat(
x,
tail = c("both", "right", "left"),
r_eff = NULL,
ndraws_tail = NULL,
verbose = FALSE,
...
)
# S3 method for rvar
pareto_khat(x, ...)
(multiple options) One of:
A matrix of draws for a single variable (iterations x chains). See
extract_variable_matrix()
.
An rvar
.
Arguments passed to individual methods (if applicable).
(string) The tail to diagnose/smooth:
"right"
: diagnose/smooth only the right (upper) tail
"left"
: diagnose/smooth only the left (lower) tail
"both"
: diagnose/smooth both tails and return the maximum k-hat value
The default is "both"
.
(numeric) relative effective sample size estimate. If
r_eff
is omitted, it will be calculated assuming the draws are
from MCMC.
(numeric) number of draws for the tail. If
ndraws_tail
is not specified, it will be calculated as
ceiling(3 * sqrt(length(x) / r_eff)) if length(x) > 225 and
length(x) / 5 otherwise (see Appendix H in Vehtari et al. (2022)).
(logical) Should diagnostic messages be printed? If
TRUE
, messages related to Pareto diagnostics will be
printed. Default is FALSE
.
khat
estimated Generalized Pareto Distribution shape parameter k
Aki Vehtari, Daniel Simpson, Andrew Gelman, Yuling Yao and Jonah Gabry (2022). Pareto Smoothed Importance Sampling. arxiv:arXiv:1507.02646
mu <- extract_variable_matrix(example_draws(), "mu")
pareto_khat(mu)
#> $khat
#> [1] 0.1979001
#>
d <- as_draws_rvars(example_draws("multi_normal"))
pareto_khat(d$Sigma)
#> $khat
#> [,1] [,2] [,3]
#> [1,] 0.05601935 0.04156719 0.05091481
#> [2,] 0.04156719 0.10157218 0.06191862
#> [3,] 0.05091481 0.06191862 -0.08123058
#>