Using psis in loo for "regularizing" ratios

Hi all,

I find the documentation of psis confusing (it’s probably me, not the doc).

Suppose I have two vectors of samples v1, v2 and I construct the ratio of r = v1/v2 and my goal is to “regularize” this ratio through Pareto smoothing. How should I use psis and weights to get a smoothed version of r?

r <- v1/v2
log_ratios <- log(r)
psis_result <- psis(log_ratios)
nlw <- weights(psis_result, log=TRUE, normalize = TRUE) 
r_smoothed <- exp(as.vector(nlw))*sum(r)

Is r_smoothed the right thing to consider? I guess I am having problems where the normalization happens…

Later I will also extend this to use relative_eff, but for the sake of this example let’s ignore it.

Check out the E_loo function in the loo package.

How does this help me in smoothening the ratios (weights)? Just to make sure: I don’t want moments or quintiles w.r.t. to the ratios (weights) but the smoothened ratios (weights)

Is the attribute norm_const_log internally used to normalize the raw weights before smoothing is done or afterwards?

(Edit:) Answer: No. It is applied to the smoothened weights.

I think the E_loo suggestion worked for me, since after smoothing the ratios (weights) I still want to use them to weight another sequence of samples, extracting mean and quantiles. It appears that E_loo really works with the smoothened weights and does not do any internal normalization bringing the ratios to another scale.