Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

paths() does not check DAG for existing adjusted nodes #97

Open
malcolmbarrett opened this issue Aug 27, 2024 · 1 comment
Open

paths() does not check DAG for existing adjusted nodes #97

malcolmbarrett opened this issue Aug 27, 2024 · 1 comment

Comments

@malcolmbarrett
Copy link
Contributor

I tripped myself up today because I expected paths() to be aware of the variables already adjusted in a DAG just like how it is aware of the exposure and outcome.

library(dagitty)
x <- dagitty('dag {
m [pos="1.000,0.000"]
x [exposure,pos="0.000,1.000"]
y [outcome,pos="2.000,1.000"]
x -> m
y -> m
}')
adjustedNodes(x) <- "m"
paths(x)
#> $paths
#> [1] "x -> m <- y"
#> 
#> $open
#> [1] FALSE
paths(x, Z = adjustedNodes(x))
#> $paths
#> [1] "x -> m <- y"
#> 
#> $open
#> [1] TRUE

Created on 2024-08-27 with reprex v2.1.1

I suggest that adjustedNodes(x) is a better default argument for Z. Happy to make a PR if you agree (as well as check for other locations where this is a sensible default)

@jtextor
Copy link
Owner

jtextor commented Dec 6, 2024

Hi Malcolm, this could make sense but I am indeed not sure whether someone relies on the current default. There is also now a new node attribute "selected" that refers to conditioning as opposed to adjustment, so I think then the default should at least be something like union( adjustedNodes( x ), selectedNodes( x ) ) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants