jointSelect {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
jointModel()
or models fits using traditionalModel()
. See more examples
in the Package
Vignette.
Usage
jointSelect(modelfits)
Arguments
modelfits |
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
jointModel()
or all withtraditionalModel().
If any of these checks fail, the function returns an error message.
Examples
data(greencrabData)
# 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 <- jointModel(data = greencrabData, family = "poisson",
p10priors = 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 <- jointModel(data = greencrabData, family = "negbin",
p10priors = c(1,20), q = TRUE, multicore = FALSE)
# Perform model selection
jointSelect(modelfits = list(fit.no.q$model, fit.q$model))