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:
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)
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).