Running ‘test_LINGAM.R’
  Running ‘test_amat2dag.R’
  Running ‘test_arges.R’
  Running ‘test_backdoor.R’
  Comparing ‘test_backdoor.Rout’ to ‘test_backdoor.Rout.save’ ... OK
  Running ‘test_bicscore.R’
  Running ‘test_causalEffect.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’ [10s/15s]
  Running ‘test_fciPlus.R’
  Running ‘test_gSquareBin.R’ [15s/21s]
  Running ‘test_gSquareDis.R’
  Running ‘test_gac.R’
  Running ‘test_getNextSet.R’
  Running ‘test_gies.R’
  Running ‘test_ida.R’
  Running ‘test_idaFast.R’
  Running ‘test_jointIda.R’
  Running ‘test_mat2targets.R’
  Running ‘test_pc.R’
  Running ‘test_pcSelect.R’
  Running ‘test_pcorOrder.R’
  Running ‘test_pdag2allDags.R’
  Running ‘test_pdag2dag.R’
  Running ‘test_randDAG.R’
  Comparing ‘test_randDAG.Rout’ to ‘test_randDAG.Rout.save’ ... OK
  Running ‘test_randomDAG.R’
  Running ‘test_rfci.R’ [32s/41s]
  Running ‘test_rmvDAG.R’
  Running ‘test_shd.R’
  Running ‘test_skeleton.R’
  Running ‘test_udag2pdag.R’
  Running ‘test_unifDAG.R’ [11s/14s]
  Running ‘test_wgtMatrix.R’
Running the tests in ‘tests/test_arges.R’ failed.
Complete output:
  > ####' Tests adaptive versions of GES (ARGES and ARGES-skeleton)
  > ####'
  > ####' @author Alain Hauser
  > ####' $Id: test_arges.R 393 2016-08-20 09:43:47Z alhauser $
  > 
  > cat("Testing adaptive versions of GES:\n")
  Testing adaptive versions of GES:
  > 
  > library(pcalg)
  > library(graph)
  Loading required package: BiocGenerics
  Loading required package: parallel
  
  Attaching package: 'BiocGenerics'
  
  The following objects are masked from 'package:parallel':
  
      clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
      clusterExport, clusterMap, parApply, parCapply, parLapply,
      parLapplyLB, parRapply, parSapply, parSapplyLB
  
  The following objects are masked from 'package:stats':
  
      IQR, mad, sd, var, xtabs
  
  The following objects are masked from 'package:base':
  
      Filter, Find, Map, Position, Reduce, anyDuplicated, append,
      as.data.frame, cbind, colMeans, colSums, colnames, do.call,
      duplicated, eval, evalq, get, grep, grepl, intersect, is.unsorted,
      lapply, lengths, mapply, match, mget, order, paste, pmax, pmax.int,
      pmin, pmin.int, rank, rbind, rowMeans, rowSums, rownames, sapply,
      setdiff, sort, table, tapply, union, unique, unsplit, which,
      which.max, which.min
  
  > 
  > ## Test with DAG of 3 vertices
  > 
  > # Create DAG with 3 vertices a shielded v-structure (A --> B <-- C, A --> C).
  > # The edge weight of A --> C should be smaller than the others.
  > # Only allowing edges between A and B and B and C at the beginning, 
  > # we can check whether ARGES also allows an edge between A and C in the
  > # end.
  > dag <- new("GaussParDAG", 
  +     nodes = as.character(1:3), 
  +     in.edges = list(integer(0), c(1, 3), 1),
  +     params = list(c(0.8, 0), c(0.2, 0, 0.7, 1.2), c(0.6, 0, 0.1)))
  > cpdag <- dag2cpdag(dag)
  > adjMat <- as(cpdag, "matrix")
  > 
  > # Simulate data
  > n <- 5000
  > set.seed(307)
  > X <- rmvnorm.ivent(n, dag)
  > 
  > # Create a score object
  > score <- new("GaussL0penObsScore", X)
  > 
  > # Estimate DAG without restriction
  > ges.fit <- ges(score)
  Error in value[[3L]](cond) : 
    Instance of class 'GaussParDAG' cannot be created.
  Calls: ges ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
  In addition: Warning messages:
  1: In min(x) : no non-missing arguments to min; returning Inf
  2: In max(x) : no non-missing arguments to max; returning -Inf
  Execution halted
