kfold.hsstan | R Documentation |
Perform K-fold cross-validation using the same settings used when fitting the model on the whole data.
## S3 method for class 'hsstan'
kfold(
x,
folds,
chains = 1,
store.fits = TRUE,
cores = getOption("mc.cores", 1),
...
)
x |
An object of class |
folds |
Integer vector with one element per observation indicating the cross-validation fold in which the observation should be withdrawn. |
chains |
Number of Markov chains to run. By default this is set to 1,
independently of the number of chains used for |
store.fits |
Whether the fitted models for each fold should be stored
in the returned object ( |
cores |
Number of cores to use for parallelization (the value of
|
... |
Further arguments passed to |
An object with classes kfold
and loo
that has a similar structure as the
objects returned by loo()
and waic()
and is compatible with the
loo_compare
function for
comparing models. The object contains the following fields:
estimates |
a matrix containing point estimates and standard errors of
the expected log pointwise predictive density ("elpd_kfold"),
the effective number of parameters ("p_kfold", always |
pointwise |
a matrix containing the pointwise contributions of "elpd_kfold", "p_kfold" and "kfoldic". |
fits |
a matrix with two columns and number of rows equal to the number
of cross-validation folds. Column |
data |
the dataset used in fitting the model (before withdrawing
observations). This is not present if |
# continued from ?hsstan
# only 2 folds for speed of example
folds <- rep(1:2, length.out=length(df$Y))
cv.biom <- kfold(hs.biom, folds=folds, cores=2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.