Running ‘test_LINGAM.R’ [3s/5s]
  Running ‘test_addBgKnowledge.R’ [2s/3s]
  Running ‘test_adjustment.R’ [4s/6s]
  Running ‘test_ages.R’ [2s/4s]
  Running ‘test_amat2dag.R’ [2s/3s]
  Running ‘test_arges.R’ [2s/3s]
  Running ‘test_backdoor.R’ [8s/10s]
  Comparing ‘test_backdoor.Rout’ to ‘test_backdoor.Rout.save’ ... OK
  Running ‘test_bicscore.R’ [2s/3s]
  Running ‘test_causalEffect.R’ [2s/3s]
  Running ‘test_coercion.R’ [2s/3s]
  Running ‘test_compareGraphs.R’ [2s/2s]
  Running ‘test_dag2cpdag.R’ [2s/3s]
  Running ‘test_dag2essgraph.R’ [2s/3s]
  Running ‘test_displayAmat.R’ [2s/2s]
  Running ‘test_dsep.R’ [2s/3s]
  Running ‘test_fci.R’ [2s/3s]
  Running ‘test_fciPlus.R’ [4s/6s]
  Running ‘test_gSquareBin.R’ [2s/3s]
  Running ‘test_gSquareDis.R’ [3s/5s]
  Running ‘test_gac.R’ [3s/6s]
  Running ‘test_getNextSet.R’ [2s/3s]
  Running ‘test_gies.R’ [3s/4s]
  Running ‘test_ida.R’ [58s/83s]
  Running ‘test_idaFast.R’ [5s/6s]
  Running ‘test_isValidGraph.R’ [4s/6s]
  Running ‘test_jointIda.R’ [2s/4s]
  Running ‘test_mat2targets.R’ [2s/3s]
  Running ‘test_optAdjSet.R’ [2s/3s]
  Running ‘test_opttarget.R’ [1s/3s]
  Running ‘test_pc.R’ [2s/3s]
  Running ‘test_pcSelect.R’ [3s/5s]
  Running ‘test_pcalg2dagitty.R’ [3s/4s]
  Running ‘test_pcorOrder.R’ [1s/3s]
  Running ‘test_pdag2allDags.R’ [1s/3s]
  Running ‘test_pdag2dag.R’ [2s/3s]
  Running ‘test_possDeAn.R’ [2s/4s]
  Running ‘test_randDAG.R’ [3s/5s]
  Comparing ‘test_randDAG.Rout’ to ‘test_randDAG.Rout.save’ ... OK
  Running ‘test_randomDAG.R’ [2s/3s]
  Running ‘test_rfci.R’ [4s/5s]
  Running ‘test_rmvDAG.R’ [2s/3s]
  Running ‘test_shd.R’ [2s/2s]
  Running ‘test_skeleton.R’ [5s/7s]
  Running ‘test_udag2pag.R’ [1s/2s]
  Running ‘test_udag2pdag.R’ [6s/8s]
  Running ‘test_wgtMatrix.R’ [2s/2s]
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 409 2017-02-05 15:41:51Z 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)
  + 
  +     if (any(score$pp.dat$data.count != 1000)) {
  +       stop("The number of non-interventions are not calculated correctly.")
  +     }
  + 
  +     stopifnot(is.list(score$pp.dat$non.int), length(score$pp.dat$non.int) == 5)
  +     stopifnot(all(sapply(1:5, function(j) {
  +       isTRUE(all.equal(score$pp.dat$non.int[[j]],
  +                        setdiff(1:1200, 200*j + 1:200)))
  +     })))
  + 
  +     if (settings$format[m] == "scatter") {
  +       if (!isTRUE(all.equal(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[[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 if (length(object$pp.dat$target.index) != nrow(object$pp.dat$data)) return("Length of target index vector does not coincide with sample size.") : 
    argument is of length zero
  Calls: new ... validObject -> anyStrings -> isTRUE -> validityMethod
  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 454 2017-07-11 15:03:05Z mkalisch $
  > 
  > 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 if (length(object$pp.dat$target.index) != nrow(object$pp.dat$data)) return("Length of target index vector does not coincide with sample size.") : 
    argument is of length zero
  Calls: new ... validObject -> anyStrings -> isTRUE -> validityMethod
  Execution halted