Toolkit for Weighting and Analysis of Nonequivalent Groups (TWANG)
The Toolkit for Weighting and Analysis of Nonequivalent Groups, or TWANG, contains a set of functions to support causal modeling of observational data through the estimation and evaluation of propensity score weights. The TWANG package was first developed in 2004 by RAND researchers for the R statistical computing language and environment. The R version of the package contains functions for creating high-quality propensity score weights which can be used to estimate treatment effects with two or more treatment groups, continuous treatments, and time-varying treatments.
Additionally, the TWANG project team (including researchers from ETS and Temple University) has developed a number of R tools for understanding the selection bias due to observed covariates, sensitivity to unobserved confounding, estimation of balancing weights using entropy balancing, and a package devoted to implementing causal mediation analyses.
In 2014, TWANG macros were developed for SAS and Stata to support the use of these tools without requiring researchers and analysts to learn R. Currently, the SAS and Stata TWANG macros can support estimation of propensity scores and their associated weights for comparisons involving two or more treatment groups. Future work is planned to expand the number of Stata tools related to TWANG to include time-varying and continuous treatments as well as omitted variable sensitivity analyses.
Most recently, our team has begun to develop user-friendly, menu-driven Shiny apps for implementation of our various TWANG tools.
The TWANG package was originally created after RAND researchers grew tired of spending too much time and effort trying to create the best set of propensity score weights using logistic regression. Determining which main effects, interactions, and higher-order terms should be included in the propensity score is typically challenging in application. The original TWANG package implemented Generalized Boosted Models (GBM) for estimation of propensity score weights. GBM estimates propensity scores and their associated weights using an automated, nonparametric machine learning technique that only requires the analyst to specify which pre-treatment covariates they would like to balance between the treatment groups. The algorithm (not the user) determines the most appropriate model for the propensity score.
In 2020, the TWANG suite of tools for causal inference expanded to include an additional machine learner (xgboost) for estimation of the needed propensity score weights, methods for estimating balancing weights using entropy balancing, implementing sensitivity analyses for unobserved confounding, methods for estimation of generalized propensity score weights (using entropy balancing and GBM), quantifying the bias due to each observed pretreatment covariate, and a package devoted to causal mediation. The team also started to create the TWANG tools in Shiny, creating user-friendly, menu-driven apps that can estimate propensity score weights for two or more treatment groups and time-varying treatments.
How to start using TWANG
This site contains tutorials that describe the use of the TWANG package in R, Shiny, SAS, and Stata, downloadable macros for the SAS and Stata environments, Shiny apps for performing analyses using the TWANG package's suite of commands, and links to related software available elsewhere. Combined, these resources are everything you need to begin using TWANG to create propensity score or balancing weights for a wide variety of settings.
The TWANG project team has also created educational video tutorials which provide an overview to causal inference using propensity scores and step-by-step procedures for implementing propensity score weighted analyses involving two or more treatment groups and time-varying treatments using the TWANG data analysis package.
The TWANG project team has also been actively involved in giving workshops and short courses on causal inference using propensity scores. A list of upcoming courses can be viewed here. We will soon be hosting a webinar. For more information on participating in a webinar, contact the project team at email@example.com.
The TWANG package has been expanded, improved, and widely distributed with funding from grant 1R01DA034065 and R01DA045049 from the National Institute on Drug Abuse.
To reference these resources in other publications, please cite:
Beth Ann Griffin, Greg Ridgeway, Andrew R. Morral, Lane F. Burgette, Craig Martin, Daniel Almirall, Rajeev Ramchand, Lisa H. Jaycox, Daniel F. McCaffrey. Toolkit for Weighting and Analysis of Nonequivalent Groups (TWANG) Website. Santa Monica, CA: RAND Corporation, 2014. http://www.rand.org/statistics/twang.