From 2c2ff5f5036a81c21dd56c6d253a18c1f4c4498c Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 10 Aug 2024 12:29:53 +0200 Subject: [PATCH] add tests --- .../plot-check-dag-multiple-adjustments.svg | 338 ++++++++++++++++++ tests/testthat/test-plot.check_dag.R | 19 + 2 files changed, 357 insertions(+) create mode 100644 tests/testthat/_snaps/plot.check_dag/plot-check-dag-multiple-adjustments.svg diff --git a/tests/testthat/_snaps/plot.check_dag/plot-check-dag-multiple-adjustments.svg b/tests/testthat/_snaps/plot.check_dag/plot-check-dag-multiple-adjustments.svg new file mode 100644 index 000000000..0aa4206e4 --- /dev/null +++ b/tests/testthat/_snaps/plot.check_dag/plot-check-dag-multiple-adjustments.svg @@ -0,0 +1,338 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +alertness + +exam + +humor + +mood + +podcast + +prepared + +skills_course + + +Current model + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +alertness + +exam + +humor + +mood + +podcast + +prepared + +skills_course + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +alertness + +exam + +humor + +mood + +podcast + +prepared + +skills_course + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +alertness + +exam + +humor + +mood + +podcast + +prepared + +skills_course + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +alertness + +exam + +humor + +mood + +podcast + +prepared + +skills_course + + + + + + + + + +Adjusted for mood, prepared + + + + + + + + + +Adjusted for mood, skills_course + + + + + + + + + +Adjusted for alertness, prepared + + + + + + + + + +Adjusted for alertness, skills_course + + + + + + +outcome +exposure +adjusted +unadjusted +Required model +plot.check_dag multiple adjustments + + diff --git a/tests/testthat/test-plot.check_dag.R b/tests/testthat/test-plot.check_dag.R index 00cf68bd9..917c1079d 100644 --- a/tests/testthat/test-plot.check_dag.R +++ b/tests/testthat/test-plot.check_dag.R @@ -51,3 +51,22 @@ test_that("`plot()` for check_dag", { fig = plot(dag, which = "required") ) }) + + +test_that("`plot()` for check_dag, multiple adjustment sets", { + set.seed(1234) + dag <- performance::check_dag( + podcast ~ mood + humor + skills_course, + alertness ~ mood, + mood ~ humor, + prepared ~ skills_course, + exam ~ alertness + prepared, + exposure = "podcast", + outcome = "exam", + coords = ggdag::time_ordered_coords() + ) + vdiffr::expect_doppelganger( + title = "plot.check_dag multiple adjustments", + fig = plot(dag) + ) +})