coef_hist: Graphs of the distribution of the coefficients over the model...

View source: R/coef_hist.R

coef_histR Documentation

Graphs of the distribution of the coefficients over the model space

Description

This function draws graphs of the distribution (in the form of histogram or kernel density) of the coefficients for all the considered regressors over the part of the model space that includes these regressors (half of the model space).

Usage

coef_hist(
  bma_list,
  weight = NULL,
  bin_method = c("FD", "SC", "vec"),
  bin_widths = NULL,
  use_bin_count = 0,
  bin_counts = NULL,
  use_kernel = 0
)

Arguments

bma_list

An object of class badp_bma, typically returned by bma.

weight

Parameter indicating whether the coefficients should be weighted by posterior model probabilities:

  1. NULL - no weighting (default option)

  2. "binomial" - using posterior model probabilities based on binomial model prior

  3. "beta" - using posterior model probabilities based on binomial-beta model prior

bin_method

Character string specifying the method for bin widths (default: "FD"). One of:
"FD" - Freedman-Diaconis method;
"SC" - Scott method;
"vec" - user specified bin widths provided through a vector (parameter: bin_widths).

bin_widths

A vector with bin widths to be used to construct histograms for the regressors. The vector must be of the size equal to total number of regressors plus one for the lagged dependent variable. The vector with bin widths is used only if parameter bin_method = "vec".

use_bin_count

Parameter taking the values (default: use_bin_count = 0):
1 - the histogram will be built based on the number of bins specified by the user through parameter bin_counts. If use_bin_count = 1, the function ignores parameter bin_method.
0 - the histogram will be built in line with parameter bin_method.

bin_counts

A vector with the numbers of bins to be used to construct histograms for the regressors. The vector must be of the size equal to total number of regressors plus one for the lagged dependent variable. The vector with bin counts is used only if parameter use_bin_count = 1.

use_kernel

A parameter taking the values (default: use_kernel = 0):
1 - the function will build graphs using kernel density for the distribution of coefficients (with use_kernel = 1, the function ignores parameters bin_method and use_bin_count)
0 - the function will build regular histogram density for the distribution of coefficients

Value

A list with the graphs of the distribution of coefficients for all the considered regressors and the lagged dependent variable.

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
)

coef_plots <- coef_hist(bma_results, use_kernel = 1)


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