![](../logo.png)
Run k-fold cross-validation
run_kfold_cv.Rd
This function performs k-fold cross-validation using the appropriate model
development function based on the class of the ermod
object.
Value
A kfold_cv_ermod
class object containing the fitted models and
holdout predictions for each fold.
Examples
# \donttest{
data(d_sim_binom_cov_hgly2)
ermod_bin <- dev_ermod_bin(
data = d_sim_binom_cov_hgly2,
var_resp = "AEFLAG",
var_exposure = "AUCss_1000",
var_cov = "BHBA1C_5",
# Settings to make the example run faster
chains = 2,
iter = 1000
)
cv_results <- run_kfold_cv(ermod_bin, k = 3, seed = 123)
print(cv_results)
#>
#> ── k-fold Cross-Validation for ermod object ────────────────────────────────────
#> ℹ Number of folds: 3
#>
#> ── Structure of the object: ──
#>
#> • $l_ermod: list of ermod objects
#> • $d_truth: data frame with true response values
#> • $d_sim: data frame with holdout predictions
# }