coef.badp_bma: Extract posterior statistics from Bayesian Model Averaging...

View source: R/s3_methods_bma.R

coef.badp_bmaR Documentation

Extract posterior statistics from Bayesian Model Averaging Results

Description

Coefficient extraction method for objects of class badp_bma.

Usage

## S3 method for class 'badp_bma'
coef(
  object,
  prior = "both",
  conditional = FALSE,
  se = FALSE,
  robustSE = FALSE,
  PIP = TRUE,
  ...
)

Arguments

object

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

prior

Character string specifying which prior to use. Options are "both" (default), "binomial", or "beta". With "both" the result reports estimates under the binomial and the binomial-beta priors and is printed via print.badp_bma_coef.

conditional

Logical. If TRUE, returns posterior means (and posterior standard deviations when se = TRUE) conditional on inclusion of the variable in a model - i.e. the columns whose names end in "con" (PMcon, PSDcon, PSDRcon). If FALSE (default), returns the unconditional posterior mean and standard error.

se

Logical. If TRUE, includes a posterior standard deviation column alongside each posterior mean. Defaults to FALSE.

robustSE

Logical. Only meaningful when se = TRUE. If TRUE, uses the robust posterior standard deviation (PSDR / PSDRcon); if FALSE (default), uses the non-robust version (PSD / PSDcon). Ignored with a warning when se = FALSE.

PIP

Logical. If TRUE (default), includes a posterior inclusion probability column for each prior. Set to FALSE to suppress.

...

Additional arguments (currently unused).

Details

This function extracts coefficient estimates from Bayesian Model Averaging results. By default both priors are reported so the user can compare them at a glance; set prior = "binomial" or prior = "beta" to obtain the legacy single-prior return values (useful when feeding coefficients into downstream code).

Value

The shape of the return value depends on prior, conditional, se, robustSE and PIP:

  • prior = "both": always a badp_bma_coef data frame. Columns are grouped by prior; for each prior the columns binom_PM / beta_PM (or binom_PMcon / beta_PMcon when conditional = TRUE), standard error columns binom_PSD / beta_PSD (or binom_PSDR / beta_PSDR when robustSE = TRUE, or their con variants when conditional = TRUE) when se = TRUE, and binom_PIP / beta_PIP when PIP = TRUE.

  • prior = "binomial" or "beta": a named numeric vector of estimates when se = FALSE and PIP = FALSE; otherwise a data frame with columns PM (or PMcon when conditional = TRUE), posterior standard deviation column PSD / PSDR (or PSDcon / PSDRcon) when se = TRUE, and PIP when PIP = TRUE.

See Also

bma, summary.badp_bma, print.badp_bma_coef

Examples


data(full_model_space)
results <- bma(full_model_space)

# Posterior means under both priors with PIP
coef(results)

# With standard errors
coef(results, se = TRUE)

# With robust standard errors
coef(results, se = TRUE, robustSE = TRUE)

# Conditional posterior means and SEs
coef(results, conditional = TRUE, se = TRUE)

# Suppress PIP column
coef(results, PIP = FALSE)

# Single-prior numeric vector (legacy behaviour)
coef(results, prior = "binomial", PIP = FALSE)



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