Running ‘test_LINGAM.R’
  Running ‘test_addBgKnowledge.R’
  Running ‘test_adjustment.R’
  Running ‘test_ages.R’
  Running ‘test_amat2dag.R’
  Running ‘test_arges.R’
  Running ‘test_backdoor.R’ [10s/12s]
  Comparing ‘test_backdoor.Rout’ to ‘test_backdoor.Rout.save’ ... OK
  Running ‘test_bicscore.R’
  Running ‘test_causalEffect.R’
  Running ‘test_coercion.R’
  Running ‘test_compareGraphs.R’
  Running ‘test_dag2cpdag.R’
  Running ‘test_dag2essgraph.R’
  Running ‘test_displayAmat.R’
  Running ‘test_dsep.R’
  Running ‘test_fci.R’
  Running ‘test_fciPlus.R’
  Running ‘test_gSquareBin.R’
  Running ‘test_gSquareDis.R’
  Running ‘test_gac.R’
  Running ‘test_getNextSet.R’
  Running ‘test_gies.R’
  Running ‘test_ida.R’ [89s/100s]
  Running ‘test_idaFast.R’
  Running ‘test_isValidGraph.R’
  Running ‘test_jointIda.R’
  Running ‘test_mat2targets.R’
  Running ‘test_optAdjSet.R’
  Running ‘test_opttarget.R’
  Running ‘test_pc.R’
  Running ‘test_pcSelect.R’
  Running ‘test_pcalg2dagitty.R’
  Running ‘test_pcorOrder.R’
  Running ‘test_pdag2allDags.R’
  Running ‘test_pdag2dag.R’
  Running ‘test_possDeAn.R’
  Running ‘test_randDAG.R’
  Comparing ‘test_randDAG.Rout’ to ‘test_randDAG.Rout.save’ ... OK
  Running ‘test_randomDAG.R’
  Running ‘test_rfci.R’
  Running ‘test_rmvDAG.R’
  Running ‘test_shd.R’
  Running ‘test_skeleton.R’
  Running ‘test_udag2pag.R’
  Running ‘test_udag2pdag.R’
  Running ‘test_wgtMatrix.R’
