Skip to content

Commit 66ac653

Browse files
test: add failing test for multiple colliders bug (#878) (#879)
Co-authored-by: Daniel <mail@danielluedecke.de>
1 parent c6125fe commit 66ac653

3 files changed

Lines changed: 28 additions & 1 deletion

File tree

R/check_dag.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ check_dag <- function(
347347
# - required is NULL and current adjustment not NULL
348348
# - OR we have a collider in current adjustments
349349
incorrectly_adjusted = (is.null(adjustment_set) && !is.null(adjustment_nodes)) ||
350-
(!is.null(collider) && collider %in% adjustment_nodes), # nolint
350+
(!is.null(collider) && any(collider %in% adjustment_nodes)), # nolint
351351
current_adjustments = adjustment_nodes,
352352
minimal_adjustments = minimal_adjustments,
353353
collider = collider

inst/WORDLIST

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Dominicy
6262
Dordrecht
6363
Dorie
6464
Dunson
65+
Dunkler
6566
Durbin
6667
Dxy
6768
Döring
@@ -88,6 +89,8 @@ Gabry
8889
Gazen
8990
Gelman
9091
Gnanadesikan
92+
Graham
93+
Gregorich
9194
Guilford
9295
Hartig
9396
HDI
@@ -158,6 +161,7 @@ Michalos
158161
Moosbrugger
159162
Monette
160163
Mora
164+
Morrissey
161165
Multicollinearity
162166
MuMIn
163167
NFI
@@ -178,6 +182,9 @@ OSF
178182
OSX
179183
Olkin
180184
PNFI
185+
Papeş
186+
Pandey
187+
Park
181188
Pek
182189
Petrov
183190
polychoric
@@ -202,6 +209,7 @@ Rousseeuw
202209
Routledge
203210
Rouder
204211
Rouder's
212+
Ruxton
205213
SEM
206214
SRMR
207215
Scheepers
@@ -220,6 +228,7 @@ Specifity
220228
Sphericity
221229
Springer
222230
Stata
231+
Strohmaier
223232
Subscales
224233
TLI
225234
Technometrics

tests/testthat/test-check_dag.R

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,21 @@ test_that("check_dag, formula-interface", {
201201
)
202202
expect_identical(dag, dag2)
203203
})
204+
205+
206+
test_that("check_dag handles multiple colliders correctly - issue #878", {
207+
# This test reproduces the error from issue #878
208+
# The DAG has multiple colliders (both 'a' and 'b' are colliders)
209+
# because they both have multiple incoming paths from 'c' and 'd'
210+
# This test FAILS while bug exists, PASSES after fix
211+
expect_no_error(
212+
check_dag(
213+
y ~ x + a + b,
214+
a ~ c + d,
215+
b ~ c + d,
216+
outcome = "y",
217+
exposure = "x",
218+
adjusted = ~ a + b
219+
)
220+
)
221+
})

0 commit comments

Comments
 (0)