best_models: Best Models by Posterior Model Probability

View source: R/best_models.R

best_modelsR Documentation

Best Models by Posterior Model Probability

Description

Ranks the models in a fitted model space by their posterior model probability and returns the highest ranked ones as a list of individual models, each carrying its own estimates and diagnostics.

Usage

best_models(x, prior = "binomial", best = 5, round = 3)

Arguments

x

An object of class badp_bma, typically the result of bma.

prior

Model prior used to rank the models: "binomial" (the default) or "beta" for the binomial-beta prior.

best

Number of models to return. If it exceeds the size of the model space, every model is returned and a message is issued.

round

Number of decimal places used when the estimates are formatted for display. The stored values are not rounded.

Details

The object returned is a list of badp_model objects, one per selected model, ordered from the highest to the lowest posterior model probability. Individual models are reached by position, for example best_models(bma_results)[[1]] for the best one, and each has its own print, summary and coef methods. The container has print, summary and plot methods that display the whole selection.

Value

An object of class badp_best_models: a list of badp_model objects with attributes prior, n_models (the size of the model space), reg_names and digits.

See Also

bma, summary.badp_best_models, plot.badp_best_models, print.badp_model

Examples


data(full_model_space)
results <- bma(full_model_space)

best <- best_models(results, best = 5)
best                      # the selection
best[[1]]                 # the single best model
coef(best[[1]])           # its coefficients
summary(best, robust = TRUE)



badp documentation built on Sept. 15, 2026, 1:08 a.m.