|
5 | 5 | #' your model based on directed acyclic graphs (DAG). The function checks if a
|
6 | 6 | #' model is correctly adjusted for identifying specific relationships of
|
7 | 7 | #' 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()`. |
10 | 12 | #'
|
11 | 13 | #' `check_dag()` is a convenient wrapper around `ggdag::dagify()`,
|
12 | 14 | #' `dagitty::adjustmentSets()` and `dagitty::adjustedNodes()` to check correct
|
|
52 | 54 | #' the arrow points in both directions. Bi-directed paths often indicate
|
53 | 55 | #' unmeasured cause, or unmeasured confounding, of the two involved variables.
|
54 | 56 | #'
|
| 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 | +#' |
55 | 75 | #' @section Why are DAGs important - the Table 2 fallacy:
|
56 | 76 | #'
|
57 | 77 | #' Correctly thinking about and identifying the relationships between variables
|
@@ -332,7 +352,7 @@ print.check_dag <- function(x, ...) {
|
332 | 352 | datawizard::text_concatenate(out$current_adjustments, enclose = "`"),
|
333 | 353 | "."
|
334 | 354 | )
|
335 |
| - } else if (!any(missing_adjustments)) { |
| 355 | + } else if (!any(missing_adjustments)) { # nolint |
336 | 356 | # Scenario 3: missing adjustments
|
337 | 357 | msg <- paste0(
|
338 | 358 | insight::color_text("Incorrectly adjusted!", "red"),
|
|
0 commit comments