Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 11751

Dagitty dose not support coordinates adjustment

$
0
0

I am trying to create a DAG using dagitty. my code is here:

library(dagitty)library(lavaan)adh <- dagitty('dag {        Exp_LCS [pos="0,1"]        Out_FU_Ann_Scn [pos="5,1"]        age [pos="0.5,0"]        sex [pos="1,0"]        Exp_LCS->Out_FU_Ann_Scn        Exp_LCS->False_result->Out_FU_Ann_Scn        Exp_LCS<-age->Out_FU_Ann_Scn        Exp_LCS<-race->Out_FU_Ann_Scn}')plot(adh)

But I got the warning like: "Plot coordinates for graph not supplied! Generating coordinates, see ?coordinates for how to set your own." So, I tried to adjust coordinates by using the code:

library(dagitty)library(lavaan)adh <- dagitty('dag {        Exp_LCS->Out_FU_Ann_Scn;        Exp_LCS->False_result->Out_FU_Ann_Scn;        Exp_LCS<-age->Out_FU_Ann_Scn;        Exp_LCS<-race->Out_FU_Ann_Scn;}')# Manually set coordinates for the nodescoordinates(adh) <- list(  x = c(Exp_LCS=0, Out_FU_Ann_Scn=6, age=0.5, sex=1),  y = c(Exp_LCS=1, Out_FU_Ann_Scn=1, age=0, sex=0))plot(adh)

No matter which way, the coordinates are always generated by the dagitty itself. My specific coordinates information does not work. My system is Windows and R version is the latest one: 4.3.2. Can someone help to tell how to fix it? I expect the Exp_LCS and outcome var: Out_FU_Ann_Scn can be fixed in a line like typical DAG instead of being randomly arranged.

Also, how can I colorize the outcome and exposure variables in R like when I use dagitty online? Thanks a lot!


Viewing all articles
Browse latest Browse all 11751

Trending Articles