Randomly partition data into K subsets of equal size (by site). Re-fit the model K times, each time leaving out one of the subsets. Calculate the log-likelihood for each of the sites that was left out. This function is an alternative to loo (leave-one-out cross validation).
## S4 method for signature 'ubmsFit'kfold(x, K =10, folds =NULL, quiet =FALSE,...)
Arguments
x: A ubmsFit model
K: Number of folds into which the data will be partitioned
folds: An optional vector with length equal to the number of sites in the data and containing integers from 1 to K, to manually assign sites to folds. You should use this if you plan to compare multiple models, since the folds for each model should be identical. You can use loo::kfold_split_random to generate this vector
quiet: If TRUE, suppress progress bar
...: Currently ignored
Returns
An object of class elpd_generic that is compatible with loo::loo_compare