tidybayes-models {tidybayes}R Documentation

Models supported by tidybayes

Description

Tidybayes supports two classes of models and sample formats: Models/formats that provide prediction functions, and those that do not.

All Supported Models/Sample Formats

All supported models/formats support the base tidybayes sample extraction functions, such as tidy_draws(), spread_draws(), gather_draws(), spread_rvars(), and gather_rvars(). These models/formats include:

If you install the tidybayes.rethinking package, models from the rethinking package are also supported.

Models Supporting Prediction

In addition, the following models support fit and prediction extraction functions, such as add_epred_draws(), add_predicted_draws(), add_linpred_draws(), add_epred_rvars(), add_predicted_rvars(), and add_linpred_rvars():

If your model type is not in the above list, you may still be able to use the add_draws() function to turn matrices of predictive draws (or fit draws) into tidy data frames. Or, you can wrap output from a prediction function in posterior::rvar() and add it to a data frame so long as that output is a matrix with draws as rows.

If you install the tidybayes.rethinking package, models from the rethinking package are also supported.

Extending tidybayes

To include basic support for new models, one need only implement the tidy_draws() generic function for that model. Alternatively, objects that support posterior::as_draws() or coda::as.mcmc.list() will automatically be supported by tidy_draws().

To include support for estimation and prediction, one must either implement the epred_draws(), predicted_draws(), and linpred_draws() functions or their correspond functions from rstantools: rstantools::posterior_epred(), rstantools::posterior_predict(), and rstantools::posterior_linpred(). If you take the latter approach, you should include newdata and ndraws arguments that work as documented in predicted_draws().


[Package tidybayes version 3.0.6 Index]