Skip to main page content
U.S. flag

An official website of the United States government

Dot gov

The .gov means it’s official.
Federal government websites often end in .gov or .mil. Before sharing sensitive information, make sure you’re on a federal government site.

Https

The site is secure.
The https:// ensures that you are connecting to the official website and that any information you provide is encrypted and transmitted securely.

Access keys NCBI Homepage MyNCBI Homepage Main Content Main Navigation
. 2021 Feb;1(2):e45.
doi: 10.1002/cpz1.45.

Testing Graphical Causal Models Using the R Package "dagitty"

Affiliations

Testing Graphical Causal Models Using the R Package "dagitty"

Ankur Ankan et al. Curr Protoc. 2021 Feb.

Erratum in

Abstract

Causal diagrams such as directed acyclic graphs (DAGs) are used in several scientific fields to help design and analyze studies that aim to infer causal effects from observational data; for example, DAGs can help identify suitable strategies to reduce confounding bias. However, DAGs can be difficult to design, and the validity of any DAG-derived strategy hinges on the validity of the postulated DAG itself. Researchers should therefore check whether the assumptions encoded in the DAG are consistent with the data before proceeding with the analysis. Here, we explain how the R package 'dagitty', based on the web tool dagitty.net, can be used to test the statistical implications of the assumptions encoded in a given DAG. We hope that this will help researchers discover model specification errors, avoid erroneous conclusions, and build better models. © 2021 The Authors. Basic Protocol 1: Constructing and importing DAG models from the dagitty web interface Support Protocol 1: Installing R, RStudio, and the dagitty package Basic Protocol 2: Testing DAGs against categorical data Basic Protocol 3: Testing DAGs against continuous data Support Protocol 2: Testing DAGs against continuous data with non-linearities Basic Protocol 4: Testing DAGs against a combination of categorical and continuous data.

Keywords: dagitty; directed acyclic graphs (DAGs); independence testing; model testing.

PubMed Disclaimer

Similar articles

Cited by

References

Literature Cited

    1. Cleveland, W. S. (1979). Robust locally weighted regression and smoothing scatterplots. Journal of the American Statistical Association, 74(368), 829-836.
    1. Dua, D., & Graff, C. (2019). UCI machine learning repository. Available at http://archive.ics.uci.edu/ml.
    1. Ellis, B., Haaland, P., Hahne, F., Meur, N. Le, Gopalakrishnan, N., Spidlen, J., … Finak, G. (2019). flowCore: Basic structures for flow cytometry data, R package version 1.52.0.
    1. Grolemund, G., & Wickham, H. (2020). R for data science. Online e-book. Available at http://r4ds.had.co.nz/#.
    1. Heinze-Deml, C., Peters, J., & Meinshausen, N. (2018). Invariant causal prediction for nonlinear models. Journal of Causal Inference, 6(2), doi: 10.1515/jci-2017-0016.

Grants and funding

LinkOut - more resources