Running ‘testthat.R’ [3s/5s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
  > library(testthat)
  > library(revdbayes)
  > 
  > test_check("revdbayes")
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  revdbayes
   --- call from context --- 
  gev_mle(gum_init, data = data, m = m, sum_gev = sum_gev)
   --- call from argument --- 
  if (class(temp$hessian) == "try-error") {
      temp$cov <- temp$se <- NULL
      return(temp)
  }
   --- R stacktrace ---
  where 1: gev_mle(gum_init, data = data, m = m, sum_gev = sum_gev)
  where 2: (function (data, m = length(data[!is.na(data)]), x1 = min(data, 
      na.rm = TRUE), xm = max(data, na.rm = TRUE), sum_gev = sum(data, 
      na.rm = TRUE), xi_eq_zero = FALSE, init_ests = NULL) 
  {
      sr <- sqrt(xm - x1)
      theta_to_phi <- function(theta) {
          phi1 <- theta[1]
          phi2 <- (theta[2] + theta[3] * (x1 - theta[1]))/sr
          phi3 <- (theta[2] + theta[3] * (xm - theta[1]))/sr
          c(phi1, phi2, phi3)
      }
      if (!is.null(init_ests)) {
          return(theta_to_phi(init_ests))
      }
      sigma_init <- stats::sd(data) * sqrt(6)/pi
      mu_init <- mean(data) - sigma_init * 0.577215664901532
      gum_init <- c(mu_init, sigma_init, 0)
      if (xi_eq_zero) {
          init <- gum_init
          init_phi <- theta_to_phi(init)
          fish <- gev_fish(gum_init)
          cov_mtx <- solve(fish)/m
          se <- sqrt(diag(cov_mtx))
          row1 <- c(1, 0, 0)
          row2 <- c(-gum_init[3], 1, x1 - gum_init[1])/sr
          row3 <- c(-gum_init[3], 1, xm - gum_init[1])/sr
          mat <- rbind(row1, row2, row3)
          var_phi <- mat %*% cov_mtx %*% t(mat)
          se_phi <- sqrt(diag(var_phi))
          return(list(init = init, se = se, init_phi = init_phi, 
              se_phi = se_phi))
      }
      ests_ok <- ses_ok <- FALSE
      temp <- gev_mle(gum_init, data = data, m = m, sum_gev = sum_gev)
      init <- temp$mle
      if (init[3] > -1 & !is.infinite(temp$nllh)) {
          ests_ok <- TRUE
          if (init[3] > -0.25 & !is.null(temp$cov)) {
              cov_mtx <- temp$cov
              se <- sqrt(diag_pos(cov_mtx))
              row1 <- c(1, 0, 0)
              row2 <- c(-init[3], 1, x1 - init[1])/sr
              row3 <- c(-init[3], 1, xm - init[1])/sr
              mat <- rbind(row1, row2, row3)
              var_phi <- mat %*% cov_mtx %*% t(mat)
              if (all(diag(var_phi) > 0)) {
                  se_phi <- sqrt(diag(var_phi))
                  ses_ok <- TRUE
              }
          }
      }
      if (!ests_ok | !ses_ok) {
          pwm <- gev_pwm(data)
          se <- pwm$se
          cov_mtx <- pwm$cov
          row1 <- c(1, 0, 0)
          row2 <- c(-pwm$est[3], 1, x1 - pwm$est[1])/sr
          row3 <- c(-pwm$est[3], 1, xm - pwm$est[1])/sr
          mat <- rbind(row1, row2, row3)
          var_phi <- mat %*% cov_mtx %*% t(mat)
          se_phi <- sqrt(diag(var_phi))
          check <- gev_loglik(pars = pwm$est, data = data, m = m, 
              x1 = x1, xm = xm, sum_gev = sum_gev)
          if (!ests_ok & init[3] > -1 & !is.infinite(check)) {
              init <- pwm$est
              ests_ok <- TRUE
          }
      }
      if (!ests_ok) {
          init <- gev_lrs(data)
          check <- gev_loglik(pars = pwm$est, data = data, m = m, 
              x1 = x1, xm = xm, sum_gev = sum_gev)
          if (init[3] > -1 & !is.infinite(check)) {
              ests_ok <- TRUE
          }
      }
      if (!ests_ok) {
          xbar <- sum_gev/m
          mu <- ((m + 1) * xm/m + xbar)/2
          sigma <- ((m + 1) * xm/m - xbar)/2
          init <- c(mu, sigma, -1)
      }
      init_phi <- theta_to_phi(init)
      return(list(init = init, se = se, init_phi = init_phi, se_phi = se_phi))
  })(data = c(4.03, 3.83, 3.65, 3.88, 4.01, 4.08, 4.18, 3.8, 4.36, 
  3.96, 3.98, 4.69, 3.85, 3.96, 3.85, 3.93, 3.75, 3.63, 3.57, 4.25, 
  3.97, 4.05, 4.24, 4.22, 3.73, 4.37, 4.06, 3.71, 3.96, 4.06, 4.55, 
  3.79, 3.89, 4.11, 3.85, 3.86, 3.86, 4.21, 4.01, 4.11, 4.24, 3.96, 
  4.21, 3.74, 3.85, 3.88, 3.66, 4.11, 3.71, 4.18, 3.9, 3.78, 3.91, 
  3.72, 4, 3.66, 3.62, 4.33, 4.55, 3.75, 4.08, 3.9, 3.88, 3.94, 
  4.33), m = 65L, x1 = 3.57, xm = 4.69, sum_gev = 258.74)
  where 3: do.call(gev_init, ds)
  where 4 at testthat/test-predict_evpost.R#18: rpost_rcpp(n = 1000, model = "gev", prior = pn, data = portpirie)
  where 5: eval(code, test_env)
  where 6: eval(code, test_env)
  where 7: 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 8: doTryCatch(return(expr), name, parentenv, handler)
  where 9: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 10: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 11: doTryCatch(return(expr), name, parentenv, handler)
  where 12: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 13: tryCatchList(expr, classes, parentenv, handlers)
  where 14: 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 15: test_code(NULL, exprs, env)
  where 16: source_file(path, new.env(parent = env), chdir = TRUE, wrap = wrap)
  where 17: force(code)
  where 18: doWithOneRestart(return(expr), restart)
  where 19: withOneRestart(expr, restarts[[1L]])
  where 20: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 21: 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 22: FUN(X[[i]], ...)
  where 23: lapply(paths, test_file, env = env, reporter = current_reporter, 
      start_end_reporter = FALSE, load_helpers = FALSE, wrap = wrap)
  where 24: force(code)
  where 25: doWithOneRestart(return(expr), restart)
  where 26: withOneRestart(expr, restarts[[1L]])
  where 27: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 28: 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 29: test_files(paths, reporter = reporter, env = env, stop_on_failure = stop_on_failure, 
      stop_on_warning = stop_on_warning, wrap = wrap)
  where 30: 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 31: 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 32: test_check("revdbayes")
  
   --- value of length: 2 type: logical ---
  [1] FALSE FALSE
   --- function from context --- 
  function (init, ...) 
  {
      x <- stats::optim(init, gev_loglik, ..., control = list(fnscale = -1), 
          hessian = FALSE)
      temp <- list()
      temp$mle <- x$par
      temp$nllh <- -x$value
      temp$hessian <- try(stats::optimHess(temp$mle, gev_loglik, 
          ...), silent = TRUE)
      if (class(temp$hessian) == "try-error") {
          temp$cov <- temp$se <- NULL
          return(temp)
      }
      temp$cov <- try(-solve(temp$hessian), silent = TRUE)
      if (class(temp$cov) == "try-error") {
          temp$cov <- temp$se <- NULL
      }
      else {
          temp$se <- sqrt(diag(temp$cov))
      }
      return(temp)
  }
  <bytecode: 0x556487e53ab8>
  <environment: namespace:revdbayes>
   --- function search by body ---
  Function gev_mle in namespace revdbayes has this body.
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1