Skip to contents

The following helpers extract elements of the list returned by run_mod_lm().

pull_mod_rank() extracts a tibble summarising the ranking of pre-processing steps measured according to rank_metric chosen in run_mod_lm().

pull_mod_best() extract the best model id.

pull_mod_coeff() extracts best model coefficient estimates.

pull_mod_fit() extracts the best model object.

pull_mod_coeff_all() extracts coefficients estimates referenced by year.

Usage

pull_mod_rank(mod_out_list)

pull_mod_best(rank_df)

pull_mod_coeff(mod_out_list)

pull_mod_fit(mod_out_list)

pull_mod_coeff_all(tbl, mod_const = tb_mod_const)

Arguments

mod_out_list

A list object as returned by run_mod_lm().

rank_df

A tibble as returned by pull_mod_rank().

tbl

Input data frame containing the data to model.

mod_const

Default models specs as returned by the list tb_mod_const.

Value

pull_mod_rank() returns a tibble.

pull_mod_best() returns a character of length one.

pull_mod_coeff() returns a tibble.

pull_mod_fit() returns an object of class _lm.

pull_mod_coeff_all() returns a tibble.

Examples

if (FALSE) {
preproc_list <- get_mod_preproc(
  .tbl = tbl,
  .neighbors = 5,
  .threshold = 0.25,
  .impute_with = c("gdp", "e_inc_num", "pop_total")
 )

mod_objects <- run_mod_lm(
  tbl,
  preproc = preproc_list,
  folds = 10,
  metrics = yardstick::metric_set(yardstick::rmse, yardstick::rsq),
  rank_metric = "rmse"
)
pull_mod_rank(mod_objects)
}
if (FALSE) {
pull_mod_rank(mod_objects) |>
  pull_mod_best()
}
if (FALSE) {
pull_mod_coeff(mod_objects)
}
if (FALSE) {
lm_obj <- pull_mod_fit(mod_objects)
plot_check <- performance::check_model(
  lm_obj,
  check = c("linearity", "normality", "qq", "outliers"),
  theme = "ggplot2::theme_minimal"
)
}
if (FALSE) {
tbl <-
  build_tbl(
    "tb",
    estimated = "who_estimates.e_inc_num",
    notified = "who_notifications.c_newinc",
    year = NULL,
    vars = extract_vars("tb")
  ) |>
  dplyr::mutate(is_hbc = forcats::as_factor(is_hbc))
coeff_df <- pull_mod_coeff_all(tbl)
}