joint_select {eDNAjoint} | R Documentation |
Perform model selection using leave one out cross validation of model objects
Description
This function performs leave one out cross validation of a list of model
fits using functions in the loo
package, as described in Vehtari, Gelman,
and Gabry (2017) doi:10.1007/s11222-016-9696-4. Compare models fit using
joint_model()
or models fits using traditional_model()
. See more examples
in the Package
Vignette.
Usage
joint_select(model_fits)
Arguments
model_fits |
A list containing model fits of class |
Value
A matrix of delta elpd (expected log pointwise predictive density)
between model fits. Function is performed using the loo
package.
Note
Before model selection, this function makes the following check:
Input is a list of model fits of class 'stanfit'.
All models compared were fit wither either
joint_model()
or all withtraditional_model().
If any of these checks fail, the function returns an error message.
Examples
data(green_crab_data)
# Fit a model without estimating a gear scaling coefficient for traditional
# survey gear types.
# This model assumes all traditional survey methods have the same
# catchability.
# Count data is modeled using a poisson distribution.
fit_no_q <- joint_model(data = green_crab_data, family = "poisson",
p10_priors = c(1,20), q = FALSE, multicore = FALSE)
# Fit a model estimating a gear scaling coefficient for traditional
# survey gear types.
# This model does not assume all traditional survey methods have the
# same catchability.
# Gear type 1 is used as the reference gear type.
# Count data is modeled using a negative binomial distribution.
fit_q <- joint_model(data = green_crab_data, family = "negbin",
p10_priors = c(1,20), q = TRUE, multicore = FALSE)
# Perform model selection
joint_select(model_fits = list(fit_no_q$model, fit_q$model))