glmertree()
to a cross-validated data setcross_validate_it.Rd
fit glmertree()
to a cross-validated data set
cross_validate_it(cv_obj, seed = 713, mod_formula, tuning_grid = NULL, ...)
vfold_cv—a v-fold cross-validated dataset from rsample::vfold_cv()
integer—starting seed
Formula—made from as.Formula()
. uppercase required :)
— either tuning grid e.g., from dials::grid_max_entropy()
or default grid (when tuning_grid = NULL
).
additional arguments to be passed to glmertree()
tibble—fit statistics (rmse, mae) for object
dat <- sim_multilevel()
example_split <- rsample::initial_split(dat)
example_train <- rsample::training(example_split)
example_test <- rsample::testing(example_split)
cv <- rsample::vfold_cv(data = example_train, v = 10)
ex_formula <-
Formula::as.Formula(
'outcome ~ small_1 |
(1 | id_vector) |
small_c_1 + small_c_2 + nuisance_1a + nuisance_c_1a'
)
tuning_grid <-
dials::grid_max_entropy(
maxdepth_par(maxdepth_min = 0L, maxdepth_max = 20L),
alpha_par(alpha_min = 0.10, alpha_max = 0.001),
trim_par(trim_min = 0.01, trim_max = 0.5),
size = 10
)
fitted <-
cross_validate_it(
cv_obj = cv,
seed = 713,
tuning_grid = tuning_grid,
mod_formula = ex_formula
)
#> cv index 1 complete
#> cv index 2 complete
#> cv index 3 complete
#> cv index 4 complete
#> cv index 5 complete
#> cv index 6 complete
#> cv index 7 complete
#> cv index 8 complete
#> cv index 9 complete
#> cv index 10 complete
#> hyperparameter index 1 complete
#> cv index 1 complete
#> cv index 2 complete
#> cv index 3 complete
#> cv index 4 complete
#> cv index 5 complete
#> cv index 6 complete
#> cv index 7 complete
#> cv index 8 complete
#> cv index 9 complete
#> cv index 10 complete
#> hyperparameter index 2 complete
#> cv index 1 complete
#> cv index 2 complete
#> cv index 3 complete
#> cv index 4 complete
#> cv index 5 complete
#> cv index 6 complete
#> cv index 7 complete
#> cv index 8 complete
#> cv index 9 complete
#> cv index 10 complete
#> hyperparameter index 3 complete
#> cv index 1 complete
#> cv index 2 complete
#> cv index 3 complete
#> cv index 4 complete
#> cv index 5 complete
#> cv index 6 complete
#> cv index 7 complete
#> cv index 8 complete
#> cv index 9 complete
#> cv index 10 complete
#> hyperparameter index 4 complete
#> cv index 1 complete
#> cv index 2 complete
#> cv index 3 complete
#> cv index 4 complete
#> cv index 5 complete
#> cv index 6 complete
#> cv index 7 complete
#> cv index 8 complete
#> cv index 9 complete
#> cv index 10 complete
#> hyperparameter index 5 complete
#> cv index 1 complete
#> cv index 2 complete
#> cv index 3 complete
#> cv index 4 complete
#> cv index 5 complete
#> cv index 6 complete
#> cv index 7 complete
#> cv index 8 complete
#> cv index 9 complete
#> cv index 10 complete
#> hyperparameter index 6 complete
#> cv index 1 complete
#> cv index 2 complete
#> cv index 3 complete
#> cv index 4 complete
#> cv index 5 complete
#> cv index 6 complete
#> cv index 7 complete
#> cv index 8 complete
#> cv index 9 complete
#> cv index 10 complete
#> hyperparameter index 7 complete
#> cv index 1 complete
#> cv index 2 complete
#> cv index 3 complete
#> cv index 4 complete
#> cv index 5 complete
#> cv index 6 complete
#> cv index 7 complete
#> cv index 8 complete
#> cv index 9 complete
#> cv index 10 complete
#> hyperparameter index 8 complete
#> cv index 1 complete
#> cv index 2 complete
#> cv index 3 complete
#> cv index 4 complete
#> cv index 5 complete
#> cv index 6 complete
#> cv index 7 complete
#> cv index 8 complete
#> cv index 9 complete
#> cv index 10 complete
#> hyperparameter index 9 complete
#> cv index 1 complete
#> cv index 2 complete
#> cv index 3 complete
#> cv index 4 complete
#> cv index 5 complete
#> cv index 6 complete
#> cv index 7 complete
#> cv index 8 complete
#> cv index 9 complete
#> cv index 10 complete
#> hyperparameter index 10 complete