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

elpd

Generic (expected) log-predictive density


Description

The elpd() methods for arrays and matrices can compute the expected log pointwise predictive density for a new dataset or the log pointwise predictive density of the observed data (an overestimate of the elpd).

Usage

elpd(x, ...)

## S3 method for class 'array'
elpd(x, ...)

## S3 method for class 'matrix'
elpd(x, ...)

Arguments

x

A log-likelihood array or matrix. The Methods (by class) section, below, has detailed descriptions of how to specify the inputs for each method.

...

Currently ignored.

Details

The elpd() function is an S3 generic and methods are provided for 3-D pointwise log-likelihood arrays and matrices.

Methods (by class)

  • array: An I by C by N array, where I is the number of MCMC iterations per chain, C is the number of chains, and N is the number of data points.

  • matrix: An S by N matrix, where S is the size of the posterior sample (with all chains merged) and N is the number of data points.

See Also

The vignette Holdout validation and K-fold cross-validation of Stan programs with the loo package for demonstrations of using the elpd() methods.

Examples

# Calculate the lpd of the observed data
LLarr <- example_loglik_array()
elpd(LLarr)

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.