Skip to content

Fits a Bayesian regression on a 'tidyFit' R6 class. The function can be used with regress and classify.

Usage

# S3 method for bayes
.fit(self, data = NULL)

Arguments

self

a 'tidyFit' R6 class.

data

a data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr).

Value

A fitted 'tidyFit' class model.

A 'tibble'.

Details

Hyperparameters:

None. Cross validation not applicable.

Important method arguments (passed to m)

The function provides a wrapper for arm::bayesglm. See ?bayesglm for more details.

Implementation

No implementation notes

References

Gelman A, Su Y (2021). arm: Data Analysis Using Regression and Multilevel/Hierarchical Models. R package version 1.12-2, https://CRAN.R-project.org/package=arm.

See also

.fit.glm and m methods

Author

Johann Pfitzinger

Examples

# Load data
data <- tidyfit::Factor_Industry_Returns

# Stand-alone function
fit <- m("bayes", Return ~ ., data)
fit
#> # A tibble: 1 × 6
#>   estimator_fct `size (MB)` grid_id  model_object settings warnings       
#>   <chr>               <dbl> <chr>    <list>       <list>   <chr>          
#> 1 arm::bayesglm        5.62 #0010000 <tidyFit>    <tibble> variable 'Indu…

# Within 'regress' function
fit <- regress(data, Return ~ ., m("bayes"), .mask = c("Date", "Industry"))
coef(fit)
#> Warning: The `tidy()` method for objects of class `bayesglm` is not maintained by the broom team, and is only supported through the `glm` tidier method. Please be cautious in interpreting and reporting broom output.
#> 
#> This warning is displayed once per session.
#> # A tibble: 7 × 4
#> # Groups:   model [1]
#>   model term        estimate model_info      
#>   <chr> <chr>          <dbl> <list>          
#> 1 bayes (Intercept)  -0.0312 <tibble [1 × 3]>
#> 2 bayes Mkt-RF        0.977  <tibble [1 × 3]>
#> 3 bayes SMB           0.0182 <tibble [1 × 3]>
#> 4 bayes HML           0.0605 <tibble [1 × 3]>
#> 5 bayes RMW           0.164  <tibble [1 × 3]>
#> 6 bayes CMA           0.117  <tibble [1 × 3]>
#> 7 bayes RF            1.00   <tibble [1 × 3]>