PSIS
PSIS.jl implements the Pareto smoothed importance sampling (PSIS) algorithm from Vehtari et al. [1].
Given a set of importance weights used in some estimator, PSIS both improves the reliability of the estimates by smoothing the importance weights and acts as a diagnostic of the reliability of the estimates.
See psis
for details.
Example
In this example, we use PSIS to smooth log importance ratios for importance sampling 30 isotropic Student $t$-distributed parameters using standard normal distributions as proposals.
using PSIS, Distributions
proposal = Normal()
target = TDist(7)
ndraws, nchains, nparams = (1_000, 1, 30)
x = rand(proposal, ndraws, nchains, nparams)
log_ratios = logpdf.(target, x) .- logpdf.(proposal, x)
result = psis(log_ratios)
┌ Warning: 9 parameters had Pareto shape values 0.7 < k ≤ 1. Resulting importance sampling estimates are likely to be unstable.
└ @ PSIS ~/work/PSIS.jl/PSIS.jl/src/core.jl:373
┌ Warning: 1 parameters had Pareto shape values k > 1. Corresponding importance sampling estimates are likely to be unstable and are unlikely to converge with additional samples.
└ @ PSIS ~/work/PSIS.jl/PSIS.jl/src/core.jl:376
PSISResult with 1000 draws, 1 chains, and 30 parameters
Pareto shape (k) diagnostic values:
Count Min. ESS
(-Inf, 0.5] good 7 (23.3%) 959
(0.5, 0.7] okay 13 (43.3%) 938
(0.7, 1] bad 9 (30.0%) ——
(1, Inf) very bad 1 (3.3%) ——
As indicated by the warnings, this is a poor choice of a proposal distribution, and estimates are unlikely to converge (see PSISResult
for an explanation of the shape thresholds).
When running PSIS with many parameters, it is useful to plot the Pareto shape values to diagnose convergence. See Plotting PSIS results for examples.