Running ‘test-AllKrigingConcistency.R’ [5s/7s]
  Running ‘test-KrigingCopy.R’ [2s/3s]
  Running ‘test-KrigingFit.R’ [3s/4s]
  Running ‘test-KrigingLeaveOneOut.R’ [3s/5s]
  Running ‘test-KrigingLeaveOneOut_3d.R’ [2s/3s]
  Running ‘test-KrigingLogLik.R’ [4s/5s]
  Running ‘test-KrigingLogLikGradHess.R’ [9s/12s]
  Running ‘test-KrigingMethods.R’ [4s/5s]
  Running ‘test-KrigingPredict.R’ [15s/20s]
  Running ‘test-KrigingSimulate.R’ [2s/3s]
  Running ‘test-KrigingUpdate.R’ [2s/3s]
  Running ‘test-KrigingUpdateSimulate.R’ [4s/5s]
  Running ‘test-LinearAlgebra.R’ [3s/3s]
  Running ‘test-NoiseKrigingFit.R’ [5s/6s]
  Running ‘test-NoiseKrigingLogLik.R’ [3s/5s]
  Running ‘test-NoiseKrigingMethods.R’ [3s/5s]
  Running ‘test-NoiseKrigingPredict.R’ [11s/15s]
  Running ‘test-NoiseKrigingSimulate.R’ [7s/9s]
  Running ‘test-NoiseKrigingUpdate.R’ [2s/2s]
  Running ‘test-NoiseKrigingUpdateSimulate.R’ [4s/6s]
  Running ‘test-NuggetKrigingFit.R’ [5s/6s]
  Running ‘test-NuggetKrigingLogLik.R’ [6s/9s]
  Running ‘test-NuggetKrigingLogMargPost.R’ [10s/12s]
  Running ‘test-NuggetKrigingMethods.R’ [3s/4s]
  Running ‘test-NuggetKrigingPredict.R’ [10s/15s]
  Running ‘test-NuggetKrigingSimulate.R’ [3s/4s]
  Running ‘test-NuggetKrigingUpdate.R’ [2s/3s]
  Running ‘test-NuggetKrigingUpdateSimulate.R’ [3s/5s]
  Running ‘test-RobustGaSP-Nugget.R’ [1s/1s]
  Running ‘test-RobustGaSP.R’ [1s/1s]
  Running ‘test-RobustGaSPtrendlinear.R’ [1s/1s]
  Running ‘test-RobustGaSPvsKrigingLMP.R’ [2s/2s]
  Running ‘test-RobustGaSPvsNuggetKrigingLMP.R’ [1s/1s]
  Running ‘test-SaveLoad.R’ [2s/3s]
  Running ‘test-asDiceKriging.R’ [13s/16s]
  Running ‘test-estimnone.R’ [3s/3s]
  Running ‘test-normalize.R’ [4s/7s]
  Running ‘test-rlibkriging-demo.R’ [1s/2s]
  Running ‘test-unstableLL.R’ [2s/3s]
Running the tests in ‘tests/test-RobustGaSP-Nugget.R’ failed.
Complete output:
  > library(testthat)
  >  Sys.setenv('OMP_THREAD_LIMIT'=2)
  >  library(rlibkriging)
  
  Attaching package: 'rlibkriging'
  
  The following objects are masked from 'package:base':
  
      load, save
  
  > 
  > ##library(rlibkriging, lib.loc="bindings/R/Rlibs")
  > ##library(testthat)
  > 
  > library(RobustGaSP)
  Error in library(RobustGaSP) : there is no package called 'RobustGaSP'
  Execution halted
Running the tests in ‘tests/test-RobustGaSP.R’ failed.
Complete output:
  > library(testthat)
  >  Sys.setenv('OMP_THREAD_LIMIT'=2)
  >  library(rlibkriging)
  
  Attaching package: 'rlibkriging'
  
  The following objects are masked from 'package:base':
  
      load, save
  
  > 
  > ##library(rlibkriging, lib.loc="bindings/R/Rlibs")
  > ##library(testthat)
  > 
  > library(RobustGaSP)
  Error in library(RobustGaSP) : there is no package called 'RobustGaSP'
  Execution halted
Running the tests in ‘tests/test-RobustGaSPtrendlinear.R’ failed.
Complete output:
  > library(testthat)
  >  Sys.setenv('OMP_THREAD_LIMIT'=2)
  >  library(rlibkriging)
  
  Attaching package: 'rlibkriging'
  
  The following objects are masked from 'package:base':
  
      load, save
  
  > 
  > ##library(testthat)
  >  Sys.setenv('OMP_THREAD_LIMIT'=2)
  > #library(rlibkriging)
  > 
  > library(RobustGaSP)
  Error in library(RobustGaSP) : there is no package called 'RobustGaSP'
  Execution halted
