WAIC {BayesianTools} | R Documentation |
calculates the WAIC
WAIC(bayesianOutput, numSamples = 1000, ...)
bayesianOutput |
an object of class BayesianOutput. Must implement a log-likelihood density function that can return point-wise log-likelihood values ("sum" argument). |
numSamples |
the number of samples to calculate the WAIC |
... |
optional values to be passed on the the getSample function |
The WAIC is constructed as
The lppd (log pointwise predictive density), defined in Gelman et al., 2013, eq. 4 as
The value of p_{WAIC} can be calculated in two ways, the method used is determined by the
method
argument.
Method 1 is defined as,
The function requires that the likelihood passed on to BayesianSetup contains the option sum = T/F, with defaul F. If set to true, the likelihood for each data point must be returned.
Florian Hartig
Gelman, Andrew and Jessica Hwang and Aki Vehtari (2013), "Understanding Predictive Information Criteria for Bayesian Models," http://www.stat.columbia.edu/~gelman/research/unpublished/waic_understand_final.pdf.
Watanabe, S. (2010). "Asymptotic Equivalence of Bayes Cross Validation and Widely Applicable Information Criterion in Singular Learning Theory", Journal of Machine Learning Research, http://www.jmlr.org/papers/v11/watanabe10a.html.
bayesianSetup <- createBayesianSetup(likelihood = testDensityNormal, prior = createUniformPrior(lower = rep(-10,2), upper = rep(10,2))) # likelihood density needs to have option sum = FALSE testDensityNormal(c(1,1,1), sum = FALSE) bayesianSetup$likelihood$density(c(1,1,1), sum = FALSE) bayesianSetup$likelihood$density(matrix(rep(1,9), ncol = 3), sum = FALSE) # running MCMC out = runMCMC(bayesianSetup = bayesianSetup) WAIC(out)