Running the tests in ‘tests/test_adjustment.R’ failed.
Complete output:
  > if(requireNamespace("dagitty")) {
  + library(pcalg)
  + (doExtras <- pcalg:::doExtras())
  + 
  + ## Minimalistic CRAN checks
  + 
  + ## Test 1 ############################
  + ## Test that "no adjustment set" and "empty adjustment set" are distinguished properly
  + x <- 1; y <- 2
  + cpdag <- matrix(c(0,1,1,0),2,2) ## 1 --- 2 => no adj set
  + dag <- matrix(c(0,1,0,0),2,2) ## 1 --> 2 => empty adj set
  + 
  + adjC <- adjustment(amat = cpdag, amat.type = "cpdag", x = 1, y = 2, set.type = "canonical")
  + adjD <- adjustment(amat = dag, amat.type = "dag", x = 1, y = 2, set.type = "canonical")
  + adjP <- adjustment(amat = dag, amat.type = "pdag", x = 1, y = 2, set.type = "canonical")
  + 
  + stopifnot(!identical(adjC, adjD), identical(adjD, adjP) )
  + 
  + ## Test 2 ###############################
  + gacVSadj <- function(amat, x, y ,z, V, type) {
  +   ## gac(z) is TRUE IFF z is returned by adjustment()
  +   ## x,y,z: col positions as used in GAC
  +   ## Result: TRUE is result is equal
  +   typeDG <- switch(type,
  +                    dag = "dag",
  +                    cpdag = "cpdag",
  +                    mag = "mag",
  +                    pag = "pag")
  +   gacRes <- gac(amat,x,y, z, type)$gac 
  +   adjRes <- adjustment(amat = amat, amat.type = typeDG, x = x, y = y, set.type = "all")
  +   if (gacRes) { ## z is valid adj set
  +     res <- any(sapply(adjRes, function(xx) setequal(z, xx)))
  +   } else { ## z is not valid adj set
  +     res <- all(!sapply(adjRes, function(xx) setequal(z, xx)))
  +   }
  +   res
  + }
  + 
  + xx <- TRUE
  + 
  + ## CPDAG 1: Paper Fig 1
  + mFig1 <- matrix(c(0,1,1,0,0,0, 1,0,1,1,1,0, 0,0,0,0,0,1,
  +                   0,1,1,0,1,1, 0,1,0,1,0,1, 0,0,0,0,0,0), 6,6)
  + type <- "cpdag"
  + x <- 3; y <- 6
  + 
  + V <- as.character(1:ncol(mFig1))
  + rownames(mFig1) <- colnames(mFig1) <- V
  + 
  + xx <- xx &  gacVSadj(mFig1,x,y, z=c(2,4), V=V, type)
  + xx <- xx &  gacVSadj(mFig1,x,y, z=c(4,5), V=V, type)
  + 
  + type <- "pag"
  + mFig3a <- matrix(c(0,1,0,0, 1,0,1,1, 0,1,0,1, 0,1,1,0), 4,4)
  + V <- as.character(1:ncol(mFig3a))
  + rownames(mFig3a) <- colnames(mFig3a) <- V
  + xx <- xx & gacVSadj(mFig3a, x=2,      y=4, z=NULL,   V=V, type)
  + 
  + ## DAG 1 from Marloes' Talk
  + mMMd1 <- matrix(c(0,1,0,1,0,0, 0,0,1,0,1,0, 0,0,0,0,0,1,
  +                   0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0,0),6,6)
  + V <- as.character(1:ncol(mMMd1))
  + rownames(mMMd1) <- colnames(mMMd1) <- V
  + 
  + type <- "dag"
  + x <- 1; y <- 3
  + xx <- xx &  gacVSadj(mMMd1, x,y, z=NULL, V=V, type)
  + xx <- xx & gacVSadj(mMMd1, x,y, z= 2, V=V, type)
  + 
  + if (!xx) {
  +   stop("Problem when testing function gacVSadj.")
  + } else {
  +   message("OK, no issues were found.")
  + }
  + 
  + ############################################################
  + ## Extensive checks
  + ############################################################
  + if (doExtras) {
  + 
  + ## Test that "no adjustment set" and "empty adjustment set" are distinguished properly
  + x <- 1; y <- 2
  + cpdag <- matrix(c(0,1,1,0),2,2) ## 1 --- 2 => no adj set
  + dag <- matrix(c(0,1,0,0),2,2) ## 1 --> 2 => empty adj set
  + 
  + adjC <- adjustment(amat = cpdag, amat.type = "cpdag", x = 1, y = 2, set.type = "canonical")
  + adjD <- adjustment(amat = dag, amat.type = "dag", x = 1, y = 2, set.type = "canonical")
  + adjP <- adjustment(amat = dag, amat.type = "pdag", x = 1, y = 2, set.type = "canonical")
  + 
  + stopifnot(!identical(adjC, adjD), identical(adjD, adjP) )
  + 
  + adjCAll <- adjustment(amat = cpdag, amat.type = "cpdag", x = 1, y = 2, set.type = "all")
  + adjDAll <- adjustment(amat = dag, amat.type = "dag", x = 1, y = 2, set.type = "all")
  + adjPAll <- adjustment(amat = dag, amat.type = "pdag", x = 1, y = 2, set.type = "all")
  + 
  + stopifnot( !identical(adjCAll, adjDAll), identical(adjDAll, adjPAll) )
  + 
  + adjCMin <- adjustment(amat = cpdag, amat.type = "cpdag", x = 1, y = 2, set.type = "minimal")
  + adjDMin <- adjustment(amat = dag, amat.type = "dag", x = 1, y = 2, set.type = "minimal")
  + adjPMin <- adjustment(amat = dag, amat.type = "pdag", x = 1, y = 2, set.type = "minimal")
  + 
  + stopifnot( !identical(adjCMin, adjDMin), identical(adjDMin, adjPMin) )
  + 
  + 
  + #####################################################################################
  + ## Test 1: Compare CPDAG and PDAG implementation and validate all sets using gac()
  + #####################################################################################
  + nreps <- 100
  + simRes <- data.frame(setType = rep(NA, nreps), id = rep(NA,nreps), 
  +                      rtCPDAG = rep(NA,nreps), rtPDAG = rep(NA, nreps),
  +                      nSet = rep(NA, nreps), gacCheck = rep(NA, nreps))
  + proc.time()
  + for (i in 1:nreps) {
  +   cat("i = ",i,"\n")
  +   ## generate a graph
  +   seed <- i
  +   set.seed(seed)
  +   p <- sample(x=5:10, size = 1)
  +   prob <- sample(x=3:7/10, size = 1)
  +   g <- pcalg:::randomDAG(p, prob)  ## true DAG
  +   cpdag <- dag2cpdag(g)
  +   cpdag.mat <- t(as(cpdag,"matrix")) ## has correct encoding
  + 
  +   ## define input
  +   amat <- cpdag.mat
  +   x <- sample(x = 1:p, size = 1)
  +   y <- sample(x = setdiff(1:p,x), size = 1)
  +   set.type <- sample(x = c("all", "minimal"), size = 1)
  +   simRes$setType[i] <- set.type
  +   
  +   ## run both methods
  +   simRes$rtCPDAG[i] <- system.time(res1 <- adjustment(amat = amat, amat.type = "cpdag", x = x, y = y, set.type = set.type))[3]
  +   simRes$rtPDAG[i] <- system.time(res2 <- adjustment(amat = amat, amat.type = "pdag", x = x, y = y, set.type = set.type))[3]
  +   simRes$nSet[i] <- length(res1)
  +   
  +   if (length(res1) == 0) {
  +     res1 <- vector("list", 0)
  +   }
  +   if (length(res2) == 0) {
  +     res2 <- vector("list", 0)
  +   }
  +   ## compare results
  +   simRes$id[i] <- identical(res1,res2)
  +   
  +   ## compare results with gac() based on "pdag"
  +   if (length(res2) > 0) {
  +     gc <- TRUE
  +     for (j in 1:length(res2)) {
  +       gc <- gc & gac(amat = amat, x = x, y = y, z = res2[[j]], type = "cpdag")$gac
  +     }
  +     simRes$gacCheck[i] <-  gc
  +   }
  +   
  + }
  + proc.time()
  + 
  + summary(simRes)
  + table(is.na(simRes$gacCheck), simRes$nSet == 0)
  + 
  + ################################################
  + ## Test 2: Check using predefined graphs
  + ################################################
  + gacVSadj <- function(amat, x, y ,z, V, type) {
  +   ## gac(z) is TRUE IFF z is returned by adjustment()
  +   ## x,y,z: col positions as used in GAC
  +   ## Result: TRUE is result is equal
  +   typeDG <- switch(type,
  +                    dag = "dag",
  +                    cpdag = "cpdag",
  +                    mag = "mag",
  +                    pag = "pag")
  +   gacRes <- gac(amat,x,y, z, type)$gac 
  +   adjRes <- adjustment(amat = amat, amat.type = typeDG, x = x, y = y, set.type = "all")
  +   if (gacRes) { ## z is valid adj set
  +     res <- any(sapply(adjRes, function(xx) setequal(z, xx)))
  +   } else { ## z is not valid adj set
  +     res <- all(!sapply(adjRes, function(xx) setequal(z, xx)))
  +   }
  +   res
  + }
  + 
  + xx <- TRUE
  + ##################################################
  + ## DAG / CPDAG
  + ##################################################
  + ## CPDAG 1: Paper Fig 1
  + mFig1 <- matrix(c(0,1,1,0,0,0, 1,0,1,1,1,0, 0,0,0,0,0,1,
  +                   0,1,1,0,1,1, 0,1,0,1,0,1, 0,0,0,0,0,0), 6,6)
  + type <- "cpdag"
  + x <- 3; y <- 6
  + 
  + V <- as.character(1:ncol(mFig1))
  + rownames(mFig1) <- colnames(mFig1) <- V
  + 
  + xx <- xx &  gacVSadj(mFig1,x,y, z=c(2,4), V=V, type)
  + xx <- xx &  gacVSadj(mFig1,x,y, z=c(4,5), V=V, type)
  + xx <- xx &  gacVSadj(mFig1,x,y, z=c(4,2,1), V=V, type)
  + xx <- xx &  gacVSadj(mFig1,x,y, z=c(4,5,1), V=V, type)
  + xx <- xx &  gacVSadj(mFig1,x,y, z=c(4,2,5), V=V, type)
  + xx <- xx &  gacVSadj(mFig1,x,y, z=c(4,2,5,1), V=V, type)
  + xx <- xx & gacVSadj(mFig1,x,y, z= 2,    V=V, type)
  + xx <- xx & gacVSadj(mFig1,x,y, z= NULL, V=V, type)
  + 
  + ## CPDAG 2: Paper Fig 5a
  + mFig5a <- matrix(c(0,1,0,0,0, 1,0,1,0,0, 0,0,0,0,1, 0,0,1,0,0, 0,0,0,0,0), 5,5)
  + V <- as.character(1:ncol(mFig5a))
  + rownames(mFig5a) <- colnames(mFig5a) <- V
  + 
  + type <- "cpdag"
  + x <- c(1,5); y <- 4
  + xx <- xx &  gacVSadj(mFig5a, x,y, z=c(2,3), V=V, type)
  + xx <- xx & gacVSadj(mFig5a, x,y, z= 2,     V=V, type)
  + 
  + ## DAG 1 from Marloes' Talk
  + mMMd1 <- matrix(c(0,1,0,1,0,0, 0,0,1,0,1,0, 0,0,0,0,0,1,
  +                   0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0,0),6,6)
  + V <- as.character(1:ncol(mMMd1))
  + rownames(mMMd1) <- colnames(mMMd1) <- V
  + 
  + type <- "dag"
  + x <- 1; y <- 3
  + xx <- xx &  gacVSadj(mMMd1, x,y, z=NULL, V=V, type)
  + xx <- xx & gacVSadj(mMMd1, x,y, z= 2, V=V, type)
  + xx <- xx &  gacVSadj(mMMd1, x,y, z= 4, V=V, type)
  + xx <- xx & gacVSadj(mMMd1, x,y, z= 5, V=V, type)
  + xx <- xx & gacVSadj(mMMd1, x,y, z= 6, V=V, type)
  + xx <- xx & gacVSadj(mMMd1, x,y, z=c(4,5), V=V, type)
  + 
  + ## DAG 2 from Marloes' Talk
  + mMMd2 <- matrix(c(0,1,0,1,0,0, 0,0,0,0,0,0, 0,1,0,0,1,0,
  +                   0,0,0,0,1,0, 0,0,0,0,0,1, 0,0,0,0,0,0), 6,6)
  + V <- as.character(1:ncol(mMMd2))
  + rownames(mMMd2) <- colnames(mMMd2) <- V
  + 
  + type <- "dag"
  + x <- 4; y <- 6
  + xx <- xx &  gacVSadj(mMMd2, x,y, z= 1, V=V, type)
  + xx <- xx &  gacVSadj(mMMd2, x,y, z= 3, V=V, type)
  + xx <- xx & gacVSadj(mMMd2, x,y, z= 5, V=V, type)
  + xx <- xx & gacVSadj(mMMd2, x,y, z=c(1,5), V=V, type)
  + xx <- xx &  gacVSadj(mMMd2, x,y, z=c(1,2), V=V, type)
  + xx <- xx &  gacVSadj(mMMd2, x,y, z=c(1,3), V=V, type)
  + xx <- xx & gacVSadj(mMMd2, x,y, z= 2, V=V, type)
  + 
  + ##################################################
  + ## PAG
  + ##################################################
  + type <- "pag"
  + mFig3a <- matrix(c(0,1,0,0, 1,0,1,1, 0,1,0,1, 0,1,1,0), 4,4)
  + V <- as.character(1:ncol(mFig3a))
  + rownames(mFig3a) <- colnames(mFig3a) <- V
  + xx <- xx & gacVSadj(mFig3a, x=2,      y=4, z=NULL,   V=V, type)
  + 
  + mFig3b <- matrix(c(0,2,0,0, 3,0,3,3, 0,2,0,3, 0,2,2,0), 4,4)
  + V <- as.character(1:ncol(mFig3b))
  + rownames(mFig3b) <- colnames(mFig3b) <- V
  + xx <- xx & gacVSadj(mFig3b, x=2,      y=4, z=NULL,   V=V, type)
  + 
  + mFig3c <- matrix(c(0,3,0,0, 2,0,3,3, 0,2,0,3, 0,2,2,0), 4,4)
  + V <- as.character(1:ncol(mFig3c))
  + rownames(mFig3c) <- colnames(mFig3c) <- V
  + xx <- xx &  gacVSadj(mFig3c, x=2,      y=4, z=NULL,   V=V, type)
  + 
  + mFig4a <- matrix(c(0,0,1,0,0,0, 0,0,1,0,0,0, 2,2,0,3,3,2,
  +                    0,0,2,0,2,2, 0,0,2,1,0,2, 0,0,1,3,3,0), 6,6)
  + V <- as.character(1:ncol(mFig4a))
  + rownames(mFig4a) <- colnames(mFig4a) <- V
  + xx <- xx & gacVSadj(mFig4a, x=3,      y=4, z=NULL,   V=V, type)
  + xx <- xx &  gacVSadj(mFig4a, x=3,      y=4, z= 6,     V=V, type)
  + xx <- xx &  gacVSadj(mFig4a, x=3,      y=4, z=c(1,6), V=V, type)
  + xx <- xx &  gacVSadj(mFig4a, x=3,      y=4, z=c(2,6), V=V, type)
  + xx <- xx &  gacVSadj(mFig4a, x=3,      y=4, z=c(1,2,6), V=V, type)
  + 
  + mFig4b <- matrix(c(0,0,1,0,0,0, 0,0,1,0,0,0, 2,2,0,0,3,2,
  +                    0,0,0,0,2,2, 0,0,2,3,0,2, 0,0,2,3,2,0), 6,6)
  + V <- as.character(1:ncol(mFig4b))
  + rownames(mFig4b) <- colnames(mFig4b) <- V
  + xx <- xx & gacVSadj(mFig4b, x=3,      y=4, z=NULL,   V=V, type)
  + xx <- xx & gacVSadj(mFig4b, x=3,      y=4, z= 6,     V=V, type)
  + xx <- xx & gacVSadj(mFig4b, x=3,      y=4, z=c(5,6), V=V, type)
  + 
  + mFig5b <- matrix(c(0,1,0,0,0,0,0, 2,0,2,3,0,3,0, 0,1,0,0,0,0,0, 0,2,0,0,3,0,0,
  +                    0,0,0,2,0,2,3, 0,2,0,0,2,0,0, 0,0,0,0,2,0,0), 7,7)
  + V <- as.character(1:ncol(mFig5b))
  + rownames(mFig5b) <- colnames(mFig5b) <- V
  + xx <- xx & gacVSadj(mFig5b, x=c(2,7), y=6, z=NULL,   V=V, type)
  + xx <- xx &  gacVSadj(mFig5b, x=c(2,7), y=6, z=c(4,5), V=V, type)
  + xx <- xx &  gacVSadj(mFig5b, x=c(2,7), y=6, z=c(4,5,1), V=V, type)
  + xx <- xx &  gacVSadj(mFig5b, x=c(2,7), y=6, z=c(4,5,3), V=V, type)
  + xx <- xx &  gacVSadj(mFig5b, x=c(2,7), y=6, z=c(1,3,4,5), V=V, type)
  + 
  + ## PAG in Marloes' talk
  + mMMp <- matrix(c(0,0,0,3,2,0,0, 0,0,0,0,1,0,0, 0,0,0,0,1,0,0, 2,0,0,0,0,3,2,
  +                  3,2,2,0,0,0,3, 0,0,0,2,0,0,0, 0,0,0,2,2,0,0), 7,7)
  + V <- as.character(1:ncol(mMMp))
  + rownames(mMMp) <- colnames(mMMp) <- V
  + 
  + x <- c(5,6); y <- 7
  + xx <- xx & gacVSadj(mMMp, x,y, z=NULL, V=V, type)
  + xx <- xx & gacVSadj(mMMp, x,y, z= 1,   V=V, type)
  + xx <- xx & gacVSadj(mMMp, x,y, z= 4,   V=V, type)
  + xx <- xx & gacVSadj(mMMp, x,y, z= 2,   V=V, type)
  + xx <- xx & gacVSadj(mMMp, x,y, z= 3,   V=V, type)
  + xx <- xx & gacVSadj(mMMp, x,y, z=c(2,3), V=V, type)
  + xx <- xx &  gacVSadj(mMMp, x,y, z=c(1,4), V=V, type)
  + xx <- xx &  gacVSadj(mMMp, x,y, z=c(1,4,2), V=V, type)
  + xx <- xx &  gacVSadj(mMMp, x,y, z=c(1,4,3), V=V, type)
  + xx <- xx &  gacVSadj(mMMp, x,y, z=c(1,4,2,3), V=V, type)
  + 
  + ##################################################
  + ## V=V, type = "pag" -- Tests from Ema
  + ##################################################
  + type <- "pag"
  + pag.m <- readRDS(system.file(package="pcalg", "external", "gac-pags.rds"))
  + m1 <- pag.m[["m1"]]
  + V <- colnames(m1)
  + x <- 6; y <- 9
  + xx <- xx & gacVSadj(m1,x,y, z=NULL, V=V, type)
  + xx <- xx & gacVSadj(m1,x,y, z=1, V=V, type)
  + xx <- xx & gacVSadj(m1,x,y, z=2, V=V, type)
  + xx <- xx & gacVSadj(m1,x,y, z=3, V=V, type)
  + xx <- xx & gacVSadj(m1,x,y, z=4, V=V, type)
  + xx <- xx & gacVSadj(m1,x,y, z=c(2,3), V=V, type)
  + xx <- xx & gacVSadj(m1,x,y, z=c(2,3,8), V=V, type)
  + xx <- xx & gacVSadj(m1,x,y, z=c(2,3,7,8), V=V, type)
  + xx <- xx & gacVSadj(m1,x,y, z=c(2,3,5,8), V=V, type)
  + xx <- xx & gacVSadj(m1,x,y, z=c(2,3,5,7,8), V=V, type)
  + 
  + x <- c(6,8); y <- 9
  + xx <- xx & gacVSadj(m1,x,y, z=NULL, V=V, type)
  + xx <- xx & gacVSadj(m1,x,y, z=1, V=V, type)
  + xx <- xx & gacVSadj(m1,x,y, z=2, V=V, type)
  + xx <- xx & gacVSadj(m1,x,y, z=3, V=V, type)
  + xx <- xx & gacVSadj(m1,x,y, z=4, V=V, type)
  + xx <- xx &  gacVSadj(m1,x,y, z=c(2,3), V=V, type)
  + xx <- xx &  gacVSadj(m1,x,y, z=c(2,3,4), V=V, type)
  + xx <- xx &  gacVSadj(m1,x,y, z=c(2,3,7), V=V, type)
  + xx <- xx & gacVSadj(m1,x,y, z=c(2,3,5), V=V, type)
  + xx <- xx & gacVSadj(m1,x,y, z=c(2,3,5,7), V=V, type)
  + 
  + x <- 3; y <- 1
  + xx <- xx & gacVSadj(m1,x,y, z=NULL, V=V, type)
  + xx <- xx & gacVSadj(m1,x,y, z=2, V=V, type)
  + xx <- xx & gacVSadj(m1,x,y, z=4, V=V, type)
  + xx <- xx & gacVSadj(m1,x,y, z=5, V=V, type)
  + xx <- xx & gacVSadj(m1,x,y, z=6, V=V, type)
  + xx <- xx & gacVSadj(m1,x,y, z=c(2,6), V=V, type)
  + xx <- xx & gacVSadj(m1,x,y, z=c(2,8), V=V, type)
  + xx <- xx & gacVSadj(m1,x,y, z=c(2,7,8), V=V, type)
  + xx <- xx & gacVSadj(m1,x,y, z=c(2,5,8), V=V, type)
  + xx <- xx & gacVSadj(m1,x,y, z=c(2,5,7,8), V=V, type)
  + 
  + m2 <- pag.m[["m2"]]
  + V <- colnames(m2)
  + x <- 3; y <-1
  + xx <- xx & gacVSadj(m2,x,y, z=NULL, V=V, type)
  + xx <- xx &  gacVSadj(m2,x,y, z=2, V=V, type)
  + xx <- xx & gacVSadj(m2,x,y, z=4, V=V, type)
  + xx <- xx & gacVSadj(m2,x,y, z=c(2,8), V=V, type)
  + xx <- xx & gacVSadj(m2,x,y, z=8, V=V, type)
  + xx <- xx & gacVSadj(m2,x,y, z=9, V=V, type)
  + xx <- xx & gacVSadj(m2,x,y, z=c(2,8,9), V=V, type)
  + xx <- xx &  gacVSadj(m2,x,y, z=c(2,5), V=V, type)
  + 
  + x <- c(3,9); y <- 1
  + xx <- xx & gacVSadj(m2,x,y, z=NULL, V=V, type)
  + xx <- xx & gacVSadj(m2,x,y, z=2, V=V, type)
  + xx <- xx & gacVSadj(m2,x,y, z=4, V=V, type)
  + xx <- xx & gacVSadj(m2,x,y, z=c(2,8), V=V, type)
  + xx <- xx & gacVSadj(m2,x,y, z=8, V=V, type)
  + xx <- xx & gacVSadj(m2,x,y, z=9, V=V, type)
  + xx <- xx & gacVSadj(m2,x,y, z=c(2,8,9), V=V, type)
  + xx <- xx & gacVSadj(m2,x,y, z=c(2,5), V=V, type)
  + 
  + m3 <- pag.m[["m3"]]
  + V <- colnames(m3)
  + x <- 1; y <- 9
  + xx <- xx & gacVSadj(m3,x,y, z=NULL, V=V, type)
  + xx <- xx & gacVSadj(m3,x,y, z=2, V=V, type)
  + xx <- xx & gacVSadj(m3,x,y, z=3, V=V, type)
  + xx <- xx & gacVSadj(m3,x,y, z=5, V=V, type)
  + xx <- xx & gacVSadj(m3,x,y, z=7, V=V, type)
  + xx <- xx & gacVSadj(m3,x,y, z=8, V=V, type)
  + xx <- xx &  gacVSadj(m3,x,y, z=c(2,3), V=V, type)
  + xx <- xx &  gacVSadj(m3,x,y, z=c(5,7), V=V, type)
  + 
  + x <- 1; y <- 8
  + xx <- xx & gacVSadj(m3,x,y, z=NULL, V=V, type)
  + xx <- xx & gacVSadj(m3,x,y, z=2, V=V, type)
  + xx <- xx & gacVSadj(m3,x,y, z=3, V=V, type)
  + xx <- xx & gacVSadj(m3,x,y, z=5, V=V, type)
  + xx <- xx &  gacVSadj(m3,x,y, z=7, V=V, type)
  + xx <- xx & gacVSadj(m3,x,y, z=9, V=V, type)
  + xx <- xx &  gacVSadj(m3,x,y, z=c(2,3), V=V, type)
  + xx <- xx & gacVSadj(m3,x,y, z=c(5,9), V=V, type)
  + 
  + if (!xx) {
  +   stop("Problem when testing function gacVSadj.")
  + } else {
  +   message("OK, no issues were found.")
  + }
  + 
  + ##################################################
  + ## given same graph, type=cpdag and type=pdag
  + ## should give same canonical set
  + ##################################################
  + m <- rbind(c(0,1,0,0,0,0),
  +            c(1,0,1,0,0,0),
  +            c(0,1,0,0,0,0),
  +            c(0,0,0,0,0,0),
  +            c(0,1,1,1,0,0),
  +            c(1,0,1,1,1,0))
  + colnames(m) <- rownames(m) <- as.character(1:6)
  + 
  + ## You can see that the current adjustment function outputs different sets
  + ## if type = "cpdag" or type = "pdag" which shouldn't happen 
  + ## because it is the same graph:
  + res1 <- adjustment(m,amat.type="cpdag",2,4,set.type="canonical")
  + res2 <- adjustment(m,amat.type="pdag",2,4,set.type="canonical")
  + 
  + if (!all.equal(res1, res2)) {
  +     stop("Canonical set is not the same for type=cpdag and type=pdag\n")
  + }
  + 
  + }
  + 
  + }
  Loading required namespace: dagitty
  
  
  #
  # Fatal error in , line 0
  # Failed to create ICU collator, are ICU data files missing?
  #
  #
  #
  #FailureMessage Object: 0x7ffd4ae2a500
  ==== C stack trace ===============================
  
      /lib64/libnode.so.64(v8::base::debug::StackTrace::StackTrace()+0x1a) [0x7f0d7ce9045a]
      /lib64/libnode.so.64(+0x92e8b1) [0x7f0d7c4188b1]
      /lib64/libnode.so.64(V8_Fatal(char const*, int, char const*, ...)+0x177) [0x7f0d7ce8bf57]
      /lib64/libnode.so.64(v8::internal::Collator::InitializeCollator(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSObject>, v8::internal::Handle<v8::internal::String>, v8::internal::Handle<v8::internal::JSObject>, v8::internal::Handle<v8::internal::JSObject>)+0x473) [0x7f0d7cb6d413]
      /lib64/libnode.so.64(v8::internal::Runtime_CreateCollator(int, v8::internal::Object**, v8::internal::Isolate*)+0x192) [0x7f0d7cc924a2]
      [0x154dc79dc0d8]
  
   *** caught illegal operation ***
  address 0x7f0d7c2569a5, cause 'illegal operand'
  
  Traceback:
   1: context_eval(join(src), private$context, serialize)
   2: get_str_output(context_eval(join(src), private$context, serialize))
   3: evaluate_js(src, serialize = serialize)
   4: ct$eval(paste("global.", name, "=", value))
   5: .jsassign(xv, .jsp("GraphParser.parseGuess(global.", xv, ").toString()"))
   6: doTryCatch(return(expr), name, parentenv, handler)
   7: tryCatchOne(expr, names, parentenv, handlers[[1L]])
   8: tryCatchList(expr, classes, parentenv, handlers)
   9: tryCatch({    .jsassign(xv, as.character(x))    .jsassign(xv, .jsp("GraphParser.parseGuess(global.", xv,         ").toString()"))    r <- structure(.jsget(xv), class = "dagitty")}, error = function(e) {    stop(e)}, finally = {    .deleteJSVar(xv)})
  10: dagitty::dagitty(result)
  11: pcalg2dagitty(amat = amat, labels = lb, type = amat.type)
  12: adjustment(amat = cpdag, amat.type = "cpdag", x = 1, y = 2, set.type = "canonical")
  An irrecoverable exception occurred. R is aborting now ...
