Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

psis_approximate_posterior

Diagnostics for Laplace and ADVI approximations and Laplace-loo and ADVI-loo


Description

Diagnostics for Laplace and ADVI approximations and Laplace-loo and ADVI-loo

Usage

psis_approximate_posterior(
  log_p = NULL,
  log_g = NULL,
  log_liks = NULL,
  cores,
  save_psis,
  ...,
  log_q = NULL
)

Arguments

log_p

The log-posterior (target) evaluated at S samples from the proposal distribution (g). A vector of length S.

log_g

The log-density (proposal) evaluated at S samples from the proposal distribution (g). A vector of length S.

log_liks

A log-likelihood matrix of size S * N, where N is the number of observations and S is the number of samples from q. See loo.matrix() for details. Default is NULL. Then only the posterior is evaluated using the k_hat diagnostic.

cores

The number of cores to use for parallelization. This defaults to the option mc.cores which can be set for an entire R session by options(mc.cores = NUMBER). The old option loo.cores is now deprecated but will be given precedence over mc.cores until loo.cores is removed in a future release. As of version 2.0.0 the default is now 1 core if mc.cores is not set, but we recommend using as many (or close to as many) cores as possible.

  • Note for Windows 10 users: it is strongly recommended to avoid using the .Rprofile file to set mc.cores (using the cores argument or setting mc.cores interactively or in a script is fine).

save_psis

Should the "psis" object created internally by loo() be saved in the returned object? The loo() function calls psis() internally but by default discards the (potentially large) "psis" object after using it to compute the LOO-CV summaries. Setting save_psis=TRUE will add a psis_object component to the list returned by loo. Currently this is only needed if you plan to use the E_loo() function to compute weighted expectations after running loo.

...

For the loo.function() method and the loo_i() function, these are the data, posterior draws, and other arguments to pass to the log-likelihood function. See the Methods (by class) section below for details on how to specify these arguments.

log_q

Deprecated argument name (the same as log_g).

Value

If log likelihoods are supplied, the function returns a "loo" object, otherwise the function returns a "psis" object.

References

Vehtari, A., Gelman, A., and Gabry, J. (2017a). 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. (2019). Pareto smoothed importance sampling. preprint arXiv:1507.02646

See Also


loo

Efficient Leave-One-Out Cross-Validation and WAIC for Bayesian Models

v2.4.1
GPL (>= 3)
Authors
Aki Vehtari [aut], Jonah Gabry [cre, aut], Mans Magnusson [aut], Yuling Yao [aut], Paul-Christian Bürkner [aut], Topi Paananen [aut], Andrew Gelman [aut], Ben Goodrich [ctb], Juho Piironen [ctb], Bruno Nicenboim [ctb]
Initial release
2020-12-07

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.