Description Usage Arguments Details Value Examples
This function computes the waic described in Gelman et al. (2013) information criterion paper for multi-scale occupancy models.
1 |
msocc_mod |
output from |
type |
one of |
The authors of Gelman et al. (2013) note that the type 2 penalty is a
better representation of leave one out cross-validation, and therefore
recommend its use.
In the case of hierarchical models, they also note
that there are two ways to think the likelihood; one that incorporates the
hyper-parameters and one that does not. Both are arguably justifiable
depending upon the situation. We do not incorporate the hyper-parameters in
our calculations here.
numeric value that is the waic
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | data(fung)
# prep data
fung.detect <- fung %>%
dplyr::select(1:4)
site.df <- fung %>%
dplyr::select(-sample, -pcr1, -pcr2) %>%
dplyr::distinct(site, .keep_all = TRUE) %>%
dplyr::arrange(site)
sample.df <- fung %>%
dplyr::select(-pcr1, -pcr2) %>%
dplyr::arrange(site, sample)
# fit intercept model at all three levels use beta-binomial sampler
fung_mod1 <- msocc_mod(wide_data = fung.detect, progress = T,
site = list(model = ~ 1, cov_tbl = site.df),
sample = list(model = ~ 1, cov_tbl = sample.df),
rep = list(model = ~ 1, cov_tbl = sample.df), # covariates aggregated at sample level
num.mcmc = 1000, beta_bin = T)
# model sample level occurence by frog density
fung_mod2 <- msocc_mod(wide_data = fung.detect, progress = T,
site = list(model = ~ 1, cov_tbl = site.df),
sample = list(model = ~ frogs, cov_tbl = sample.df),
rep = list(model = ~ 1, cov_tbl = sample.df),
num.mcmc = 1000, beta_bin = T)
# compare
waic(fung_mod1)
waic(fung_mod2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.