Skip to content

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

@malcolmbarrett

Description

@malcolmbarrett

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions