Running 'testthat.R' [38s/41s]
Running the tests in 'tests/testthat.R' failed.
Complete output:
  > if (require("testthat")) {
  +     test_check("surveillance")
  + }
  Loading required package: testthat
  Loading required package: surveillance
  Loading required package: sp
  Loading required package: xtable
  This is surveillance 1.17.2. For overview type 'help(surveillance)'.
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  surveillance
   --- call from context --- 
  algo.hhh(influMen, list(lambda = c(1, 1), neighbours = c(NA, 
      0), linear = FALSE, nseason = c(3, 1), negbin = "multiple"), 
      verbose = FALSE)
   --- call from argument --- 
  if (class(cov) == "try-error") {
      if (verbose) {
          cat("Fisher info singular \t loglik=", loglik, " \n")
          cat("theta", round(thetahat, 2), "\n")
          cat("Results are not reliable! Try different starting values. \n")
      }
      res <- list(convergence = FALSE)
      class(res) <- "ah"
      return(res)
  }
   --- R stacktrace ---
  where 1 at testthat/test-hhh4+algo.hhh.R#7: algo.hhh(influMen, list(lambda = c(1, 1), neighbours = c(NA, 
      0), linear = FALSE, nseason = c(3, 1), negbin = "multiple"), 
      verbose = FALSE)
  where 2: eval(code, test_env)
  where 3: eval(code, test_env)
  where 4: withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error)
  where 5: doTryCatch(return(expr), name, parentenv, handler)
  where 6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 7: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 8: doTryCatch(return(expr), name, parentenv, handler)
  where 9: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 10: tryCatchList(expr, classes, parentenv, handlers)
  where 11: tryCatch(withCallingHandlers({
      eval(code, test_env)
      if (!handled && !is.null(test)) {
          skip_empty()
      }
  }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
      message = handle_message, error = handle_error), error = handle_fatal, 
      skip = function(e) {
      })
  where 12: test_code(NULL, exprs, env)
  where 13: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 14: force(code)
  where 15: doWithOneRestart(return(expr), restart)
  where 16: withOneRestart(expr, restarts[[1L]])
  where 17: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 18: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter, 
      {
          reporter$start_file(basename(path))
          lister$start_file(basename(path))
          source_file(path, new.env(parent = env), chdir = TRUE, 
              wrap = wrap)
          reporter$.end_context()
          reporter$end_file()
      })
  where 19: FUN(X[[i]], ...)
  where 20: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 21: force(code)
  where 22: doWithOneRestart(return(expr), restart)
  where 23: withOneRestart(expr, restarts[[1L]])
  where 24: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 25: with_reporter(reporter = current_reporter, results <- lapply(paths, 
      test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
      load_helpers = FALSE, wrap = wrap))
  where 26: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 27: test_dir(path = test_path, reporter = reporter, env = env, filter = filter, 
      ..., stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning, 
      wrap = wrap)
  where 28: test_package_dir(package = package, test_path = test_path, filter = filter, 
      reporter = reporter, ..., stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 29: test_check("surveillance")
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (disProgObj, control = list(lambda = TRUE, neighbours = FALSE, 
      linear = FALSE, nseason = 0, negbin = c("none", "single", 
          "multiple"), proportion = c("none", "single", "multiple"), 
      lag.range = NULL), thetastart = NULL, verbose = TRUE) 
  {
      if (class(disProgObj) == "sts") 
          disProgObj <- sts2disProg(disProgObj)
      if (is.null(control[["linear", exact = TRUE]])) 
          control$linear <- FALSE
      if (is.null(control[["nseason", exact = TRUE]])) 
          control$nseason <- 0
      if (is.null(control[["neighbours", exact = TRUE]])) 
          control$neighbours <- NA
      if (is.null(control[["negbin", exact = TRUE]])) 
          control$negbin <- "none"
      if (is.null(control[["lambda", exact = TRUE]])) 
          control$lambda <- 1
      if (is.null(control[["proportion", exact = TRUE]])) 
          control$proportion <- "none"
      control$negbin <- match.arg(control$negbin, c("single", "multiple", 
          "none"))
      control$proportion <- match.arg(control$proportion, c("single", 
          "multiple", "none"))
      if (is.logical(control[["lambda", exact = TRUE]])) {
          control$lambda <- as.numeric(control$lambda)
          control$lambda[control$lambda == 0] <- NA
      }
      if (is.logical(control[["neighbours", exact = TRUE]])) {
          control$neighbours <- as.numeric(control$neighbours)
          control$neighbours[control$neighbours == 0] <- NA
      }
      if (is.null(control[["lag.range", exact = TRUE]])) {
          lags <- c(control$lambda, control$neighbours)
          control$lag.range <- c(max(c(lags, 1), na.rm = TRUE), 
              max(c(-lags, 0), na.rm = TRUE))
      }
      if (is.vector(disProgObj$observed)) 
          disProgObj$observed <- as.matrix(disProgObj$observed)
      n <- nrow(disProgObj$observed)
      nareas <- ncol(disProgObj$observed)
      if (nareas == 1) {
          control$neighbours <- NA
          control$proportion <- "none"
          control$nseason <- control$nseason[1]
      }
      if (control$proportion != "none") {
          control$neighbours <- NA
          if (sum(!is.na(control$lambda)) == 0 | sum(!is.na(control$lambda)) != 
              nareas) 
              control$lambda <- 1
      }
      if (sum(!is.na(control$neighbours)) > 0 | control$proportion != 
          "none") {
          if (is.null(disProgObj$neighbourhood)) 
              stop("No neighbourhood matrix is provided\n")
          if (any(is.na(disProgObj$neighbourhood))) 
              stop("No correct neighbourhood matrix given\n")
      }
      designRes <- make.design(disProgObj = disProgObj, control = control)
      if (designRes$dim$phi > 0) {
          nOfNeighbours <- designRes$nOfNeighbours
          if ((designRes$dim$phi == 1) & (sum(nOfNeighbours) == 
              0)) 
              stop("Specified model is not in line with neighbourhood matrix\n")
          if ((length(control$neighbours) == nareas) & (any(nOfNeighbours[!is.na(control$neighbours)] == 
              0))) 
              stop("Specified model is not in line with neighbourhood matrix\n")
      }
      else if (designRes$dim$proportion > 0) {
          nOfNeighbours <- designRes$nOfNeighbours
          if ((designRes$dim$proportion == 1) & (sum(nOfNeighbours) == 
              0)) 
              stop("Specified model is not in line with neighbourhood matrix\n")
          if ((designRes$dim$proportion == nareas) & (any(nOfNeighbours == 
              0))) 
              stop("Specified model is not in line with neighbourhood matrix\n")
      }
      dimtheta <- designRes$dimTheta$dim
      dimLambda <- designRes$dimTheta$lambda
      dimPhi <- designRes$dimTheta$phi
      areastart <- log(colMeans(designRes$Y)/designRes$populationFrac[1, 
          ])
      if (!is.null(thetastart)) {
          if (all(length(thetastart) != c(dimtheta, dimtheta - 
              nareas))) {
              cat("thetastart must be of length", dimtheta, "or ", 
                  dimtheta - nareas, "\n")
              return(NULL)
          }
          theta <- thetastart
          if (length(theta) == dimtheta) 
              areastart <- NULL
      }
      else {
          theta <- c(rep(log(0.5), designRes$dimTheta$lambda), 
              rep(log(0.1), designRes$dimTheta$phi), rep(0.5, designRes$dimTheta$proportion), 
              rep(0, designRes$dimTheta$trend + designRes$dimTheta$season), 
              rep(2, designRes$dimTheta$negbin))
      }
      if (!is.null(areastart)) {
          if (dimLambda + dimPhi > 0) {
              Lambda <- getLambda(theta[1:(dimLambda + dimPhi)], 
                  designRes)
              expAlpha <- expAlpha.mm(Lambda, designRes$Y)
              expAlpha[expAlpha <= 0] <- (colMeans(designRes$Y)/designRes$populationFrac[1, 
                  ])[expAlpha <= 0]
              areastart <- log(expAlpha)
          }
          theta <- c(areastart, theta)
      }
      mu <- meanResponse(theta, designRes)$mean
      if (any(mu == 0) | any(!is.finite(mu))) 
          stop("invalid initial values\n")
      mycontrol <- list(fnscale = -1, type = 3, maxit = 1000)
      suppressWarnings(myoptim <- optim(theta, fn = loglikelihood, 
          gr = gradient, control = mycontrol, method = "BFGS", 
          hessian = TRUE, designRes = designRes))
      if (myoptim$convergence == 0) {
          convergence <- TRUE
      }
      else {
          if (verbose) 
              cat("Algorithm has NOT converged. \n")
          res <- list(convergence = FALSE)
          class(res) <- "ah"
          return(res)
      }
      loglik <- myoptim$value
      if (loglik == 0) {
          if (verbose) {
              cat("loglikelihood = 0\n")
              cat("Results are not reliable! Try different starting values. \n")
          }
          res <- list(convergence = FALSE)
          class(res) <- "ah"
          return(res)
      }
      thetahat <- myoptim$par
      fisher <- -myoptim$hessian
      fitted <- meanResponse(thetahat, designRes)$mean
      D <- jacobian(thetahat, designRes)$D
      thetahat <- jacobian(thetahat, designRes)$theta
      cov <- try(D %*% solve(fisher) %*% t(D), silent = TRUE)
      if (class(cov) == "try-error") {
          if (verbose) {
              cat("Fisher info singular \t loglik=", loglik, " \n")
              cat("theta", round(thetahat, 2), "\n")
              cat("Results are not reliable! Try different starting values. \n")
          }
          res <- list(convergence = FALSE)
          class(res) <- "ah"
          return(res)
      }
      if (any(!is.finite(diag(cov))) | any(diag(cov) < 0)) {
          if (verbose) {
              cat("infinite or negative cov\t loglik=", loglik, 
                  "\n")
              cat("theta", round(thetahat, 2), "\n")
              cat("Results are not reliable! Try different starting values. \n")
          }
          res <- list(convergence = FALSE)
          class(res) <- "ah"
          return(res)
      }
      se <- sqrt(diag(cov))
      if (convergence & verbose) 
          cat("Algorithm claims to have converged \n")
      result <- list(coefficients = thetahat, se = se, cov = cov, 
          call = match.call(), loglikelihood = loglik, convergence = convergence, 
          fitted.values = fitted, control = control, disProgObj = disProgObj, 
          lag = designRes$lag, nObs = designRes$nObs)
      class(result) <- "ah"
      return(result)
  }
  <bytecode: 0x970ff00>
  <environment: namespace:surveillance>
   --- function search by body ---
  Function algo.hhh in namespace surveillance has this body.
   ----------- END OF FAILURE REPORT -------------- 
  -- 1. Error: (unknown) (@test-hhh4+algo.hhh.R#7)  ------------------------------
  the condition has length > 1
  Backtrace:
   1. surveillance::algo.hhh(...)
  
  
  Penalized log-likelihood:
  Checking analytical score vector using numDeriv::grad() ...
  [1] TRUE
  Checking analytical Fisher information matrix using numDeriv::hessian() ...
  [1] "Mean relative difference: 3.881263e-07"
  
  Penalized log-likelihood:
  Checking analytical score vector using numDeriv::grad() ...
  [1] TRUE
  Checking analytical Fisher information matrix using numDeriv::hessian() ...
  [1] "Mean relative difference: 1.551014e-07"
  
  Penalized log-likelihood:
  Checking analytical score vector using numDeriv::grad() ...
  [1] TRUE
  Checking analytical Fisher information matrix using numDeriv::hessian() ...
  [1] "Mean relative difference: 3.859334e-07"
  
  Penalized log-likelihood:
  Checking analytical score vector using numDeriv::grad() ...
  [1] TRUE
  Checking analytical Fisher information matrix using numDeriv::hessian() ...
  [1] "Mean relative difference: 3.165475e-07"
  
  Penalized log-likelihood:
  Checking analytical score vector using numDeriv::grad() ...
  [1] TRUE
  Checking analytical Fisher information matrix using numDeriv::hessian() ...
  [1] "Mean relative difference: 1.877109e-07"
  
  Penalized log-likelihood:
  Checking analytical score vector using numDeriv::grad() ...
  [1] TRUE
  Checking analytical Fisher information matrix using numDeriv::hessian() ...
  [1] "Mean relative difference: 5.890145e-07"
  
  Penalized log-likelihood:
  Checking analytical score vector using numDeriv::grad() ...
  [1] TRUE
  Checking analytical Fisher information matrix using numDeriv::hessian() ...
  [1] "Mean relative difference: 1.363046e-07"
  'F' vs. cubature using method = "midpoint" ... TRUE 
  'Fcircle' vs. cubature using method = "midpoint" ... TRUE 
  'deriv' vs. numerical derivative ... TRUE 
  'Deriv' vs. cubature using method = "midpoint" ... TRUE 
  'F' vs. cubature using method = "SV" ... TRUE 
  'Fcircle' vs. cubature using method = "SV" ... TRUE 
  'deriv' vs. numerical derivative ... TRUE 
  'Deriv' vs. cubature using method = "SV" ... TRUE 
  Checking 'intrfr' against a numeric approximation ... OK
  Checking 'intrfr' against a numeric approximation ... OK
  Checking 'intrfr' against a numeric approximation ... OK
  Checking 'intrfr' against a numeric approximation ... OK
  Checking 'intrfr' against a numeric approximation ... OK
  Checking 'intrfr' against a numeric approximation ... OK
  Checking 'intrfr' against a numeric approximation ... OK
  Checking 'intrfr' against a numeric approximation ... OK
  Checking 'intrfr' against a numeric approximation ... OK
  'F' vs. cubature using method = "SV" ... TRUE 
  'Fcircle' vs. cubature using method = "SV" ... TRUE 
  'deriv' vs. numerical derivative ... TRUE 
  'Deriv' vs. cubature using method = "SV" ... 
  	siaf parameter 1: TRUE 
  	siaf parameter 2: TRUE 
  'F' vs. cubature using method = "SV" ... TRUE 
  'Fcircle' vs. cubature using method = "SV" ... TRUE 
  'deriv' vs. numerical derivative ... TRUE 
  'Deriv' vs. cubature using method = "SV" ... TRUE 
  Checking 'intrfr' against a numeric approximation ... OK
  Checking 'intrfr' against a numeric approximation ... OK
  Checking 'intrfr' against a numeric approximation ... OK
  Checking 'intrfr' against a numeric approximation ... OK
  Checking 'intrfr' against a numeric approximation ... OK
  Checking 'intrfr' against a numeric approximation ... OK
  Checking 'intrfr' against a numeric approximation ... OK
  Checking 'intrfr' against a numeric approximation ... OK
  Checking 'intrfr' against a numeric approximation ... OK
  'F' vs. cubature using method = "midpoint" ... TRUE 
  'Fcircle' vs. cubature using method = "midpoint" ... TRUE 
  'deriv' vs. numerical derivative ... TRUE 
  'Deriv' vs. cubature using method = "midpoint" ... 
  	siaf parameter 1: TRUE 
  	siaf parameter 2: TRUE 
  Checking 'intrfr' against a numeric approximation ... OK
  Checking 'intrfr' against a numeric approximation ... OK
  Checking 'intrfr' against a numeric approximation ... OK
  Checking 'intrfr' against a numeric approximation ... OK
  Checking 'intrfr' against a numeric approximation ... OK
  Checking 'intrfr' against a numeric approximation ... OK
  Checking 'intrfr' against a numeric approximation ... OK
  Checking 'intrfr' against a numeric approximation ... OK
  Checking 'intrfr' against a numeric approximation ... OK
  'F' vs. cubature using method = "SV" ... TRUE 
  'deriv' vs. numerical derivative ... TRUE 
  'Deriv' vs. cubature using method = "SV" ... 
  	siaf parameter 1: TRUE 
  	siaf parameter 2: TRUE 
  'F' vs. cubature using method = "midpoint" ... TRUE 
  'Fcircle' vs. cubature using method = "midpoint" ... TRUE 
  'deriv' vs. numerical derivative ... TRUE 
  'Deriv' vs. cubature using method = "midpoint" ... 
  	siaf parameter 1: TRUE 
  	siaf parameter 2: TRUE 
  	siaf parameter 3: TRUE 
  == testthat results  ===========================================================
  [ OK: 281 | SKIPPED: 0 | WARNINGS: 0 | FAILED: 1 ]
  1. Error: (unknown) (@test-hhh4+algo.hhh.R#7) 
  
  Error: testthat unit tests failed
  Execution halted