Learn R Programming

webSDM (version 1.1-5)

loo.trophicSDMfit: Computes an approximation of loo for the whole model

Description

Only works if method = 'stan_glm'. The global loo is computed by summing the loo of all the local models (since the likelihood factorises, the log-likelihood can be summed)This is an implementation of the methods described in Vehtari, Gelman, and Gabry (2017) and Vehtari, Simpson, Gelman, Yao, and Gabry (2019).

Usage

# S3 method for trophicSDMfit
loo(x, ...)

Value

The value of the loo for the whole model

Arguments

x

A trophicSDMfit object obtained with trophicSDM()

...

additional arguments

Author

Giovanni Poggiato

Examples

Run this code
data(Y, X, G)
# define abiotic part of the model
env.formula = "~ X_1 + X_2"
# Run the model with bottom-up control using stan_glm as fitting method and no penalisation
m = trophicSDM(Y,X,G, env.formula,
               family = binomial(link = "logit"), penal = NULL, iter = 50,
               mode = "prey", method = "stan_glm")
brms::loo(m)

Run the code above in your browser using DataLab