| waic {loo} | R Documentation |
Widely applicable information criterion (WAIC)
waic(x, ...) ## S3 method for class 'matrix' waic(x, ...) ## S3 method for class 'function' waic(x, ..., args)
x |
A log-likelihood matrix or function. See the Methods (by class) section below for a detailed description. |
... |
Other arguments. Currently ignored. |
args |
Only required if |
A named list (of class 'loo') with components:
elpd_waic, se_elpd_waicexpected log pointwise predictive density and standard error
p_waic, se_p_waicestimated effective number of parameters and standard error
waic, se_waic-2 * elpd_waic (i.e., converted to the
deviance scale) and standard error
pointwisethe pointwise contributions of each of the above measures
matrix: An S by N matrix, where S is the size of the posterior
sample (the number of simulations) and N is the number of data points.
For example, the object returned by
extract_log_lik can be used.
function: A function f that takes arguments i, data,
and draws and returns a vector containing the log-likelihood for
the ith observation evaluated at each posterior draw.
The args argument must also be specified and should be a named list
with the following components:
draws: An object containing the posterior draws for any
parameters needed to compute the pointwise log-likelihood.
data: An object containing data (e.g. observed outcome and
predictors) needed to compute the pointwise log-likelihood. data
should be in an appropriate form so that f(i=i,
data=data[i,,drop=FALSE], draws=draws) returns the S-vector of
log-likelihoods for the ith observation.
N: The number of observations.
S: The size of the posterior sample.
compare, print.loo,
loo-package
## Not run: log_lik1 <- extract_log_lik(stanfit1) log_lik2 <- extract_log_lik(stanfit2) (waic1 <- waic(log_lik1)) (waic2 <- waic(log_lik2)) print(compare(waic1, waic2), digits = 2) ## End(Not run)