Weights of several fitted models for combining their predictions, by
stacking of their leave-one-site-out predictive densities (Yao et al.
2018), or by pseudo-BMA. A thin wrapper of loo::loo_model_weights()
that accepts fits or loo() results.
Usage
fp_loo_weights(..., method = c("stacking", "pseudobma"))Arguments
- ...
Named
fp_occuorfp_occu_rnfits, or the results ofloo()on them.- method
"stacking"(default) or"pseudobma".
References
Yao, Y., Vehtari, A., Simpson, D., & Gelman, A. (2018). Using stacking to average Bayesian predictive distributions. Bayesian Analysis, 13, 917–1007. doi:10.1214/17-BA1091
Examples
# \donttest{
sim <- simulate_fp(nsite = 200, nocc = 10, conf_effect = 1.5,
conf_cor = 0.7, seed = 1)
m0 <- fp_occu(sim$data, occ = ~ x, fp = ~ 1, random_recorder = FALSE,
chains = 2, threads_per_chain = 1)
#> Running MCMC with 2 parallel chains, with 1 thread(s) per chain...
#>
#> Chain 1 finished in 16.7 seconds.
#> Chain 2 finished in 21.8 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 19.2 seconds.
#> Total execution time: 21.9 seconds.
#>
m1 <- fp_occu(sim$data, occ = ~ x, fp = ~ x, random_recorder = FALSE,
chains = 2, threads_per_chain = 1)
#> Running MCMC with 2 parallel chains, with 1 thread(s) per chain...
#>
#> Chain 1 finished in 19.1 seconds.
#> Chain 2 finished in 20.8 seconds.
#>
#> Both chains finished successfully.
#> Mean chain execution time: 19.9 seconds.
#> Total execution time: 20.9 seconds.
#>
fp_loo_weights(constant = m0, fp_on_x = m1)
#> constant fp_on_x
#> 0.1786987 0.8213013
# }