Simulation Tool for Causal Inference Using Longitudinal Data
optic R package helps you scrutinize candidate causal inference models using your own longitudinal data. Researchers from the Opioid Policy Tools and Information Center (OPTIC) initially created the tool to examine longitudinal data related to opioids, but its framework can be used with longitudinal data on topics other than opioids.
Recent difference-in-differences (DID) literature revealed issues with the traditional DID model, but we found it very difficult to evaluate the relative performance of different causal inference methods using our own data. Thus, we designed a series of simulations (Griffin et al. 2021; Griffin et al. 2023) to study the performance of various methods under different scenarios. Our publications to date are as follows:
In Griffin et al. (2021), we use real-world data on opioid mortality rates to assess commonly used statistical models for DID designs, which are widely used in state policy evaluations. These experiments demonstrated notable limitations of those methods. In contrast, the optimal model we identified—the autoregressive (AR) model—showed a lot of promise. That said, do not just take our word for it; try it out with your own data and see how various approaches perform relative to one another. See the “Usage” section for details.
In Griffin et al. (2023), we demonstrate that it is critical to be able to control for effects of co-occurring policies and understand the potential bias that might arise from not controlling for those policies. Our package can help you assess the impact of co-occurring policies on the performance of commonly used statistical models in state policy evaluations.
Assessing those methods in a systematic way might be challenging, but you can now use our
optic R package to simulate policy effects and compare causal inference models using your own data.
The package supports the traditional two-way fixed effects DID model and the AR model, as well as other leading methods, such as augmented synthetic control and the Callaway-Sant’Anna approach to DID (Ben-Michael, Feller, and Rothstein 2021; Callaway and Sant’Anna 2021).
You will need R (version 4.1.0 or above) to use this package. You can install the
optic R package from the
The introductory vignette provides a working example using a sample
overdoses dataset provided with the package.
optic provides three main functions:
optic_model to define model specifications for each causal model to be tested in the simulation experiment. Then, pass your models, your data, and your parameters to the
optic_simulation function, which specifies a set of simulations to be performed for each
optic_model included in your
list of models. Finally, use
dispatch_simulations to run your simulations in parallel.
Reach out to Beth Ann Griffin for questions related to this repository.
Copyright (C) 2023 by The RAND Corporation. This repository is released as open-source software under a GPL-3.0 license. See the LICENSE file.
This research was financially supported through a National Institute on Drug Abuse grant (P50DA046351) to the RAND Corporation and carried out within the Access and Delivery Program in RAND Health Care.
RAND Health Care, a division of the RAND Corporation, promotes healthier societies by improving health care systems in the United States and other countries. We do this by providing health care decisionmakers, practitioners, and consumers with actionable, rigorous, objective evidence to support their most complex decisions. For more information, see www.rand.org/health-care, or contact
RAND Health Care Communications
1776 Main Street
P.O. Box 2138
Santa Monica, CA 90407-2138
(310) 393-0411, ext. 7775