50% off: Unlimited data and AI learning.
State of Data and AI Literacy Report 2025

BAMBI (version 2.3.5)

waic.angmcmc: Watanabe-Akaike Information Criterion (WAIC) for angmcmc objects

Description

Watanabe-Akaike Information Criterion (WAIC) for angmcmc objects

Usage

# S3 method for angmcmc
waic(x, ...)

Value

Computes the WAIC for a given angmcmc object.

Arguments

x

angmcmc object.

...

additional model specific arguments to be passed to waic from loo. For example, int.displ specifies integer displacement in wnorm and wnorm2 models. See fit_wnormmix and fit_wnorm2mix for more details.

Details

Given a deviance function D(η)=2log(p(y|η)), and an estimate η=(ηi)/n of the posterior mean E(η|y), where y=(y1,...,yn) denote the data, η is the unknown parameter vector of the model, η1,...,ηN are MCMC samples from the posterior distribution of η given y and p(y|η) is the likelihood function, the Watanabe-Akaike Information Criterion (WAIC) is defined as WAIC=LPPDpW where LPPD=i=1nlog(N1s=1Np(yi|ηs)) and (form 1 of) pW=2i=1n[log(N1s=1Np(yi|ηs))N1s=1Nlogp(yi|ηs)]. An alternative form (form 2) for pW is given by pW=i=1nvar^logp(yi|η) where for i=1,...,n, var^logp(yi|η) denotes the estimated variance of logp(yi|η) based on the realizations η1,...,ηN.

Note that waic.angmcmc calls waic for computation. If the likelihood contribution of each data point for each MCMC iteration is available in object (can be returned by setting return_llik_contri = TRUE) during fit_angmix call), waic.array is used; otherwise waic.function is called. Computation is much faster if the likelihood contributions are available - however, they are very memory intensive, and by default not returned in fit_angmix.

Examples

Run this code
# illustration only - more iterations needed for convergence
fit.vmsin.20 <- fit_vmsinmix(tim8, ncomp = 3, n.iter =  20,
                             n.chains = 1, return_llik_contri = TRUE)
library(loo)
waic(fit.vmsin.20)

Run the code above in your browser using DataLab