Learn R Programming

loo (version 2.1.0)

kfold-generic: Generic function for K-fold cross-validation for developers

Description

For developers of modeling packages, loo includes a generic function kfold so that methods may be defined for K-fold CV without name conflicts between packages. See, e.g., the kfold.stanreg method in rstanarm and the kfold.brmsfit method in brms.

Usage

kfold(x, ...)

is.kfold(x)

Arguments

x

A fitted model object.

...

Arguments to pass to specific methods.

Value

For developers defining a kfold method for a class "foo", the kfold.foo function should return a list with class c("kfold", "loo") with at least the elements

  • "estimates": a 1x2 matrix with column names "Estimate" and "SE" containing the ELPD estimate and its standard error.

  • "pointwise": an Nx1 matrix with column name "elpd_kfold" containing the pointwise contributions for each data point.