Running ‘test-AllKrigingConcistency.R’
  Running ‘test-KrigingConstructorConsistency.R’
  Running ‘test-KrigingCopy.R’
  Running ‘test-KrigingFit.R’
  Running ‘test-KrigingLeaveOneOut.R’
  Running ‘test-KrigingLeaveOneOut_3d.R’
  Running ‘test-KrigingLogLik.R’
  Running ‘test-KrigingLogLikGradHess.R’
  Running ‘test-KrigingMethods.R’
  Running ‘test-KrigingNoiseFit.R’
  Running ‘test-KrigingNoiseLogLik.R’
  Running ‘test-KrigingNoiseMethods.R’
  Running ‘test-KrigingNoisePredict.R’ [11s/12s]
  Running ‘test-KrigingNoiseSimulate.R’
  Running ‘test-KrigingNoiseUpdate.R’
  Running ‘test-KrigingNoiseUpdateSimulate.R’
  Running ‘test-KrigingNuggetFit.R’
  Running ‘test-KrigingNuggetLogLik.R’
  Running ‘test-KrigingNuggetLogMargPost.R’ [12s/12s]
  Running ‘test-KrigingNuggetMethods.R’
  Running ‘test-KrigingNuggetPredict.R’
  Running ‘test-KrigingNuggetSimulate.R’
  Running ‘test-KrigingNuggetUpdate.R’
  Running ‘test-KrigingNuggetUpdateSimulate.R’
  Running ‘test-KrigingPredict.R’ [13s/13s]
  Running ‘test-KrigingSimulate.R’
  Running ‘test-KrigingUpdate.R’
  Running ‘test-KrigingUpdateSimulate.R’
  Running ‘test-LinearAlgebra.R’
  Running ‘test-MLPKriging.R’
  Running ‘test-NestedKriging.R’ [90m/46m]
  Running ‘test-RobustGaSP-Nugget.R’
  Running ‘test-RobustGaSP.R’
  Running ‘test-RobustGaSPtrendlinear.R’
  Running ‘test-RobustGaSPvsKrigingLMP.R’
  Running ‘test-RobustGaSPvsNuggetKrigingLMP.R’
  Running ‘test-SaveLoad.R’
  Running ‘test-WarpKriging.R’
  Running ‘test-asDiceKriging.R’
  Running ‘test-estimnone.R’
  Running ‘test-new-features.R’
  Running ‘test-normalize.R’
  Running ‘test-rlibkriging-demo.R’
  Running ‘test-unstableLL.R’
Running the tests in ‘tests/test-NestedKriging.R’ failed.
Complete output:
  > library(testthat)
  >  Sys.setenv('OMP_THREAD_LIMIT'=2)
  > 
  > library(rlibkriging)
  
  Attaching package: 'rlibkriging'
  
  The following object is masked from 'package:stats':
  
      kernel
  
  The following objects are masked from 'package:base':
  
      beta, load, save
  
  > 
  > #library(testthat)
  > #library(rlibkriging)
  > 
  > f <- function(X) apply(X, 1, function(x) sin(3 * x[1]) + cos(5 * x[2]) + x[1] * x[2])
  > 
  > set.seed(123)
  > X <- matrix(runif(2 * 200), ncol = 2)
  > y <- f(X)
  > Xt <- matrix(runif(2 * 100), ncol = 2)
  > 
  > test_that("NestedKriging fits and predicts with all aggregations", {
  +   for (agg in c("PoE", "gPoE", "BCM", "rBCM", "NK")) {
  +     k <- NestedKriging(y, X, kernel = "matern5_2", nb_groups = 4, aggregation = agg)
  +     p <- predict(k, Xt)
  +     expect_length(p$mean, nrow(Xt))
  +     expect_length(p$stdev, nrow(Xt))
  +     expect_true(all(is.finite(p$mean)))
  +     expect_true(all(p$stdev >= 0))
  +     rmse <- sqrt(mean((p$mean - f(Xt))^2))
  +     expect_lt(rmse, 0.5 * sd(y))
  +   }
  + })
  Test passed with 25 successes 🌈.
  > 
  > test_that("NK aggregation interpolates the design", {
  +   k <- NestedKriging(y, X, kernel = "matern5_2", nb_groups = 4, aggregation = "NK")
  +   p <- predict(k, X)
  +   expect_lt(max(abs(p$mean - y)), 1e-3)
  +   expect_lt(max(p$stdev), 1e-2)
  + })
  Test passed with 2 successes 🎉.
  > 
  > test_that("accessors are consistent", {
  +   k <- NestedKriging(y, X, kernel = "gauss", nb_groups = 4)
  +   expect_equal(k$kernel(), "gauss")
  +   expect_equal(k$aggregation(), "NK")
  +   expect_equal(k$nb_groups(), 4)
  +   expect_length(k$theta(), 2)
  +   expect_gt(k$sigma2(), 0)
  +   expect_equal(sort(unlist(k$groups())), 1:nrow(X))  # 1-based partition
  + })
  Test passed with 6 successes 😀.
  > 
  > test_that("close to full Kriging on moderate n", {
  +   kf <- Kriging(y, X, kernel = "matern5_2")
  +   pf <- predict(kf, Xt, return_stdev = FALSE)
  +   k <- NestedKriging(y, X, kernel = "matern5_2", nb_groups = 4, aggregation = "NK")
  +   p <- predict(k, Xt, return_stdev = FALSE)
  +   expect_lt(mean(abs(p$mean - pf$mean)), 0.05 * sd(y))
  + })