Package: tidytreatment 1.0.0

tidytreatment: Tidy Methods for Bayesian Treatment Effect Models

Functions for extracting tidy data from Bayesian treatment effect models, in particular BART, but extensions are possible. Functionality includes extracting tidy posterior summaries as in 'tidybayes' <https://github.com/mjskay/tidybayes>, estimating (average) treatment effects, common support calculations, and plotting useful summaries of these.

Authors:Joshua J Bon [aut, cre]

tidytreatment_1.0.0.tar.gz
tidytreatment_1.0.0.zip(r-4.7-any)tidytreatment_1.0.0.zip(r-4.6-any)tidytreatment_1.0.0.zip(r-4.5-any)
tidytreatment_1.0.0.tgz(r-4.6-any)tidytreatment_1.0.0.tgz(r-4.5-any)
tidytreatment_1.0.0.tar.gz(r-4.7-any)tidytreatment_1.0.0.tar.gz(r-4.6-any)
tidytreatment_1.0.0.tgz(r-4.6-emscripten)
manual.pdf |manual.html✨
DESCRIPTION |NEWS
card.svg |card.png
tidytreatment/json (API)

# Install 'tidytreatment' in R:
install.packages('tidytreatment', repos = c('https://bonstats.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/bonstats/tidytreatment/issues

Datasets:

On CRAN:

Conda:

bayesiantidytreatment-effects

6.96 score 17 stars 27 scripts 391 downloads 12 exports 60 dependencies

Last updated from:c241c438ab. Checks:9 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-develOK246
source / vignettesOK356
linux-releaseOK197
macos-releaseOK172
macos-oldrelOK180
windows-develOK274
windows-releaseOK278
windows-oldrelOK315
wasm-releaseOK132

Exports:%>%avg_treatment_effectscovariate_importancecovariate_with_treatment_importancehas_common_supporthas_tidytreatment_methodssimulate_su_hill_datasu_hill_true_effectstidy_atetidy_atttreatment_effectsvariance_draws

Dependencies:abindarrayhelpersbackportsBARTbitbit64checkmateclicliprcodacpp11crayondbartsdistributionaldplyrfarvergenericsggdistggplot2gluegtablehmsisobandlabelinglatticelifecyclemagrittrMatrixmatrixStatsnlmenumDerivpillarpkgconfigposteriorprettyunitsprogresspurrrquadprogR6RColorBrewerRcppreadrrlangS7scalesstringistringrsurvivalsvUnittensorAtibbletidybayestidyrtidyselecttzdbutf8vctrsviridisLitevroomwithr

Using the tidytreatment package with BART
Simulate data | Fit the regression model | Extract the posterior (tidy style) | Use some plotting functions from the tidybayes package | Calculate Treatment Effects | Common support calculations | Investigating variable importance | Model checking and convergence | References

Last update: 2026-10-23
Started: 2020-04-27

Using the tidytreatment package with BART (binary outcome)
Simulate data | Fit the regression model | Extract the posterior (tidy style) | Use some plotting functions from the tidybayes package | Calculate Treatment Effects | Common support calculations | Investigating variable importance | Model checking and convergence | References

Last update: 2026-10-23
Started: 2025-01-11

Using the tidytreatment package with bartCause
Simulate data | Fit the regression model | Extract the posterior (tidy style) | Use some plotting functions from the tidybayes package | Calculate Treatment Effects | References

Last update: 2026-10-23
Started: 2023-05-18

Using the tidytreatment package with stochtree
Simulate data | Fit the regression model | Extract the posterior (tidy style) | Use some plotting functions from the tidybayes package | Calculate Treatment Effects | References

Last update: 2026-10-23
Started: 2026-10-23

Readme and manuals

Help Manual

Help pageTopics
Get (conditional) average treatment effect draws from posterioravg_treatment_effects
Example model 1bartmodel1
Model matrix used for 'bartmodel1'bartmodel1_modelmatrix
Counts of variable overall inclusioncovariate_importance
Multinomial BART models ('mbart'/'mbart2') are not supportedcovariate_importance-mbart-unsupported covariate_importance.mbart covariate_importance.mbart2
Counts of variable inclusion when interacting with treatmentcovariate_with_treatment_importance
Multinomial BART models ('mbart'/'mbart2') are not supportedcovariate_with_treatment_importance-mbart-unsupported covariate_with_treatment_importance.mbart covariate_with_treatment_importance.mbart2
Get fitted draws from posterior of a 'dbarts::bart'/'dbarts::bart2' modelepred_draws.bart
Get expected prediction draws from posterior of 'bartCause'-package objectsepred_draws.bartcFit
Get fitted draws from posterior of 'bartMachine' modelepred_draws.bartMachine
Get fitted draws from posterior of 'bartmodel' ('stochtree' package) modelepred_draws.bartmodel
Get fitted draws from posterior of 'bcfmodel' ('stochtree' package) modelepred_draws.bcfmodel
Get fitted draws from posterior of 'lbart' modelepred_draws.lbart
Get fitted draws from posterior of 'pbart' modelepred_draws.pbart
Get expected prediction draws from posterior of 'stan4bart'-package modelsepred_draws.stan4bartFit
Get fitted draws from posterior of 'wbart' modelepred_draws.wbart
Get fitted draws from posterior of 'BART'-package modelsfitted_draws_BART
Get fitted draws from posterior of 'dbarts'-package 'bart'/'bart2' modelsfitted_draws_dbarts
Get fitted draws from posterior of 'stochtree'-package modelsfitted_draws_stochtree
Get fitted draws from posterior of 'stochtree'-package BCF (causal forest) modelsfitted_draws_stochtree_bcf
Evaluate if observations have common support.has_common_support
Check if a model class has required generic methods for tidytreatment functions.has_tidytreatment_methods
ACIC2019 High Dimensional Test DatasethighDim_testdataset3
Get expected prediction draws (on linear scale) from posterior of 'bartCause'-package objectslinpred_draws.bartcFit
Get linear predictor draws from posterior of 'bartmodel' ('stochtree' package) modellinpred_draws.bartmodel
Get linear predictor draws from posterior of 'bcfmodel' ('stochtree' package) modellinpred_draws.bcfmodel
Get linear predictor draws from posterior of 'stan4bart'-package modelslinpred_draws.stan4bartFit
Multinomial BART models ('mbart'/'mbart2') are not supportedepred_draws.mbart epred_draws.mbart2 mbart-unsupported predicted_draws.mbart predicted_draws.mbart2 residual_draws.mbart residual_draws.mbart2
Get posterior tree draws into tibble format from BART modelposterior_trees_BART
Get predict draws from posterior of 'BART::wbart' modelspredicted_draws_BART
Get predict draws from posterior of a 'dbarts::bart'/'bart2' modelpredicted_draws.bart
Get prediction draws from posterior of 'bartCause'-package objectspredicted_draws.bartcFit
Get predict draws from posterior of 'bartMachine' modelpredicted_draws.bartMachine
Get predict draws from posterior of 'bartmodel' ('stochtree' package) modelpredicted_draws.bartmodel
Get predict draws from posterior of 'bcfmodel' ('stochtree' package) modelpredicted_draws.bcfmodel
Get predict draws from posterior of 'lbart' modelpredicted_draws.lbart
Get predict draws from posterior of 'pbart' modelpredicted_draws.pbart
Get prediction draws from posterior of 'stan4bart'-package modelspredicted_draws.stan4bartFit
Get predict draws from posterior of 'wbart' modelpredicted_draws.wbart
Get residual draw for BART modelresidual_draws_BART
Get residual draws for a 'dbarts::bart'/'bart2' modelresidual_draws.bart
Get residual draw for 'bartMachine' modelresidual_draws.bartMachine
Get residual draw for 'bartmodel' ('stochtree' package) modelresidual_draws.bartmodel
Get residual draw for 'bcfmodel' ('stochtree' package) modelresidual_draws.bcfmodel
Get residual draw for 'pbart' modelresidual_draws.pbart
Get residual draw for 'wbart' modelresidual_draws.wbart
Simulate data with scenarios from Hill and Su (2013)simulate_su_hill_data
Get the ground truth (e.g. treatment effect) for a Su and Hill (2013) simulationsu_hill_true_effects
Example simulated dataset 1suhillsim1
Example simulated dataset 2: with subject specific random effectssuhillsim2_ranef
Get average treatment effect draws from posteriortidy_ate
Get average treatment effect on treated draws from posteriortidy_att
Multinomial BART models ('mbart'/'mbart2') are not supportedtidy_draws-mbart-unsupported tidy_draws.mbart tidy_draws.mbart2
Tidy access to posterior of a 'pbart'/'lbart' modeltidy_draws-pbart-lbart tidy_draws.lbart tidy_draws.pbart
Tidy access to posterior of a 'dbarts::bart'/'bart2' modeltidy_draws.bart
Tidy access to posterior of 'bartCause'-package objectstidy_draws.bartcFit
Tidy access to posterior of 'bartmodel' ('stochtree' package) modeltidy_draws.bartmodel
Tidy access to posterior of 'bcfmodel' ('stochtree' package) modeltidy_draws.bcfmodel
Tidy access to posterior of a 'wbart' modeltidy_draws.wbart
tidytreatment: Tidy methods for Bayesian treatment effect modelstidytreatment-package tidytreatment
Get (individual) treatment effect draws from posteriortreatment_effects
Get (individual) treatment effect draws from bartcFit posteriortreatment_effects.bartcFit
Get (individual) treatment effect draws from posterior of a 'bcfmodel' ('stochtree' package)treatment_effects.bcfmodel
Get treatment effect draws from posteriortreatment_effects.default
Get variance draws from posterior of BART modelsvariance_draws