Learn R Programming

Tidy methods for Bayesian treatment effect models

tidytreatment is an R package that provides functions for extracting tidy data from Bayesian treatment effect models, estimating treatment effects, and plotting useful summaries of these. This package closely follows the output style from the tidybayes R package in order to use some functions provided by tidybayes.

The package currently supports the following models:

  • BART: see CRAN
  • bartMachine: see CRAN.
  • bcf: see CRAN (in development, see branch bcf-hold on github)

in addition to models supported by tidybayes.

See this HTML vignette or vignette("use-tidytreatment-BART") for examples of usage.

How to install

CRAN

Install the release version from CRAN with install.packages("tidytreament").

Github

To install the latest development version:

  1. Make sure at least one of the above model fitting packages is installed.
  2. In R make sure remotes is installed. Install with install.packages("remotes").
  3. Run remotes::install_github("bonStats/tidytreatment")

Copy Link

Version

Install

install.packages('tidytreatment')

Monthly Downloads

284

Version

0.3.1

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Joshua J Bon

Last Published

January 10th, 2025

Functions in tidytreatment (0.3.1)

has_tidytreatment_methods

Check if a model class has required generic methods for tidytreatment functions.
fitted_draws.mbart2

Get fitted draws from posterior of mbart2 model
residual_draws.pbart

Get residual draw for pbart model
tidy_draws.bartcFit

Tidy access to posterior of bartCause-package objects
tidy_att

Get average treatment effect on treated draws from posterior
predicted_draws_BART

Get predict draws from posterior of BART-package models
simulate_su_hill_data

Simulate data with scenarios from Hill and Su (2013)
predicted_draws.wbart

Get predict draws from posterior of wbart model
suhillsim1

Example simulated dataset 1
tidy_ate

Get average treatment effect draws from posterior
fitted_draws.pbart

Get fitted draws from posterior of pbart model
predicted_draws.stan4bartFit

Get prediction draws from posterior of stan4bart-package models
predicted_draws.bartcFit

Get prediction draws from posterior of bartCause-package objects
suhillsim2_ranef

Example simulated dataset 2: with subject specific random effects
residual_draws.wbart

Get residual draw for wbart model
treatment_effects.default

Get treatment effect draws from posterior
residual_draws_BART

Get residual draw for BART model
treatment_effects.bartcFit

Get (individual) treatment effect draws from bartcFit posterior
tidytreatment

tidytreatment: Tidy methods for Bayesian treatment effect models
posterior_trees_BART

Get posterior tree draws into tibble format from BART model
treatment_effects

Get (individual) treatment effect draws from posterior
predicted_draws.bartMachine

Get predict draws from posterior of bartMachine model
variance_draws

Get variance draws from posterior of BART models
covariate_with_treatment_importance

Counts of variable inclusion when interacting with treatment
avg_treatment_effects

Get (conditional) average treatment effect draws from posterior
epred_draws.bartcFit

Get expected prediction draws from posterior of bartCause-package objects
fitted_draws.mbart

Get fitted draws from posterior of mbart model
epred_draws.stan4bartFit

Get expected prediction draws from posterior of stan4bart-package models
bartmodel1

Example model 1
fitted_draws.lbart

Get fitted draws from posterior of lbart model
covariate_importance

Counts of variable overall inclusion
fitted_draws.bartMachine

Get fitted draws from posterior of bartMachine model
linpred_draws.stan4bartFit

Get expected prediction draws (on linear scale) from posterior of stan4bart-package models
fitted_draws_BART

Get fitted draws from posterior of BART-package models
fitted_draws.wbart

Get fitted draws from posterior of wbart model
residual_draws.bartMachine

Get residual draw for bartMachine model
highDim_testdataset3

ACIC2019 High Dimensional Test Dataset
%>%

Pipe operator
bartmodel1_modelmatrix

Model matrix used for bartmodel1
linpred_draws.bartcFit

Get expected prediction draws (on linear scale) from posterior of bartCause-package objects
has_common_support

Evaluate if observations have common support.