Implementation of Pareto smoothed importance sampling (PSIS), a method for stabilizing importance ratios. The version of PSIS implemented here corresponds to the algorithm presented in Vehtari, Simpson, Gelman, Yao, and Gabry (2022). For PSIS diagnostics see the pareto-k-diagnostic page.

# S3 method for brmsfit
psis(log_ratios, newdata = NULL, resp = NULL, model_name = NULL, ...)



A fitted model object of class brmsfit. Argument is named "log_ratios" to match the argument name of the loo::psis generic function.


An optional data.frame for which to evaluate predictions. If NULL (default), the original data of the model is used. NA values within factors are interpreted as if all dummy variables of this factor are zero. This allows, for instance, to make predictions of the grand mean when using sum coding.


Optional names of response variables. If specified, predictions are performed only for the specified response variables.


Currently ignored.


Further arguments passed to log_lik and loo::psis.


The psis() methods return an object of class "psis", which is a named list with the following components:


Vector or matrix of smoothed (and truncated) but unnormalized log weights. To get normalized weights use the weights() method provided for objects of class "psis".


A named list containing two vectors:

  • pareto_k: Estimates of the shape parameter \(k\) of the generalized Pareto distribution. See the pareto-k-diagnostic page for details.

  • n_eff: PSIS effective sample size estimates.

Objects of class "psis" also have the following attributes:


Vector of precomputed values of colLogSumExps(log_weights) that are used internally by the weights method to normalize the log weights.


Vector of tail lengths used for fitting the generalized Pareto distribution.


If specified, the user's r_eff argument.


Integer vector of length 2 containing S (posterior sample size) and N (number of observations).


Method used for importance sampling, here psis.


Vehtari, A., Gelman, A., and Gabry, J. (2017). Practical Bayesian model evaluation using leave-one-out cross-validation and WAIC. Statistics and Computing. 27(5), 1413--1432. doi:10.1007/s11222-016-9696-4 (journal version, preprint arXiv:1507.04544).

Vehtari, A., Simpson, D., Gelman, A., Yao, Y., and Gabry, J. (2022). Pareto smoothed importance sampling. preprint arXiv:1507.02646


if (FALSE) {
fit <- brm(rating ~ treat + period + carry, data = inhaler)