Skip to contents

Compute Widely Applicable Information Criterion (WAIC).

Usage

# S3 method for class 'ratiod_fit'
waic(x, ...)

Arguments

x

A ratiod_fit object

...

Additional arguments passed to loo::waic

Value

A waic object

Details

Uses the same reconstructed pointwise log-likelihood as loo.ratiod_fit(); supported on the hmc, ess, sghmc, and vi backends and conditional on the fixed-effect linear predictor.

Examples

# \donttest{
sim <- sim_ratiod(n = 100, family = ratiod_poisson_gamma(), seed = 1)
fit <- tratio(y_num | y_denom ~ x1 + (1 | group), data = sim$data,
              family = ratiod_poisson_gamma(),
              control = list(iter = 1000, chains = 2, seed = 1))
# waic() warns when an observation's p_waic exceeds 0.4; loo() is then
# the estimate to report
waic(fit)
#> Warning: 
#> 7 (7.0%) p_waic estimates greater than 0.4. We recommend trying loo instead.
#> 
#> Computed from 1000 by 100 log-likelihood matrix.
#> 
#>           Estimate   SE
#> elpd_waic   -439.0 14.6
#> p_waic        13.0  1.9
#> waic         877.9 29.2
#> 
#> 7 (7.0%) p_waic estimates greater than 0.4. We recommend trying loo instead. 
loo(fit)
#> 
#> Computed from 1000 by 100 log-likelihood matrix.
#> 
#>          Estimate   SE
#> elpd_loo   -439.2 14.6
#> p_loo        13.2  2.0
#> looic       878.5 29.2
#> ------
#> MCSE of elpd_loo is 0.2.
#> MCSE and ESS estimates assume independent draws (r_eff=1).
#> 
#> All Pareto k estimates are good (k < 0.67).
#> See help('pareto-k-diagnostic') for details.
# }