Running the tests in ‘tests/test-RobustGaSPvsKrigingLMP.R’ failed.
Complete output:
  > library(testthat)
  >  Sys.setenv('OMP_THREAD_LIMIT'=2)
  >  library(rlibkriging)
  
  Attaching package: 'rlibkriging'
  
  The following objects are masked from 'package:base':
  
      load, save
  
  > 
  > kernel_type = function(kernel) {
  +   if (kernel=="matern3_2") return("matern_3_2")
  +   if (kernel=="matern5_2") return("matern_5_2")
  +   stop(paste0("Cannot use ",kernel))
  + }
  > kernel_type_num = function(kernel) {
  +   if (kernel=="matern3_2") return(2)
  +   if (kernel=="matern5_2") return(3)
  +   stop(paste0("Cannot use ",kernel))
  + }
  > 
  > for (kernel in c("matern5_2","matern3_2")) {
  +   context(paste0("Check Marginal Posterior for kernel ",kernel))
  +   
  +   f = function(x) 1-1/2*(sin(12*x)/(1+x)+2*cos(7*x)*x^5+0.7)
  +   plot(f)
  +   n <- 5
  +   set.seed(123)
  +   X <- as.matrix(runif(n))
  +   y = f(X)
  +   points(X,y)
  + 
  +   k = RobustGaSP::rgasp(design=X,response=y,kernel_type=kernel_type(kernel))
  + 
  +   lmp = function(theta) {
  +     #cat("theta: ",theta,"\n")
  +     lml = RobustGaSP::log_marginal_lik(param=log(1/theta),nugget=k@nugget,nugget_est=k@nugget.est,
  +       R0=k@R0,X=k@X,zero_mean=k@zero_mean,output=k@output,kernel_type=kernel_type_num(kernel),alpha=k@alpha)
  +     #cat("  lml: ",lml,"\n")
  +     larp = RobustGaSP::log_approx_ref_prior(param=log(1/theta),nugget=k@nugget,nugget_est=k@nugget.est,
  +       CL=k@CL,a=0.2,b=1/(length(y))^{1/dim(as.matrix(X))[2]}*(0.2+dim(as.matrix(X))[2]))
  +     #cat("  larp: ",larp,"\n")
  +     return(lml+larp)
  +   }
  + 
  +   plot(Vectorize(lmp),ylab="LMP",xlab="theta",xlim=c(0.01,2),ylim=c(-5,5))
  +   abline(v=1/k@beta_hat)
  + 
  +   lmp_deriv = function(theta) {
  +     #cat("theta: ",theta,"\n")
  +     lml_d = RobustGaSP::log_marginal_lik_deriv(param=log(1/theta),nugget=k@nugget,nugget_est=k@nugget.est,
  +       R0=k@R0,X=k@X,zero_mean=k@zero_mean,output=k@output,kernel_type=kernel_type_num(kernel),alpha=k@alpha)
  +     #cat("  lml_d: ",lml_d,"\n")
  +     larp_d = RobustGaSP::log_approx_ref_prior_deriv(param=log(1/theta),nugget=k@nugget,nugget_est=k@nugget.est,
  +       CL=k@CL,a=0.2,b=1/(length(y))^{1/dim(as.matrix(X))[2]}*(0.2+dim(as.matrix(X))[2]))
  +     #cat("  larp_d: ",larp_d,"\n")
  +     return((lml_d + larp_d)* 1/theta * (-1/theta))
  +   }
  + 
  +   for (x in seq(0.01,2,,11)){
  +     arrows(x,lmp(x),x+.1,lmp(x)+.1*lmp_deriv(x))
  +   }
  + 
  +   #library(rlibkriging)
  +   r <- Kriging(y, X, kernel, objective="LMP")
  +   ## Should be equal:
  +   #lmp(1.0); lmp_deriv(1.0);
  +   #logMargPostFun(r,1.0,return_grad = T)
  +   #lmp(0.1); lmp_deriv(0.1);
  +   #logMargPostFun(r,0.1,return_grad = T)
  +   #ll2 = function(theta) logMargPostFun(r,theta)$logMargPost
  +   # plot(Vectorize(ll2),col='red',add=T,xlim=c(0.01,2)) # FIXME fails with "error: chol(): decomposition failed"
  +   for (x in seq(0.01,2,,11)){
  +     ll2x = logMargPostFun(r,x)$logMargPost
  +     gll2x = logMargPostFun(r,x,return_grad = T)$logMargPostGrad
  +     arrows(x,ll2x,x+.1,ll2x+.1*gll2x,col='red')
  +   }
  +   
  +   precision <- 1e-8  # the following tests should work with it, since the computations are analytical
  +   x=.5
  +   test_that(desc="logMargPost is the same that RobustGaSP one", 
  +             expect_equal(logMargPostFun(r,x)$logMargPost[1],lmp(x),tolerance = precision))
  +   
  +   test_that(desc="logMargPost Grad is the same that RobustGaSP one", 
  +             expect_equal(logMargPostFun(r,x,return_grad = T)$logMargPostGrad[1],lmp_deriv(x),tolerance= precision))
  + }
  Error in loadNamespace(x) : there is no package called 'RobustGaSP'
  Calls: loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
  Execution halted
Running the tests in ‘tests/test-RobustGaSPvsNuggetKrigingLMP.R’ failed.
Complete output:
  > library(testthat)
  >  Sys.setenv('OMP_THREAD_LIMIT'=2)
  >  library(rlibkriging)
  
  Attaching package: 'rlibkriging'
  
  The following objects are masked from 'package:base':
  
      load, save
  
  > 
  > library(RobustGaSP)
  Error in library(RobustGaSP) : there is no package called 'RobustGaSP'
  Execution halted