Skip to content

Commit 6913001

Browse files
committed
docs
1 parent e225fdd commit 6913001

File tree

2 files changed

+49
-5
lines changed

2 files changed

+49
-5
lines changed

R/check_dag.R

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
#' your model based on directed acyclic graphs (DAG). The function checks if a
66
#' model is correctly adjusted for identifying specific relationships of
77
#' variables, especially directed (maybe also "causal") effects for given
8-
#' exposures on an outcome. It returns a **dagitty** object that can be
9-
#' visualized with `plot()`.
8+
#' exposures on an outcome. In case of incorrect adjustments, the function
9+
#' suggest the minimal required variables that should be adjusted for (sometimes
10+
#' also called "controlled for"), i.e. that need to be included in the model.
11+
#' It returns a **dagitty** object that can be visualized with `plot()`.
1012
#'
1113
#' `check_dag()` is a convenient wrapper around `ggdag::dagify()`,
1214
#' `dagitty::adjustmentSets()` and `dagitty::adjustedNodes()` to check correct
@@ -52,6 +54,24 @@
5254
#' the arrow points in both directions. Bi-directed paths often indicate
5355
#' unmeasured cause, or unmeasured confounding, of the two involved variables.
5456
#'
57+
#' @section Minimally required adjustments:
58+
#'
59+
#' The function checks if the model is correctly adjusted for identifying the
60+
#' direct and total effects of the exposure on the outcome. If the model is
61+
#' correctly specified, no adjustment is needed to estimate the direct effect.
62+
#' If the model is not correctly specified, the function suggests the minimal
63+
#' required variables that should be adjusted for. The function distinguishes
64+
#' between direct and total effects, and checks if the model is correctly
65+
#' adjusted for both. If the model is cyclic, the function stops and suggests
66+
#' to remove cycles from the model.
67+
#'
68+
#' @section Direct and total effects:
69+
#' The direct effect of an exposure on an outcome is the effect that is not
70+
#' mediated by any other variable in the model. The total effect is the sum of
71+
#' the direct and indirect effects. The function checks if the model is correctly
72+
#' adjusted for identifying the direct and total effects of the exposure on the
73+
#' outcome.
74+
#'
5575
#' @section Why are DAGs important - the Table 2 fallacy:
5676
#'
5777
#' Correctly thinking about and identifying the relationships between variables
@@ -332,7 +352,7 @@ print.check_dag <- function(x, ...) {
332352
datawizard::text_concatenate(out$current_adjustments, enclose = "`"),
333353
"."
334354
)
335-
} else if (!any(missing_adjustments)) {
355+
} else if (!any(missing_adjustments)) { # nolint
336356
# Scenario 3: missing adjustments
337357
msg <- paste0(
338358
insight::color_text("Incorrectly adjusted!", "red"),

man/check_dag.Rd

Lines changed: 26 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)