Causality map changing when order of the variables

2019-03-04 08:54发布

问题:

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

回答1:

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)