0
$\begingroup$

I am using bnlearn and pcalg R packages to obtain the causality map from the datasets. There is an order-independent algorithm which claims to be independent of variables are given as input. When I change the order the variables, directions of arrowheads are changing. Below is the code I am using:

data("gmG")
set.seed(101)
cols = sample(ncol(gmG8$x))
suffStat <- list(C = cor(gmG8$x[,cols]), n = nrow(gmG8$x))
pc.gmG <- pc(suffStat, indepTest = gaussCItest,
               labels = colnames(gmG8$x)[cols], alpha = 0.01)
plot(pc.gmG)

Above code gives me following output:

enter image description here

Now I run the same code with different order of data.

data("gmG")
set.seed(102)
cols = sample(ncol(gmG8$x))
suffStat <- list(C = cor(gmG8$x[,cols]), n = nrow(gmG8$x))
pc.gmG <- pc(suffStat, indepTest = gaussCItest,
               labels = colnames(gmG8$x)[cols], alpha = 0.01)
plot(pc.gmG)

enter image description here

As one can see there the arrows have changed the direction for v6 and v7. Am I missing something here? Note: I am aware of skeleton has been unchanged (graph without arrows).

$\endgroup$

closed as off-topic by whuber Feb 12 at 14:41

  • This question does not appear to be about statistics within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.