Learn R Programming

eDNAjoint (version 0.3.3)

joint_select: 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)

Value

A matrix of delta elpd (expected log pointwise predictive density) between model fits. Function is performed using the loo package.

Arguments

model_fits

A list containing model fits of class stanfit.

Examples

Run this code
# \donttest{
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))
# }

Run the code above in your browser using DataLab