Skip to content

Commit

Permalink
docs, wording
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Sep 13, 2024
1 parent 7d094b7 commit 61da662
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
16 changes: 12 additions & 4 deletions R/check_dag.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@
#' adjusted for both. If the model is cyclic, the function stops and suggests
#' to remove cycles from the model.
#'
#' Note that it sometimes could be necessary to try out different combinations
#' of suggested adjustments, because `check_dag()` can not always detect whether
#' _at least_ one of several variables is required, or whether adjustments should
#' be done for _all_ listed variables. It can be useful to copy the dagitty-code
#' (using `as.dag()`, which prints the dagitty-string into the console) into
#' the dagitty-website and play around with different adjustments.
#'
#' @section Direct and total effects:
#'
#' The direct effect of an exposure on an outcome is the effect that is not
Expand Down Expand Up @@ -393,11 +400,11 @@ print.check_dag <- function(x, ...) {
# Scenario 2: adjusted for collider
msg <- paste0(
insight::color_text("Incorrectly adjusted!", "red"),
"\nYour model adjusts for a collider, ",
insight::color_text(datawizard::text_concatenate(collider, enclose = "`"), "cyan"),
". To estimate the ", i, " effect, do ",
"\nYour model adjusts for a potential collider. To estimate the ", i, " effect, do ",
insight::color_text("not", "italic"),
" adjust for it, to avoid collider-bias."
" adjust for ",
insight::color_text(datawizard::text_concatenate(collider, enclose = "`"), "cyan"),
" to avoid collider-bias. It is recommended to double-check for the collider-bias on the dagitty-website."
)
} else if (isTRUE(out$incorrectly_adjusted)) {
# Scenario 3: incorrectly adjusted, adjustments where none is allowed
Expand All @@ -406,6 +413,7 @@ print.check_dag <- function(x, ...) {
"\nTo estimate the ", i, " effect, do ",
insight::color_text("not", "italic"),
" adjust for ",
ifelse(length(out$current_adjustments) > 1, "some or all of ", ""),
insight::color_text(datawizard::text_concatenate(out$current_adjustments, enclose = "`"), "red"),
"."
)
Expand Down
7 changes: 7 additions & 0 deletions man/check_dag.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions tests/testthat/_snaps/check_dag.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
Identification of total effects
Incorrectly adjusted!
To estimate the total effect, do not adjust for `x1` and `x2`.
To estimate the total effect, do not adjust for some or all of `x1` and `x2`.

# check_dag, collider bias
Expand Down Expand Up @@ -265,11 +265,11 @@
Identification of direct effects
Incorrectly adjusted!
Your model adjusts for a collider, `sm_h_total_kid`. To estimate the direct effect, do not adjust for it, to avoid collider-bias.
Your model adjusts for a potential collider. To estimate the direct effect, do not adjust for `sm_h_total_kid` to avoid collider-bias. It is recommended to double-check for the collider-bias on the dagitty-website.
Identification of total effects
Incorrectly adjusted!
Your model adjusts for a collider, `sm_h_total_kid`. To estimate the total effect, do not adjust for it, to avoid collider-bias.
Your model adjusts for a potential collider. To estimate the total effect, do not adjust for `sm_h_total_kid` to avoid collider-bias. It is recommended to double-check for the collider-bias on the dagitty-website.

0 comments on commit 61da662

Please sign in to comment.