cross_validation {rSPDE} | R Documentation |
Perform cross-validation on a list of fitted models.
Description
Obtain several scores for a list of fitted models according to a folding scheme.
Usage
cross_validation(
models,
model_names = NULL,
scores = c("mse", "crps", "scrps", "dss"),
cv_type = c("k-fold", "loo", "lpo"),
k = 5,
percentage = 20,
number_folds = 10,
n_samples = 1000,
return_scores_folds = FALSE,
orientation_results = c("negative", "positive"),
include_best = TRUE,
train_test_indexes = NULL,
return_train_test = FALSE,
parallelize_RP = FALSE,
n_cores_RP = parallel::detectCores() - 1,
true_CV = FALSE,
save_settings = FALSE,
print = TRUE,
fit_verbose = FALSE
)
Arguments
models |
A fitted model obtained from calling the |
model_names |
A vector containing the names of the models to appear in the returned |
scores |
A vector containing the scores to be computed. The options are "mse", "crps", "scrps" and "dss". By default, all scores are computed. |
cv_type |
The type of the folding to be carried out. The options are |
k |
The number of folds to be used in |
percentage |
The percentage (from 1 to 99) of the data to be used to train the model. Will only be used if |
number_folds |
Number of folds to be done if |
n_samples |
Number of samples to compute the posterior statistics to be used to compute the scores. |
return_scores_folds |
If |
orientation_results |
character vector. The options are "negative" and "positive". If "negative", the smaller the scores the better. If "positive", the larger the scores the better. |
include_best |
Should a row indicating which model was the best for each score be included? |
train_test_indexes |
A list containing two entries |
return_train_test |
Logical. Should the training and test indexes be returned? If 'TRUE' the train and test indexes will the 'train_test' element of the returned list. |
parallelize_RP |
Logical. Should the computation of CRPS and SCRPS be parallelized? |
n_cores_RP |
Number of cores to be used if |
true_CV |
Should a |
save_settings |
Logical. If |
print |
Should partial results be printed throughout the computation? |
fit_verbose |
Should INLA's run during cross-validation be verbose? |
Value
A data.frame with the fitted models and the corresponding scores.