pareto_smooth {posterior} | R Documentation |
Pareto smoothing
Description
Smooth the tail draws of x by replacing tail draws by order statistics of a generalized Pareto distribution fit to the tail(s). For further details see Vehtari et al. (2024).
Usage
pareto_smooth(x, ...)
## S3 method for class 'rvar'
pareto_smooth(x, return_k = FALSE, extra_diags = FALSE, ...)
## Default S3 method:
pareto_smooth(
x,
tail = c("both", "right", "left"),
r_eff = NULL,
ndraws_tail = NULL,
return_k = FALSE,
extra_diags = FALSE,
verbose = TRUE,
are_log_weights = FALSE,
...
)
Arguments
x |
(multiple options) One of:
|
... |
Arguments passed to individual methods (if applicable). |
return_k |
(logical) Should the Pareto khat be included in
output? If |
extra_diags |
(logical) Should extra Pareto khat diagnostics
be included in output? If |
tail |
(string) The tail to diagnose/smooth:
The default is |
r_eff |
(numeric) relative effective sample size estimate. If
|
ndraws_tail |
(numeric) number of draws for the tail. If
|
verbose |
(logical) Should diagnostic messages be printed? If
|
are_log_weights |
(logical) Are the draws log weights? Default is
|
Value
Either a vector x
of smoothed values or a named list
containing the vector x
and a named list diagnostics
containing numeric values:
-
khat
: estimated Pareto k shape parameter, and optionally -
min_ss
: minimum sample size for reliable Pareto smoothed estimate -
khat_threshold
: sample size specific khat threshold for reliable Pareto smoothed estimates -
convergence_rate
: Relative convergence rate for Pareto smoothed estimates
If any of the draws is non-finite, that is, NA
, NaN
, Inf
, or
-Inf
, Pareto smoothing will not be performed, and the original
draws will be returned and and diagnostics will be NA
(numeric).
References
Aki Vehtari, Daniel Simpson, Andrew Gelman, Yuling Yao and Jonah Gabry (2024). Pareto Smoothed Importance Sampling. Journal of Machine Learning Research, 25(72):1-58. PDF
See Also
pareto_khat
for only calculating khat, and
pareto_diags
for additional diagnostics.
Examples
mu <- extract_variable_matrix(example_draws(), "mu")
pareto_smooth(mu)
d <- as_draws_rvars(example_draws("multi_normal"))
pareto_smooth(d$Sigma)