Running the tests in ‘tests/test_bicscore.R’ failed.
Complete output:
  > #' Tests the calculation of BIC and MLE, as well as basic functions
  > #' the corresponding score class
  > #' 
  > #' @author Alain Hauser
  > #' $Id: test_bicscore.R 393 2016-08-20 09:43:47Z alhauser $
  > 
  > cat("Testing the calculation of the BIC score...\n")
  Testing the calculation of the BIC score...
  > 
  > library(pcalg)
  > 
  > load("test_bicscore.rda") # in directory tests/ i.e., typically *not* installed
  > 
  > ## Tolerance for numerical comparison
  > tol <- sqrt(.Machine$double.eps)
  > 
  > ## Define all test settings
  > settings <- expand.grid(
  +   format = c("scatter", "raw"),
  +   cpp = c(FALSE, TRUE),
  +   stringsAsFactors = FALSE)
  > nreps <- 5
  > 
  > ## Check data storage and calculation of scores
  > for (m in 1:nrow(settings)) {
  +   cat(sprintf("Setting: storage format = %s, C++ library = %s\n", 
  +           settings$format[m], settings$cpp[m]))
  +   
  +   for (i in 1:nreps) {
  +     perm <- 1:nrow(gauss.data)
  +     
  +     ## Randomly permute data
  +     if (i > 1) {
  +       set.seed(i)
  +       perm <- sample(perm)
  +     }    
  +     
  +     ## Create the score object with valid data
  +     score <- new("GaussL0penIntScore", 
  +         targets = gauss.targets, 
  +         target.index = gauss.target.index[perm], 
  +         data = gauss.data[perm, ],
  +         format = settings$format[m],
  +         use.cpp = settings$cpp[m],
  +         intercept = FALSE)
  +     
  +     # print(score$pp.dat)
  +   
  +     if (any(score$pp.dat$data.count != 1000)) {
  +       stop("The number of non-interventions are not calculated correctly.")
  +     }
  +   
  +     if (settings$format[m] == "scatter") {
  +       if (any(score$pp.dat$scatter.index != 1:5)) {
  +         stop("The indices of the scatter matrices are not calculated correctly.")
  +       }
  +     
  +       for (j in 1:5) {
  +         if (!isTRUE(all.equal(score$pp.dat$scatter[[score$pp.dat$scatter.index[j]]][1:5, 1:5], 
  +             gauss.scatter[[j]], 
  +             tolerance = tol))) {
  +           stop("The scatter matrices are not calculated correctly.")
  +         }
  +       }
  +     } # IF "scatter"
  +     
  +     for (j in 1:5) {
  +       if (!isTRUE(all.equal(gauss.loc.score[[j]], 
  +           score$local.score(j, gauss.parents[[j]]), 
  +           tolerance = tol))) {
  +         stop("The local score is not calculated correctly.")
  +       }
  +     }
  +     
  +     # print(lapply(1:5, function(i) score$local.fit(i, gauss.parents[[i]])))
  +     
  +     for (j in 1:5) {
  +       local.mle <- score$local.fit(j, gauss.parents[[j]])
  +       if (length(local.mle) != length(gauss.mle[[j]]) ||
  +           !isTRUE(all.equal(gauss.mle[[j]], local.mle, 
  +           tolerance = tol))) {
  +         stop("The local MLE is not calculated correctly.")
  +       }
  +     }
  +   }
  + }
  Setting: storage format = scatter, C++ library = FALSE
  Error in validObject(.Object) : 
    invalid class "GaussL0penIntScore" object: The scatter matrices have invalid dimensions.
  Calls: new -> initialize -> initialize -> validObject
  In addition: Warning messages:
  1: In if (sort(unique(object$pp.dat$target.index)) != 1:length(object$pp.dat$targets)) return("Data from all intervention targets must be available") :
    the condition has length > 1 and only the first element will be used
  2: In if (unique(object$pp.dat$scatter.index) != 1:length(object$pp.dat$scatter)) { :
    the condition has length > 1 and only the first element will be used
  Execution halted
Running the tests in ‘tests/test_gies.R’ failed.
Complete output:
  > ####' Tests the causal inference algorithms for interventional data:
  > ####' GIES, GES, DP
  > ####'
  > ####' @author Alain Hauser
  > ####' $Id: test_gies.R 393 2016-08-20 09:43:47Z alhauser $
  > 
  > cat("Testing the causal inference algorithms for interventional data:\n")
  Testing the causal inference algorithms for interventional data:
  > 
  > library(pcalg)
  > 
  > source(system.file(package="Matrix", "test-tools-1.R", mustWork=TRUE))
  Loading required package: tools
  > ##--> showProc.time(), assertError(), relErrV(), ...
  > 
  > load("test_bicscore.rda") # in directory tests/ i.e., typically *not* installed
  > # str(gauss.data)
  > p <- ncol(gauss.data)
  > 
  > (doExtras <- pcalg:::doExtras())
  [1] FALSE
  > DBG <- if(doExtras) TRUE else FALSE # no debugging by default
  > ## Tolerance for numerical comparison
  > tol <- sqrt(.Machine$double.eps) # = default for all.equal()
  > 
  > ## Define all test settings
  > settings <- expand.grid(
  +     fcn = c("gies", "gds"),
  +     cpp = c(FALSE, TRUE),
  +     format = c("scatter", "raw"),
  +     stringsAsFactors = FALSE)
  > nreps <- 5
  > 
  > for (m in seq_along(settings)) {
  +   cat(sprintf("Algorithm: %s, C++: %s, storage format: %s\n", 
  +           settings$fcn[m], settings$cpp[m], settings$format[m]))
  +   
  +   for (i in 1:nreps) {
  +     perm <- 1:nrow(gauss.data)
  +     
  +     ## Randomly permute data
  +     if (i > 1) {
  +       set.seed(i)
  +       perm <- sample(perm)
  +     }
  +     
  +     score <- new("GaussL0penIntScore", 
  +                  targets = gauss.targets, 
  +                  target.index = gauss.target.index[perm], 
  +                  data = gauss.data[perm, ],
  +                  format = settings$format[m],
  +                  use.cpp = settings$cpp[m])
  +     f <- get(settings$fcn[m])
  +     est.graph <- f(score, verbose = DBG)
  +     for (j in 1:p) {
  +       if (!isTRUE(all.equal(est.graph$essgraph$.in.edges[[j]],
  +                             gauss.parents[[j]], tolerance = tol)))
  +         stop("Parents are not estimated correctly.")
  +     }
  +       showProc.time()
  +   }
  +   cat("[Ok]\n")
  + }
  Algorithm: gies, C++: FALSE, storage format: scatter
  Error in validObject(.Object) : 
    invalid class "GaussL0penIntScore" object: The scatter matrices have invalid dimensions.
  Calls: new -> initialize -> initialize -> validObject
  In addition: Warning messages:
  1: In if (sort(unique(object$pp.dat$target.index)) != 1:length(object$pp.dat$targets)) return("Data from all intervention targets must be available") :
    the condition has length > 1 and only the first element will be used
  2: In if (unique(object$pp.dat$scatter.index) != 1:length(object$pp.dat$scatter)) { :
    the condition has length > 1 and only the first element will be used
  Execution halted