From c473a1f7211a821ff4a628e70fe832814fb85fb6 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 13 Sep 2024 15:01:37 +0200 Subject: [PATCH] fix --- R/check_dag.R | 3 +-- tests/testthat/_snaps/check_dag.md | 40 +++++++++++++++--------------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/R/check_dag.R b/R/check_dag.R index 56918c5f9..930c8624f 100644 --- a/R/check_dag.R +++ b/R/check_dag.R @@ -270,9 +270,8 @@ check_dag <- function(..., list( # no adjustment needed when # - required and current adjustment sets are NULL - # - OR required and current adjustments are identical # - AND we have no collider in current adjustments - adjustment_not_needed = ((is.null(adjustment_set) && is.null(adjustment_nodes)) || identical(all_required_adjustments, all_allowed_adjustments)) && is.null(collider), + adjustment_not_needed = is.null(adjustment_set) && is.null(adjustment_nodes) && is.null(collider), # incorrect adjustment when # - required is NULL and current adjustment not NULL # - OR required and current adjustments are *not* identical diff --git a/tests/testthat/_snaps/check_dag.md b/tests/testthat/_snaps/check_dag.md index 7bfcca5a6..84cc7aa38 100644 --- a/tests/testthat/_snaps/check_dag.md +++ b/tests/testthat/_snaps/check_dag.md @@ -26,7 +26,7 @@ Identification of direct and total effects Model is correctly specified. - No adjustment needed to estimate the direct and total effect of `x` on `y`. + All minimal sufficient adjustments to estimate the direct and total effect were done. --- @@ -56,8 +56,8 @@ Identification of direct and total effects - Model is correctly specified. - No adjustment needed to estimate the direct and total effect of `x` on `y`. + Incorrectly adjusted! + To estimate the direct and total effect, at least adjust for `b` and `c`. Currently, the model only adjusts for `c`. You possibly also need to adjust for `b` to block biasing paths. --- @@ -72,8 +72,8 @@ Identification of direct and total effects - Model is correctly specified. - No adjustment needed to estimate the direct and total effect of `x` on `y`. + Incorrectly adjusted! + To estimate the direct and total effect, at least adjust for `b` and `c`. Currently, the model only adjusts for `c`. You possibly also need to adjust for `b` to block biasing paths. --- @@ -89,7 +89,7 @@ Identification of direct and total effects Model is correctly specified. - No adjustment needed to estimate the direct and total effect of `wt` on `mpg`. + All minimal sufficient adjustments to estimate the direct and total effect were done. # check_dag, multiple adjustment sets @@ -120,7 +120,7 @@ Identification of direct and total effects Model is correctly specified. - No adjustment needed to estimate the direct and total effect of `podcast` on `exam`. + All minimal sufficient adjustments to estimate the direct and total effect were done. # check_dag, different adjustements for total and direct @@ -155,13 +155,13 @@ Identification of direct effects - Model is correctly specified. - No adjustment needed to estimate the direct effect of `exposure` on `outcome`. + Incorrectly adjusted! + To estimate the direct effect, at least adjust for `x1` and `x2`. Currently, the model only adjusts for `x1`. You possibly also need to adjust for `x2` to block biasing paths. Identification of total effects Model is correctly specified. - No adjustment needed to estimate the total effect of `exposure` on `outcome`. + All minimal sufficient adjustments to estimate the total effect were done. --- @@ -176,13 +176,13 @@ Identification of direct effects - Model is correctly specified. - No adjustment needed to estimate the direct effect of `exposure` on `outcome`. + Incorrectly adjusted! + To estimate the direct effect, at least adjust for `x1` and `x2`. Currently, the model only adjusts for `x2`. You possibly also need to adjust for `x1` to block biasing paths. Identification of total effects - Model is correctly specified. - No adjustment needed to estimate the total effect of `exposure` on `outcome`. + Incorrectly adjusted! + To estimate the total effect, at least adjust for . Currently, the model only adjusts for `x2`. --- @@ -198,12 +198,12 @@ Identification of direct effects Model is correctly specified. - No adjustment needed to estimate the direct effect of `exposure` on `outcome`. + All minimal sufficient adjustments to estimate the direct effect were done. Identification of total effects - Model is correctly specified. - No adjustment needed to estimate the total effect of `exposure` on `outcome`. + Incorrectly adjusted! + To estimate the total effect, at least adjust for . Currently, the model only adjusts for `x1` and `x2`. # check_dag, collider bias @@ -218,13 +218,13 @@ Identification of direct effects - Model is correctly specified. - No adjustment needed to estimate the direct effect of `agegroup` on `SMD_ICD11`. + Incorrectly adjusted! + To estimate the direct effect, at least adjust for `edgroup3`, `gender_kid`, `pss4_kid_sum_2sd`, `residence` and `sm_h_total_kid`. Currently, the model only adjusts for `edgroup3`, `gender_kid`, `pss4_kid_sum_2sd` and `residence`. You possibly also need to adjust for `sm_h_total_kid` to block biasing paths. Identification of total effects Model is correctly specified. - No adjustment needed to estimate the total effect of `agegroup` on `SMD_ICD11`. + All minimal sufficient adjustments to estimate the total effect were done. ---