Skip to contents

Compute leave-one-out cross-validation using Pareto-smoothed importance sampling (PSIS-LOO).

Usage

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

Arguments

x

A ratiod_fit object

...

Additional arguments passed to loo::loo

Value

A loo object

Details

The pointwise log-likelihood is reconstructed from the posterior draws and the model (see ratiod_compare()); it works on any fit produced by the hmc, ess, sghmc, or vi backend, for every family including the zero-inflated, one-inflated and hurdle ones. Each observation's likelihood is evaluated at the full linear predictor: fixed, random and structured effects.

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))
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.
# }