if (FALSE) { # require("ggdag", quietly = TRUE)
library(performance)
# incorrect adjustment
dag <- check_dag(
y ~ x + b + c,
x ~ b,
outcome = "y",
exposure = "x"
)
dag
plot(dag)
# plot only model with required adjustments
plot(dag, which = "required")
# collider-bias?
dag <- check_dag(
y ~ x + c + d,
x ~ c + d,
b ~ x,
b ~ y,
outcome = "y",
exposure = "x",
adjusted = "c"
)
plot(dag)
# longer labels, automatic detection of outcome and exposure
dag <- check_dag(
QoL ~ age + education + gender,
age ~ education
)
plot(dag)
}
Run the code above in your browser using DataLab