best_models: Table with the best models according to one of the posterior...

View source: R/best_models.R

best_modelsR Documentation

Table with the best models according to one of the posterior criteria

Description

This function ranks the best models according to posterior model probabilities calculated using one of the available model priors: binomial or beta-binomial. It returns three types of tables in three different formats: an inclusion table, where 1 indicates that a regressor is included in the model and 0 indicates that it is excluded; an estimation results table, which displays the best models and their estimation output, including point estimates, standard errors, and significance levels; and an estimation results table with robust standard errors.

Usage

best_models(
  bma_list,
  prior = "binomial",
  best = 5,
  round = 3,
  estimate = TRUE,
  robust = TRUE
)

Arguments

bma_list

An object of class badp_bma, typically returned by bma.

prior

Character string specifying the model prior used for the ranking. Options are "binomial" (default) or "beta" (binomial-beta). Models are ranked by the posterior model probability computed under the chosen prior.

best

Integer. The number of best models to display (default: 5).

round

Integer indicating the decimal place to which numbers in the tables should be rounded (default: 3).

estimate

A parameter with values TRUE or FALSE indicating which table should be displayed when TRUE - table with the estimation results
FALSE - table with the inclusion of regressors in the best models

robust

A parameter with values TRUE or FALSE indicating which type of standard errors should be displayed when the function finishes calculations. Works only if estimate = TRUE. Works well when best is small.
TRUE - robust standard errors
FALSE - regular standard errors

Value

A list with best_models objects:

  1. matrix with inclusion of the regressors in the best models

  2. matrix with estimation output in the best models with regular standard errors

  3. matrix with estimation output in the best models with robust standard errors

  4. knitr_kable table with inclusion of the regressors in the best models (the best for the display on the console - up to 11 models)

  5. knitr_kable table with estimation output in the best models with regular standard errors (the best for the display on the console - up to 6 models)

  6. knitr_kable table with estimation output in the best models with robust standard errors (the best for the display on the console - up to 6 models)

  7. gTree table with inclusion of the regressors in the best models (displayed as a plot). Use grid::grid.draw() to display.

  8. gTree table with estimation output in the best models with regular standard errors (displayed as a plot). Use grid::grid.draw() to display.

  9. gTree table with estimation output in the best models with robust standard errors (displayed as a plot). Use grid::grid.draw() to display.

Examples


library(magrittr)

data_prepared <- badp::economic_growth[, 1:6] %>%
  badp::feature_standardization(
    excluded_cols = c(country, year, gdp)
  ) %>%
  badp::feature_standardization(
    group_by_col  = year,
    excluded_cols = country,
    scale         = FALSE
  )

bma_results <- bma(
  model_space = badp::small_model_space,
  round       = 3,
  dilution    = 0
)

best_5_models <- best_models(bma_results, prior = "binomial", best = 5, estimate = TRUE)


badp documentation built on Aug. 20, 2026, 9:08 a.m.