0

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

Artiga
  • 776
  • 2
  • 16
  • 37

1 Answers1

0

I found the answer. Causality map can be made fully order-independent by setting conservative or maj.rule to TRUE with solve.confl = TRUE.

pc.gmG <- pc(suffStat, indepTest = gaussCItest,skel.method = 'stable',
                  conservative = TRUE,solve.confl = TRUE,
               labels = colnames(gmG8$x)[cols], alpha = 0.01)
Artiga
  • 776
  • 2
  • 16
  • 37