Skip to contents

The average over draws happens INSIDE the log, once per observation, and only then are observations summed. Computed through a log-sum-exp.

Usage

Lppd(logdens)

Arguments

logdens

Matrix, row s column i holding log p(y_i | theta^s).

Value

List with lppd, p_waic, elpd_waic, waic, pointwise_lppd, pointwise_var, S, n.

Details

Formula: lppd = sum_i log( (1/S) sum_s p(y_i | theta^s) ); p_waic = sum_i var_s( log p(y_i | theta^s) ); elpd_waic = lppd - p_waic; WAIC = -2 elpd_waic

References

Gelman, Carlin, Stern, Dunson, Vehtari & Rubin (2013), Bayesian Data Analysis, 3rd edition, Section 7.2, equation (7.5).

Examples

V <- c(1, 2, 3, 4, 5, 6, 7, 8)
Lppd(V)
#> $lppd
#> [1] 6.378898
#> 
#> $p_waic
#> [1] 6
#> 
#> $elpd_waic
#> [1] 0.3788981
#> 
#> $waic
#> [1] -0.7577962
#> 
#> $pointwise_lppd
#> [1] 6.378898
#> 
#> $pointwise_var
#> [1] 6
#> 
#> $S
#> [1] 8
#> 
#> $n
#> [1] 1
#> 
#> $method
#> [1] "lppd and WAIC, BDA3 Section 7.2 equation (7.5)"
#> 
#> attr(,"class")
#> [1] "morie_rich_result" "list"