Fits a Bayesian model averaging regression on a 'tidyFit' R6
class. The function can be used with regress
.
# S3 method for class 'bma'
.fit(self, data = NULL)
A fitted 'tidyFit' class model.
Hyperparameters:
None. Cross validation not applicable.
Important method arguments (passed to m
)
iter
(number of iteration draws)
mcmc
(model sampler used (default 'bd'))
The function provides a wrapper for BMS::bms
. See ?bms
for more details.
Implementation
The underlying function automatically generates plotting output, which is not suppressed.
Use coef(fit)
to obtain posterior mean, standard deviation as well as posterior inclusion probabilities for the features.
Feldkircher, M. and S. Zeugner (2015). Bayesian Model Averaging Employing Fixed and Flexible Priors: The BMS Package for R, Journal of Statistical Software 68(4).
.fit.bayes
and m
methods
# Load data
data <- tidyfit::Factor_Industry_Returns
# Stand-alone function
fit <- m("bma", Return ~ `Mkt-RF` + HML + SMB + RMW + CMA, data)
fit
#> # A tibble: 1 × 5
#> estimator_fct `size (MB)` grid_id model_object settings
#> <chr> <dbl> <chr> <list> <list>
#> 1 BMS::bms 3.20 #0010000 <tidyFit> <tibble [1 × 1]>
# Within 'regress' function
fit <- regress(data, Return ~ ., m("bma"), .mask = c("Date", "Industry"))
coef(fit)
#> # A tibble: 7 × 4
#> # Groups: model [1]
#> model term estimate model_info
#> <chr> <chr> <dbl> <list>
#> 1 bma CMA 0.118 <tibble [1 × 2]>
#> 2 bma HML 0.0584 <tibble [1 × 2]>
#> 3 bma Mkt-RF 0.979 <tibble [1 × 2]>
#> 4 bma RF 1.00 <tibble [1 × 2]>
#> 5 bma RMW 0.158 <tibble [1 × 2]>
#> 6 bma SMB 0.00255 <tibble [1 × 2]>
#> 7 bma (Intercept) -0.0258 <tibble [1 × 2]>