Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Sep 13, 2024
1 parent 38d5a03 commit 7d094b7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 4 additions & 4 deletions R/check_dag.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)]

Check warning on line 251 in R/check_dag.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/check_dag.R,line=251,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 122 characters.
if (!length(collider)) {

Check warning on line 252 in R/check_dag.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/check_dag.R,line=252,col=9,[if_not_else_linter] Prefer `if (A) x else y` to the less-readable `if (!A) y else x` in a simple if/else statement.
# if we don't have colliders, set to NULL
collider <- NULL
Expand Down Expand Up @@ -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") {
Expand Down Expand Up @@ -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"),
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/_snaps/check_dag.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit 7d094b7

Please sign in to comment.