Running the tests in ‘tests/test_pcalg2dagitty.R’ failed.
Complete output:
  > ## Translate amat as describes in amatType to dagitty object
  > if(requireNamespace("dagitty")) {
  + library(pcalg)
  + library(dagitty)
  + suppressWarnings(RNGversion("3.5.0"))
  + doExtras <- pcalg:::doExtras()
  + 
  + res <- rep(FALSE, 10)
  + ####################
  + ## Test DAG 1
  + ####################
  + data(gmG)
  + n <- nrow    (gmG8$x)
  + V <- colnames(gmG8$x) # labels aka node names
  + 
  + amat <- wgtMatrix(gmG8$g)
  + amat[amat != 0] <- 1
  + dagitty_dag1 <- pcalg2dagitty(amat,V,type="dag")
  + ## Use dagitty:::graphLayout instead of just graphLayout
  + ## because Rgraphviz package that R uses has a function w the same name
  + ## par(mfrow=c(1,2))
  + ## plot(gmG8$g, main = "True DAG")
  + ## plot(dagitty:::graphLayout(dagitty_dag1))
  + 
  + res[1] <- (dagitty_dag1 == "dag {\nAuthor\nBar\nCtrl\nGoal\nV5\nV6\nV7\nV8\nAuthor -> Bar\nAuthor -> V6\nAuthor -> V8\nBar -> Ctrl\nBar -> V5\nV5 -> V6\nV5 -> V8\nV6 -> V7\n}\n")
  + 
  + #############
  + ## Test DAG 2
  + #############
  + set.seed(123)
  + p <- 10
  + V <- sample(LETTERS, p)
  + g <- pcalg::randomDAG(p,prob=0.3, V = V)
  + 
  + amat <- wgtMatrix(g)
  + amat[amat != 0] <- 1
  + dagitty_dag2 <- pcalg2dagitty(amat,V,type="dag")
  + ## Use dagitty:::graphLayout instead of just graphLayout
  + ## because Rgraphviz package that R uses has a function w the same name
  + ## par(mfrow=c(1,2))
  + ## plot(g, main = "True DAG")
  + ## plot(dagitty:::graphLayout(dagitty_dag2))
  + 
  + res[2] <- (dagitty_dag2 == "dag {\nA\nH\nJ\nK\nQ\nT\nU\nW\nX\nZ\nA -> Q\nH -> A\nH -> K\nH -> Q\nH -> T\nH -> Z\nJ -> W\nT -> A\nT -> Q\nT -> X\nU -> Q\nU -> W\nU -> X\nW -> K\n}\n")
  + 
  + ###############
  + ## Test CPDAG 1
  + ###############
  + data(gmG)
  + n <- nrow(gmG8$ x)
  + V <- colnames(gmG8$ x) # labels aka node names
  + 
  + ## estimate CPDAG
  + pc.fit <- pc(suffStat = list(C = cor(gmG8$x), n = n),
  +              indepTest = gaussCItest, ## indep.test: partial correlations
  +              alpha=0.01, labels = V, verbose = FALSE)
  + amat <- as(pc.fit, "amat")
  + dagitty_cpdag1 <- pcalg2dagitty(amat,V,type="cpdag")
  + ## Use dagitty:::graphLayout instead of just graphLayout
  + ## because Rgraphviz package that R uses has a function w the same name
  + ## par(mfrow = c(1,2))
  + ## plot(pc.fit)
  + ## plot(dagitty:::graphLayout(dagitty_cpdag1))
  + 
  + res[3] <- (dagitty_cpdag1 == "pdag {\nAuthor\nBar\nCtrl\nGoal\nV5\nV6\nV7\nV8\nAuthor -- Bar\nAuthor -> V6\nAuthor -> V8\nBar -- Ctrl\nBar -> V5\nV5 -> V6\nV5 -> V8\nV6 -> V7\n}\n")
  + 
  + stopifnot(all(res[1:3]))
  + 
  + if (doExtras) {
  + #############
  + ## Test CPDAG 2
  + #############
  + set.seed(135)
  + p <- 10
  + V <- sample(LETTERS, p)
  + g <- dag2cpdag(pcalg::randomDAG(p,prob=0.3, V = V))
  + 
  + amat <- wgtMatrix(g)
  + amat[amat != 0] <- 1
  + dagitty_cpdag2 <- pcalg2dagitty(amat,V,type="cpdag")
  + ## Use dagitty:::graphLayout instead of just graphLayout
  + ## because Rgraphviz package that R uses has a function w the same name
  + ## par(mfrow=c(1,2))
  + ## plot(g)
  + ## plot(dagitty:::graphLayout(dagitty_cpdag2))
  + 
  + res[4] <- (dagitty_cpdag2 == "pdag {\nA\nB\nH\nI\nJ\nK\nO\nS\nV\nX\nA -- I\nA -- J\nA -- V\nA -> B\nA -> O\nH -- I\nH -> B\nI -> B\nJ -- K\nK -> B\nS -- X\nS -> O\nV -> B\n}\n")
  + 
  + #############
  + ## Test MAG 1
  + #############
  + amat <- matrix(c(0,2,0,0, 2,0,3,3, 0,2,0,3, 0,2,2,0), 4,4)
  + V <- LETTERS[1:4]
  + colnames(amat) <- rownames(amat) <- V
  + ## plotAG(amat)
  + dagitty_mag1 <- pcalg2dagitty(amat,V,type="mag")
  + res[5] <- (dagitty_mag1 == "mag {\nA\nB\nC\nD\nA <-> B\nB -> C\nB -> D\nC -> D\n}\n")
  + 
  + #############
  + ## Test MAG 2
  + #############
  + set.seed(78)
  + p <- 8
  + g <- pcalg::randomDAG(p, prob = 0.4)
  + ## Compute the true covariance and then correlation matrix of g:
  + true.corr <- cov2cor(trueCov(g))
  + 
  + ## define nodes 2 and 6 to be latent variables
  + L <- c(2,6)
  + 
  + ## Find PAG
  + ## As dependence "oracle", we use the true correlation matrix in
  + ## gaussCItest() with a large "virtual sample size" and a large alpha:
  + true.pag <- dag2pag(suffStat = list(C= true.corr, n= 10^9),
  +                     indepTest= gaussCItest, graph=g, L=L, alpha= 0.9999)
  + 
  + ## find a valid MAG such that no additional edges are directed into
  + (amat <- pag2magAM(true.pag@amat, 4)) # -> the adj.matrix of the MAG
  + ## plotAG(amat)
  + V <- colnames(amat)
  + dagitty_mag2 <- pcalg2dagitty(amat,V,type="mag")
  + res[6] <- (dagitty_mag2 == "mag {\n1\n2\n3\n4\n5\n6\n1 -> 4\n1 -> 5\n1 -> 6\n2 -> 5\n3 -> 4\n3 -> 6\n4 -> 5\n4 -> 6\n5 <-> 6\n}\n")
  + 
  + #############
  + ## Test PAG 1
  + #############
  + mFig4b <- matrix(c(0,0,1,0,0,0, 0,0,1,0,0,0, 2,2,0,0,3,2,
  +                    0,0,0,0,2,2, 0,0,2,3,0,2, 0,0,2,3,2,0), 6,6)
  + V <- c("V1", "V2", "X", "Y", "V4", "V3")
  + colnames(mFig4b) <- rownames(mFig4b) <- V
  + ## plotAG(mFig4b)
  + 
  + dagitty_pag1 <- pcalg2dagitty(mFig4b,V,type="pag")
  + ## Use dagitty:::graphLayout instead of just graphLayout
  + ## because Rgraphviz package that R uses has a function w the same name
  + ## par(mfrow=c(1,2))
  + ## plot(g)
  + ## plot(dagitty:::graphLayout(dagitty_cpdag2))
  + 
  + res[7] <- (dagitty_pag1 == "pag {\nV1\nV2\nV3\nV4\nX\nY\nV1 @-> X\nV2 @-> X\nV3 -> Y\nV3 <-> V4\nV3 <-> X\nV4 -> Y\nX -> V4\n}\n")
  + 
  + #############
  + ## Test PAG 2
  + #############
  + set.seed(42)
  + p <- 7
  + ## generate and draw random DAG :
  + myDAG <- pcalg::randomDAG(p, prob = 0.4)
  + 
  + ## find skeleton and PAG using the FCI algorithm
  + suffStat <- list(C = cov2cor(trueCov(myDAG)), n = 10^9)
  + fm <- fci(suffStat, indepTest=gaussCItest,
  +            alpha = 0.9999, p=p, doPdsep = FALSE)
  + 
  + amat <- as(fm, "amat")
  + V <- colnames(amat)
  + dagitty_pag2 <- pcalg2dagitty(amat,V,type="pag")
  + 
  + res[8] <- (dagitty_pag2 == "pag {\n1\n2\n3\n4\n5\n6\n7\n1 -> 7\n1 @-> 5\n1 @-> 6\n1 @-@ 3\n2 -> 7\n2 @-> 5\n2 @-> 6\n3 -> 7\n3 @-> 5\n3 @-> 6\n3 @-@ 4\n4 @-> 6\n5 @-> 7\n6 -> 7\n}\n")
  + 
  + #################
  + ## Test empty DAG
  + #################
  + set.seed(123)
  + p <- 10
  + V <- sample(LETTERS, p)
  + g <- pcalg::randomDAG(p,prob=0, V = V)
  + 
  + amat <- wgtMatrix(g)
  + amat[amat != 0] <- 1
  + dagitty_dagE <- pcalg2dagitty(amat,V,type="dag")
  + ## Use dagitty:::graphLayout instead of just graphLayout
  + ## because Rgraphviz package that R uses has a function w the same name
  + ## par(mfrow=c(1,2))
  + ## plot(g, main = "True DAG")
  + ## plot(dagitty:::graphLayout(dagitty_dagE))
  + 
  + res[9] <- (dagitty_dagE == "dag {\nA\nH\nJ\nK\nQ\nT\nU\nW\nX\nZ\n\n}\n")
  + 
  + #################
  + ## Test empty PAG
  + #################
  + set.seed(42)
  + p <- 7
  + ## generate and draw random DAG :
  + myDAG <- pcalg::randomDAG(p, prob = 0)
  + 
  + ## find skeleton and PAG using the FCI algorithm
  + suffStat <- list(C = cov2cor(trueCov(myDAG)), n = 10^9)
  + fm <- fci(suffStat, indepTest=gaussCItest,
  +            alpha = 0.9999, p=p, doPdsep = FALSE)
  + 
  + amat <- as(fm, "amat")
  + V <- colnames(amat)
  + dagitty_pagE <- pcalg2dagitty(amat,V,type="pag")
  + 
  + res[10] <- (dagitty_pagE == "pag {\n1\n2\n3\n4\n5\n6\n7\n\n}\n")
  + 
  + stopifnot(all(res))
  + 
  + ########################################################
  + ## Test via comparison of gac() and isAdjustmentSet() ##
  + ########################################################
  + gacVSdagitty <- function(amat, x, y ,z, V, type) {
  +     ## x,y,z: col positions as used in GAC
  +     ## Result: TRUE is result is equal
  +     typeDG <- switch(type,
  +                      dag = "dag",
  +                      cpdag = "cpdag",
  +                      mag = "mag",
  +                      pag = "pag")
  +     
  +     dgRes <- pcalg2dagitty(amat, V, type = typeDG)
  +     Exp <- V[x]; Out <- V[y]; Z <- V[z]
  +     gacRes <- gac(amat,x,y, z, type)$gac 
  +     dgRes <- dagitty::isAdjustmentSet(x = dgRes, Z = Z, exposure = Exp, outcome = Out)
  +     (gacRes == dgRes)
  + }
  + 
  + ## CPDAG 1: Paper Fig 1
  + ## mFig1 <- matrix(c(0,1,1,0,0,0, 1,0,1,1,1,0, 0,0,0,0,0,1,
  + ##                   0,1,1,0,1,1, 0,1,0,1,0,1, 0,0,0,0,0,0), 6,6)
  + ## V <- as.character(1:nrow(mFig1))
  + ## colnames(mFig1) <- rownames(mFig1) <- V
  + 
  + ## typeGAC <- "cpdag"
  + ## x <- 3; y <- 6
  + ## z <- c(2,4); gacVSdagitty(amat = mFig1, x=x, y=y, z=z, V=V, type=typeGAC)
  + ## z <- c(4,5); gacVSdagitty(amat = mFig1, x=x, y=y, z=z, V=V, type=typeGAC)
  + ## z <- c(4,2,1); gacVSdagitty(amat = mFig1, x=x, y=y, z=z, V=V, type=typeGAC)
  + ## z <- c(4,5,1); gacVSdagitty(amat = mFig1, x=x, y=y, z=z, V=V, type=typeGAC)
  + ## z <- c(4,2,5); gacVSdagitty(amat = mFig1, x=x, y=y, z=z, V=V, type=typeGAC)
  + ## z <- c(4,2,5,1); gacVSdagitty(amat = mFig1, x=x, y=y, z=z, V=V, type=typeGAC)
  + ## z <- 2; gacVSdagitty(amat = mFig1, x=x, y=y, z=z, V=V, type=typeGAC)
  + ## z <- NULL; gacVSdagitty(amat = mFig1, x=x, y=y, z=z, V=V, type=typeGAC)
  + 
  + xx <- TRUE
  + ##################################################
  + ## DAG / CPDAG
  + ##################################################
  + ## CPDAG 1: Paper Fig 1
  + mFig1 <- matrix(c(0,1,1,0,0,0, 1,0,1,1,1,0, 0,0,0,0,0,1,
  +                   0,1,1,0,1,1, 0,1,0,1,0,1, 0,0,0,0,0,0), 6,6)
  + type <- "cpdag"
  + x <- 3; y <- 6
  + 
  + V <- as.character(1:ncol(mFig1))
  + rownames(mFig1) <- colnames(mFig1) <- V
  + 
  + xx <- xx &  gacVSdagitty(mFig1,x,y, z=c(2,4), V=V, type)
  + xx <- xx &  gacVSdagitty(mFig1,x,y, z=c(4,5), V=V, type)
  + xx <- xx &  gacVSdagitty(mFig1,x,y, z=c(4,2,1), V=V, type)
  + xx <- xx &  gacVSdagitty(mFig1,x,y, z=c(4,5,1), V=V, type)
  + xx <- xx &  gacVSdagitty(mFig1,x,y, z=c(4,2,5), V=V, type)
  + xx <- xx &  gacVSdagitty(mFig1,x,y, z=c(4,2,5,1), V=V, type)
  + xx <- xx & gacVSdagitty(mFig1,x,y, z= 2,    V=V, type)
  + xx <- xx & gacVSdagitty(mFig1,x,y, z= NULL, V=V, type)
  + 
  + ## CPDAG 2: Paper Fig 5a
  + mFig5a <- matrix(c(0,1,0,0,0, 1,0,1,0,0, 0,0,0,0,1, 0,0,1,0,0, 0,0,0,0,0), 5,5)
  + V <- as.character(1:ncol(mFig5a))
  + rownames(mFig5a) <- colnames(mFig5a) <- V
  + 
  + type <- "cpdag"
  + x <- c(1,5); y <- 4
  + xx <- xx &  gacVSdagitty(mFig5a, x,y, z=c(2,3), V=V, type)
  + xx <- xx & gacVSdagitty(mFig5a, x,y, z= 2,     V=V, type)
  + 
  + ## DAG 1 from Marloes' Talk
  + mMMd1 <- matrix(c(0,1,0,1,0,0, 0,0,1,0,1,0, 0,0,0,0,0,1,
  +                   0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0,0),6,6)
  + V <- as.character(1:ncol(mMMd1))
  + rownames(mMMd1) <- colnames(mMMd1) <- V
  + 
  + type <- "dag"
  + x <- 1; y <- 3
  + xx <- xx &  gacVSdagitty(mMMd1, x,y, z=NULL, V=V, type)
  + xx <- xx & gacVSdagitty(mMMd1, x,y, z= 2, V=V, type)
  + xx <- xx &  gacVSdagitty(mMMd1, x,y, z= 4, V=V, type)
  + xx <- xx & gacVSdagitty(mMMd1, x,y, z= 5, V=V, type)
  + xx <- xx & gacVSdagitty(mMMd1, x,y, z= 6, V=V, type)
  + xx <- xx & gacVSdagitty(mMMd1, x,y, z=c(4,5), V=V, type)
  + 
  + ## DAG 2 from Marloes' Talk
  + mMMd2 <- matrix(c(0,1,0,1,0,0, 0,0,0,0,0,0, 0,1,0,0,1,0,
  +                   0,0,0,0,1,0, 0,0,0,0,0,1, 0,0,0,0,0,0), 6,6)
  + V <- as.character(1:ncol(mMMd2))
  + rownames(mMMd2) <- colnames(mMMd2) <- V
  + 
  + type <- "dag"
  + x <- 4; y <- 6
  + xx <- xx &  gacVSdagitty(mMMd2, x,y, z= 1, V=V, type)
  + xx <- xx &  gacVSdagitty(mMMd2, x,y, z= 3, V=V, type)
  + xx <- xx & gacVSdagitty(mMMd2, x,y, z= 5, V=V, type)
  + xx <- xx & gacVSdagitty(mMMd2, x,y, z=c(1,5), V=V, type)
  + xx <- xx &  gacVSdagitty(mMMd2, x,y, z=c(1,2), V=V, type)
  + xx <- xx &  gacVSdagitty(mMMd2, x,y, z=c(1,3), V=V, type)
  + xx <- xx & gacVSdagitty(mMMd2, x,y, z= 2, V=V, type)
  + 
  + ##################################################
  + ## PAG
  + ##################################################
  + type <- "pag"
  + mFig3a <- matrix(c(0,1,0,0, 1,0,1,1, 0,1,0,1, 0,1,1,0), 4,4)
  + V <- as.character(1:ncol(mFig3a))
  + rownames(mFig3a) <- colnames(mFig3a) <- V
  + xx <- xx & gacVSdagitty(mFig3a, x=2,      y=4, z=NULL,   V=V, type)
  + 
  + mFig3b <- matrix(c(0,2,0,0, 3,0,3,3, 0,2,0,3, 0,2,2,0), 4,4)
  + V <- as.character(1:ncol(mFig3b))
  + rownames(mFig3b) <- colnames(mFig3b) <- V
  + xx <- xx & gacVSdagitty(mFig3b, x=2,      y=4, z=NULL,   V=V, type)
  + 
  + mFig3c <- matrix(c(0,3,0,0, 2,0,3,3, 0,2,0,3, 0,2,2,0), 4,4)
  + V <- as.character(1:ncol(mFig3c))
  + rownames(mFig3c) <- colnames(mFig3c) <- V
  + xx <- xx &  gacVSdagitty(mFig3c, x=2,      y=4, z=NULL,   V=V, type)
  + 
  + mFig4a <- matrix(c(0,0,1,0,0,0, 0,0,1,0,0,0, 2,2,0,3,3,2,
  +                    0,0,2,0,2,2, 0,0,2,1,0,2, 0,0,1,3,3,0), 6,6)
  + V <- as.character(1:ncol(mFig4a))
  + rownames(mFig4a) <- colnames(mFig4a) <- V
  + xx <- xx & gacVSdagitty(mFig4a, x=3,      y=4, z=NULL,   V=V, type)
  + xx <- xx &  gacVSdagitty(mFig4a, x=3,      y=4, z= 6,     V=V, type)
  + xx <- xx &  gacVSdagitty(mFig4a, x=3,      y=4, z=c(1,6), V=V, type)
  + xx <- xx &  gacVSdagitty(mFig4a, x=3,      y=4, z=c(2,6), V=V, type)
  + xx <- xx &  gacVSdagitty(mFig4a, x=3,      y=4, z=c(1,2,6), V=V, type)
  + 
  + mFig4b <- matrix(c(0,0,1,0,0,0, 0,0,1,0,0,0, 2,2,0,0,3,2,
  +                    0,0,0,0,2,2, 0,0,2,3,0,2, 0,0,2,3,2,0), 6,6)
  + V <- as.character(1:ncol(mFig4b))
  + rownames(mFig4b) <- colnames(mFig4b) <- V
  + xx <- xx & gacVSdagitty(mFig4b, x=3,      y=4, z=NULL,   V=V, type)
  + xx <- xx & gacVSdagitty(mFig4b, x=3,      y=4, z= 6,     V=V, type)
  + xx <- xx & gacVSdagitty(mFig4b, x=3,      y=4, z=c(5,6), V=V, type)
  + 
  + mFig5b <- matrix(c(0,1,0,0,0,0,0, 2,0,2,3,0,3,0, 0,1,0,0,0,0,0, 0,2,0,0,3,0,0,
  +                    0,0,0,2,0,2,3, 0,2,0,0,2,0,0, 0,0,0,0,2,0,0), 7,7)
  + V <- as.character(1:ncol(mFig5b))
  + rownames(mFig5b) <- colnames(mFig5b) <- V
  + xx <- xx & gacVSdagitty(mFig5b, x=c(2,7), y=6, z=NULL,   V=V, type)
  + xx <- xx &  gacVSdagitty(mFig5b, x=c(2,7), y=6, z=c(4,5), V=V, type)
  + xx <- xx &  gacVSdagitty(mFig5b, x=c(2,7), y=6, z=c(4,5,1), V=V, type)
  + xx <- xx &  gacVSdagitty(mFig5b, x=c(2,7), y=6, z=c(4,5,3), V=V, type)
  + xx <- xx &  gacVSdagitty(mFig5b, x=c(2,7), y=6, z=c(1,3,4,5), V=V, type)
  + 
  + ## PAG in Marloes' talk
  + mMMp <- matrix(c(0,0,0,3,2,0,0, 0,0,0,0,1,0,0, 0,0,0,0,1,0,0, 2,0,0,0,0,3,2,
  +                  3,2,2,0,0,0,3, 0,0,0,2,0,0,0, 0,0,0,2,2,0,0), 7,7)
  + V <- as.character(1:ncol(mMMp))
  + rownames(mMMp) <- colnames(mMMp) <- V
  + 
  + x <- c(5,6); y <- 7
  + xx <- xx & gacVSdagitty(mMMp, x,y, z=NULL, V=V, type)
  + xx <- xx & gacVSdagitty(mMMp, x,y, z= 1,   V=V, type)
  + xx <- xx & gacVSdagitty(mMMp, x,y, z= 4,   V=V, type)
  + xx <- xx & gacVSdagitty(mMMp, x,y, z= 2,   V=V, type)
  + xx <- xx & gacVSdagitty(mMMp, x,y, z= 3,   V=V, type)
  + xx <- xx & gacVSdagitty(mMMp, x,y, z=c(2,3), V=V, type)
  + xx <- xx &  gacVSdagitty(mMMp, x,y, z=c(1,4), V=V, type)
  + xx <- xx &  gacVSdagitty(mMMp, x,y, z=c(1,4,2), V=V, type)
  + xx <- xx &  gacVSdagitty(mMMp, x,y, z=c(1,4,3), V=V, type)
  + xx <- xx &  gacVSdagitty(mMMp, x,y, z=c(1,4,2,3), V=V, type)
  + 
  + ##################################################
  + ## V=V, type = "pag" -- Tests from Ema
  + ##################################################
  + type <- "pag"
  + pag.m <- readRDS(system.file("external/gac-pags.rds", package="pcalg"))
  + m1 <- pag.m[["m1"]]
  + V <- colnames(m1)
  + x <- 6; y <- 9
  + xx <- xx & gacVSdagitty(m1,x,y, z=NULL, V=V, type)
  + xx <- xx & gacVSdagitty(m1,x,y, z=1, V=V, type)
  + xx <- xx & gacVSdagitty(m1,x,y, z=2, V=V, type)
  + xx <- xx & gacVSdagitty(m1,x,y, z=3, V=V, type)
  + xx <- xx & gacVSdagitty(m1,x,y, z=4, V=V, type)
  + xx <- xx & gacVSdagitty(m1,x,y, z=c(2,3), V=V, type)
  + xx <- xx & gacVSdagitty(m1,x,y, z=c(2,3,8), V=V, type)
  + xx <- xx & gacVSdagitty(m1,x,y, z=c(2,3,7,8), V=V, type)
  + xx <- xx & gacVSdagitty(m1,x,y, z=c(2,3,5,8), V=V, type)
  + xx <- xx & gacVSdagitty(m1,x,y, z=c(2,3,5,7,8), V=V, type)
  + 
  + x <- c(6,8); y <- 9
  + xx <- xx & gacVSdagitty(m1,x,y, z=NULL, V=V, type)
  + xx <- xx & gacVSdagitty(m1,x,y, z=1, V=V, type)
  + xx <- xx & gacVSdagitty(m1,x,y, z=2, V=V, type)
  + xx <- xx & gacVSdagitty(m1,x,y, z=3, V=V, type)
  + xx <- xx & gacVSdagitty(m1,x,y, z=4, V=V, type)
  + xx <- xx &  gacVSdagitty(m1,x,y, z=c(2,3), V=V, type)
  + xx <- xx &  gacVSdagitty(m1,x,y, z=c(2,3,4), V=V, type)
  + xx <- xx &  gacVSdagitty(m1,x,y, z=c(2,3,7), V=V, type)
  + xx <- xx & gacVSdagitty(m1,x,y, z=c(2,3,5), V=V, type)
  + xx <- xx & gacVSdagitty(m1,x,y, z=c(2,3,5,7), V=V, type)
  + 
  + x <- 3; y <- 1
  + xx <- xx & gacVSdagitty(m1,x,y, z=NULL, V=V, type)
  + xx <- xx & gacVSdagitty(m1,x,y, z=2, V=V, type)
  + xx <- xx & gacVSdagitty(m1,x,y, z=4, V=V, type)
  + xx <- xx & gacVSdagitty(m1,x,y, z=5, V=V, type)
  + xx <- xx & gacVSdagitty(m1,x,y, z=6, V=V, type)
  + xx <- xx & gacVSdagitty(m1,x,y, z=c(2,6), V=V, type)
  + xx <- xx & gacVSdagitty(m1,x,y, z=c(2,8), V=V, type)
  + xx <- xx & gacVSdagitty(m1,x,y, z=c(2,7,8), V=V, type)
  + xx <- xx & gacVSdagitty(m1,x,y, z=c(2,5,8), V=V, type)
  + xx <- xx & gacVSdagitty(m1,x,y, z=c(2,5,7,8), V=V, type)
  + 
  + m2 <- pag.m[["m2"]]
  + V <- colnames(m2)
  + x <- 3; y <-1
  + xx <- xx & gacVSdagitty(m2,x,y, z=NULL, V=V, type)
  + xx <- xx &  gacVSdagitty(m2,x,y, z=2, V=V, type)
  + xx <- xx & gacVSdagitty(m2,x,y, z=4, V=V, type)
  + xx <- xx & gacVSdagitty(m2,x,y, z=c(2,8), V=V, type)
  + xx <- xx & gacVSdagitty(m2,x,y, z=8, V=V, type)
  + xx <- xx & gacVSdagitty(m2,x,y, z=9, V=V, type)
  + xx <- xx & gacVSdagitty(m2,x,y, z=c(2,8,9), V=V, type)
  + xx <- xx &  gacVSdagitty(m2,x,y, z=c(2,5), V=V, type)
  + 
  + x <- c(3,9); y <- 1
  + xx <- xx & gacVSdagitty(m2,x,y, z=NULL, V=V, type)
  + xx <- xx & gacVSdagitty(m2,x,y, z=2, V=V, type)
  + xx <- xx & gacVSdagitty(m2,x,y, z=4, V=V, type)
  + xx <- xx & gacVSdagitty(m2,x,y, z=c(2,8), V=V, type)
  + xx <- xx & gacVSdagitty(m2,x,y, z=8, V=V, type)
  + xx <- xx & gacVSdagitty(m2,x,y, z=9, V=V, type)
  + xx <- xx & gacVSdagitty(m2,x,y, z=c(2,8,9), V=V, type)
  + xx <- xx & gacVSdagitty(m2,x,y, z=c(2,5), V=V, type)
  + 
  + m3 <- pag.m[["m3"]]
  + V <- colnames(m3)
  + x <- 1; y <- 9
  + xx <- xx & gacVSdagitty(m3,x,y, z=NULL, V=V, type)
  + xx <- xx & gacVSdagitty(m3,x,y, z=2, V=V, type)
  + xx <- xx & gacVSdagitty(m3,x,y, z=3, V=V, type)
  + xx <- xx & gacVSdagitty(m3,x,y, z=5, V=V, type)
  + xx <- xx & gacVSdagitty(m3,x,y, z=7, V=V, type)
  + xx <- xx & gacVSdagitty(m3,x,y, z=8, V=V, type)
  + xx <- xx &  gacVSdagitty(m3,x,y, z=c(2,3), V=V, type)
  + xx <- xx &  gacVSdagitty(m3,x,y, z=c(5,7), V=V, type)
  + 
  + x <- 1; y <- 8
  + xx <- xx & gacVSdagitty(m3,x,y, z=NULL, V=V, type)
  + xx <- xx & gacVSdagitty(m3,x,y, z=2, V=V, type)
  + xx <- xx & gacVSdagitty(m3,x,y, z=3, V=V, type)
  + xx <- xx & gacVSdagitty(m3,x,y, z=5, V=V, type)
  + xx <- xx &  gacVSdagitty(m3,x,y, z=7, V=V, type)
  + xx <- xx & gacVSdagitty(m3,x,y, z=9, V=V, type)
  + xx <- xx &  gacVSdagitty(m3,x,y, z=c(2,3), V=V, type)
  + xx <- xx & gacVSdagitty(m3,x,y, z=c(5,9), V=V, type)
  + 
  + if (!xx) {
  +     stop("Problem when testing function gacVSdagitty.")
  + } else {
  +     message("OK, no issues were found.")
  + }
  + }
  + }
  Loading required namespace: dagitty
  
  Attaching package: 'dagitty'
  
  The following object is masked from 'package:pcalg':
  
      randomDAG
  
  
  
  #
  # Fatal error in , line 0
  # Failed to create ICU collator, are ICU data files missing?
  #
  #
  #
  #FailureMessage Object: 0x7ffdfe57d830
  ==== C stack trace ===============================
  
      /lib64/libnode.so.64(v8::base::debug::StackTrace::StackTrace()+0x1a) [0x7f34fb32545a]
      /lib64/libnode.so.64(+0x92e8b1) [0x7f34fa8ad8b1]
      /lib64/libnode.so.64(V8_Fatal(char const*, int, char const*, ...)+0x177) [0x7f34fb320f57]
      /lib64/libnode.so.64(v8::internal::Collator::InitializeCollator(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSObject>, v8::internal::Handle<v8::internal::String>, v8::internal::Handle<v8::internal::JSObject>, v8::internal::Handle<v8::internal::JSObject>)+0x473) [0x7f34fb002413]
      /lib64/libnode.so.64(v8::internal::Runtime_CreateCollator(int, v8::internal::Object**, v8::internal::Isolate*)+0x192) [0x7f34fb1274a2]
      [0x16fc31b5c0d8]
  
   *** caught illegal operation ***
  address 0x7f34fa6eb9a5, cause 'illegal operand'
  
  Traceback:
   1: context_eval(join(src), private$context, serialize)
   2: get_str_output(context_eval(join(src), private$context, serialize))
   3: evaluate_js(src, serialize = serialize)
   4: ct$eval(paste("global.", name, "=", value))
   5: .jsassign(xv, .jsp("GraphParser.parseGuess(global.", xv, ").toString()"))
   6: doTryCatch(return(expr), name, parentenv, handler)
   7: tryCatchOne(expr, names, parentenv, handlers[[1L]])
   8: tryCatchList(expr, classes, parentenv, handlers)
   9: tryCatch({    .jsassign(xv, as.character(x))    .jsassign(xv, .jsp("GraphParser.parseGuess(global.", xv,         ").toString()"))    r <- structure(.jsget(xv), class = "dagitty")}, error = function(e) {    stop(e)}, finally = {    .deleteJSVar(xv)})
  10: dagitty::dagitty(result)
  11: pcalg2dagitty(amat, V, type = "cpdag")
  An irrecoverable exception occurred. R is aborting now ...