From 7d094b7f52c26ff994362e991f600391d5c9940d Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 13 Sep 2024 18:53:56 +0200 Subject: [PATCH] minor --- DESCRIPTION | 2 +- R/check_dag.R | 8 ++++---- tests/testthat/_snaps/check_dag.md | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index f74f6e7f1..58ce17d59 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: performance Title: Assessment of Regression Models Performance -Version: 0.12.3.1 +Version: 0.12.3.2 Authors@R: c(person(given = "Daniel", family = "Lüdecke", diff --git a/R/check_dag.R b/R/check_dag.R index e0535a0dd..0b812788f 100644 --- a/R/check_dag.R +++ b/R/check_dag.R @@ -248,7 +248,7 @@ check_dag <- function(..., adjustment_set <- unlist(dagitty::adjustmentSets(dag, effect = x), use.names = FALSE) adjustment_nodes <- unlist(dagitty::adjustedNodes(dag), use.names = FALSE) minimal_adjustments <- as.list(dagitty::adjustmentSets(dag, effect = x)) - collider <- adjustment_nodes[vapply(adjustment_nodes, ggdag::is_collider, logical(1), .dag = dag)] + collider <- adjustment_nodes[vapply(adjustment_nodes, ggdag::is_collider, logical(1), .dag = dag, downstream = FALSE)] if (!length(collider)) { # if we don't have colliders, set to NULL collider <- NULL @@ -356,7 +356,7 @@ print.check_dag <- function(x, ...) { # minimal adjustment sets for direct and total effect identical? # Then print only once if (identical(attributes(x)$check_direct$minimal_adjustments, attributes(x)$check_total$minimal_adjustments)) { - .print_dag_results(attributes(x)$check_direct, x, "direct and total", "all") + .print_dag_results(attributes(x)$check_direct, x, "direct and total", "all", collider) } else { for (i in c("direct", "total")) { if (i == "direct") { @@ -390,10 +390,10 @@ print.check_dag <- function(x, ...) { "`." ) } else if (!is.null(collider)) { - # Scenario 2: adjusted for (downstream) collider + # Scenario 2: adjusted for collider msg <- paste0( insight::color_text("Incorrectly adjusted!", "red"), - "\nYour model adjusts for a (downstream) collider, ", + "\nYour model adjusts for a collider, ", insight::color_text(datawizard::text_concatenate(collider, enclose = "`"), "cyan"), ". To estimate the ", i, " effect, do ", insight::color_text("not", "italic"), diff --git a/tests/testthat/_snaps/check_dag.md b/tests/testthat/_snaps/check_dag.md index 0c3b3233d..c7f577515 100644 --- a/tests/testthat/_snaps/check_dag.md +++ b/tests/testthat/_snaps/check_dag.md @@ -265,11 +265,11 @@ Identification of direct effects Incorrectly adjusted! - Your model adjusts for a (downstream) collider, `sm_h_total_kid`. To estimate the direct effect, do not adjust for it, to avoid collider-bias. + Your model adjusts for a collider, `sm_h_total_kid`. To estimate the direct effect, do not adjust for it, to avoid collider-bias. Identification of total effects Incorrectly adjusted! - Your model adjusts for a (downstream) collider, `sm_h_total_kid`. To estimate the total effect, do not adjust for it, to avoid collider-bias. + Your model adjusts for a collider, `sm_h_total_kid`. To estimate the total effect, do not adjust for it, to avoid collider-bias.