Trouble using loo::psis for importance sampling

To make computations more stable we subtract the maximum log_r before exponentiating required by Pareto fit. In this case

> max(log_r)  #[1] 5.217747

We don’t add that back, but you can get what you want by

log_w = weights(out,log=TRUE,normalize=FALSE)  + max(log_r)
lm(log_w~log_r)
mean(exp(log_r)) #[1] 0.9603866
mean(exp(log_w)) #[1] 0.9625504

Normalized weights sum to 1.

log_w = weights(out,log=TRUE,normalize=TRUE)  
sum(exp(log_r)) #[1] 9603.866
sum(exp(log_w)) #[1] 1
3 Likes