Last updated on 2025-02-21 02:52:23 CET.
Flavor | Version | Tinstall | Tcheck | Ttotal | Status | Flags |
---|---|---|---|---|---|---|
r-devel-linux-x86_64-debian-clang | 0.9-1 | 266.56 | 236.43 | 502.99 | OK | |
r-devel-linux-x86_64-debian-gcc | 0.9-1 | 210.56 | 155.80 | 366.36 | OK | |
r-devel-linux-x86_64-fedora-clang | 0.9-1 | 948.04 | ERROR | |||
r-devel-linux-x86_64-fedora-gcc | 0.9-1 | 974.11 | ERROR | |||
r-devel-macos-arm64 | 0.9-1 | 186.00 | OK | |||
r-devel-macos-x86_64 | 0.9-1 | 379.00 | OK | |||
r-devel-windows-x86_64 | 0.9-1 | 357.00 | 281.00 | 638.00 | OK | |
r-patched-linux-x86_64 | 0.9-1 | 302.92 | 215.52 | 518.44 | NOTE | |
r-release-linux-x86_64 | 0.9-1 | 294.00 | 214.47 | 508.47 | NOTE | |
r-release-macos-arm64 | 0.9-1 | 185.00 | NOTE | |||
r-release-macos-x86_64 | 0.9-1 | 364.00 | NOTE | |||
r-release-windows-x86_64 | 0.9-1 | 372.00 | 266.00 | 638.00 | NOTE | |
r-oldrel-macos-arm64 | 0.9-1 | 184.00 | NOTE | |||
r-oldrel-macos-x86_64 | 0.9-1 | 331.00 | NOTE | |||
r-oldrel-windows-x86_64 | 0.9-1 | 423.00 | 326.00 | 749.00 | NOTE |
Version: 0.9-1
Check: tests
Result: ERROR
Running ‘test-AllKrigingConcistency.R’ [8s/10s]
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’ [25s/19s]
Running ‘test-KrigingMethods.R’
Running ‘test-KrigingPredict.R’ [29s/32s]
Running ‘test-KrigingSimulate.R’
Running ‘test-KrigingUpdate.R’
Running ‘test-KrigingUpdateSimulate.R’
Running ‘test-LinearAlgebra.R’
Running ‘test-NoiseKrigingFit.R’ [11s/11s]
Running ‘test-NoiseKrigingLogLik.R’
Running ‘test-NoiseKrigingMethods.R’
Running ‘test-NoiseKrigingPredict.R’ [18s/23s]
Running ‘test-NoiseKrigingSimulate.R’ [11s/14s]
Running ‘test-NoiseKrigingUpdate.R’
Running ‘test-NoiseKrigingUpdateSimulate.R’ [8s/11s]
Running ‘test-NuggetKrigingFit.R’ [14s/12s]
Running ‘test-NuggetKrigingLogLik.R’ [16s/15s]
Running ‘test-NuggetKrigingLogMargPost.R’ [25s/20s]
Running ‘test-NuggetKrigingMethods.R’
Running ‘test-NuggetKrigingPredict.R’ [18s/22s]
Running ‘test-NuggetKrigingSimulate.R’
Running ‘test-NuggetKrigingUpdate.R’
Running ‘test-NuggetKrigingUpdateSimulate.R’
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-asDiceKriging.R’ [31s/31s]
Running ‘test-estimnone.R’
Running ‘test-normalize.R’
Running ‘test-rlibkriging-demo.R’
Running ‘test-unstableLL.R’
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)
#########
##
## Robust Gaussian Stochastic Process, RobustGaSP Package
## Copyright (C) 2016-2025 Mengyang Gu, Jesus Palomo and James O. Berger
#########
Attaching package: 'RobustGaSP'
The following object is masked from 'package:rlibkriging':
simulate
The following object is masked from 'package:stats':
simulate
>
> context("RobustGaSP / Fit: 1D")
>
> 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)
The upper bounds of the range parameters are 184.9743
The initial values of range parameters are 3.699485
Start of the optimization 1 :
The number of iterations is 30
The value of the marginal posterior function is 2.497978
Optimized range parameters are 0.1921691
Optimized nugget parameter is 0
Convergence: TRUE
The initial values of range parameters are 0.05223118
Start of the optimization 2 :
The number of iterations is 30
The value of the marginal posterior function is 1.035387
Optimized range parameters are 0.05296527
Optimized nugget parameter is 0
Convergence: TRUE
> #library(rlibkriging)
> r <- Kriging(y, X,
+ kernel="matern5_2",
+ regmodel = "constant", normalize = FALSE,
+ optim = "BFGS",
+ objective = "LMP")
OMP: Warning #96: Cannot form a team with 24 threads, using 2 instead.
OMP: Hint Consider unsetting KMP_DEVICE_THREAD_LIMIT (KMP_ALL_THREADS), KMP_TEAMS_THREAD_LIMIT, and OMP_THREAD_LIMIT (if any are set).
> # m = as.list(r)
>
> # Check lmp function
>
> lmp_rgasp = function(X, model=k) {if (!is.matrix(X)) X = matrix(X,ncol=1);
+ # print(dim(X));
+ apply(X,1,
+ function(x) {
+ #y=-logMargPostFun(r,matrix(unlist(x),ncol=2))$logMargPost
+ y=RobustGaSP:::neg_log_marginal_post_approx_ref(param=(x),nugget=0, nugget.est=model@nugget.est,
+ R0=model@R0,X=model@X, zero_mean=model@zero_mean,output=model@output,
+ CL=model@CL,
+ a=0.2,
+ b=1/(length(model@output))^{1/dim(as.matrix(model@input))[2]}*(0.2+dim(as.matrix(model@input))[2]),
+ kernel_type=rep(as.integer(3),ncol(X)),alpha=model@alpha
+ )
+ y})}
> lmp_rgasp(1)
[1] -1.901254
>
> plot(lmp_rgasp,xlim=c(0.01,6))
> abline(v=(log(k@beta_hat)))
>
> lmp_lk = function(X) {if (!is.matrix(X)) X = matrix(X,ncol=1);
+ # print(dim(X));
+ apply(X,1,
+ function(x) {
+ y=-logMargPostFun(r,matrix(unlist(exp(-(x))),ncol=1))$logMargPost
+ y})}
> lmp_lk(1)
[1] -1.901254
>
> lines(seq(0.1,6,,5),lmp_lk(seq(0.1,6,,5)),col='red')
> abline(v=(log(1/as.list(r)$theta)),col='red')
>
> precision <- 1e-3
> test_that(desc=paste0("RobustGaSP / Fit: 1D / rgasp/lmp is the same that lk/lmp one"),
+ expect_equal(lmp_rgasp(1),lmp_lk(1),tol = precision))
Test passed 🥳
> test_that(desc=paste0("RobustGaSP / Fit: 1D / fitted theta is the same that RobustGaSP one"),
+ expect_equal(as.list(r)$theta[1],1/k@beta_hat,tol = precision))
Test passed 🥳
>
>
>
> dlmp_rgasp = function(X, model=k) {if (!is.matrix(X)) X = matrix(X,ncol=1);
+ # print(dim(X));
+ apply(X,1,
+ function(x) {
+
+ # print(RobustGaSP:::log_marginal_lik_deriv(param=(x),nugget=0,nugget_est=model@nugget.est,
+ # R0=model@R0,X=model@X, zero_mean=model@zero_mean,
+ # output=model@output,
+ # kernel_type=rep(as.integer(3),ncol(X)),alpha=model@alpha))
+ #
+ # print(RobustGaSP:::log_approx_ref_prior_deriv(param=(x),nugget=0, nugget_est=model@nugget.est,
+ # CL=model@CL,
+ # a=0.2,
+ # b=1/(length(model@output))^{1/dim(as.matrix(model@input))[2]}*(0.2+dim(as.matrix(model@input))[2])))
+
+
+ #y=-logMargPostFun(r,matrix(unlist(x),ncol=2))$logMargPost
+ y=RobustGaSP:::neg_log_marginal_post_approx_ref_deriv(param=(x),nugget=0, nugget.est=model@nugget.est,
+ R0=model@R0,X=model@X, zero_mean=model@zero_mean,output=model@output,
+ CL=model@CL,
+ a=0.2,
+ b=1/(length(model@output))^{1/dim(as.matrix(model@input))[2]}*(0.2+dim(as.matrix(model@input))[2]),
+ kernel_type=rep(as.integer(3),ncol(X)),alpha=model@alpha
+ )
+ y})}
> dlmp_rgasp(1)
[1] -1.703845
>
> dlmp_lk = function(X) {if (!is.matrix(X)) X = matrix(X,ncol=1);
+ apply(X,1,
+ function(x) {
+ y=-logMargPostFun(r,matrix(unlist(exp(-(x))),ncol=1),TRUE)$logMargPostGrad
+ y})}
> -exp(-1)*dlmp_lk(1)
[1] -1.703845
>
> precision <- 1e-3
> test_that(desc=paste0("RobustGaSP / Fit: 1D / rgasp/lmp deriv is the same that lk/lmp deriv"),
+ expect_equal(dlmp_rgasp(1),-exp(-1)*dlmp_lk(1),tol = precision))
Test passed 🎉
>
>
> # Check predict
>
> ntest <- 10
> Xtest <- seq(0,1,,ntest)
> Ytest_rgasp <- predict(k,matrix(Xtest,ncol=1))
> Ytest_libK <- predict(r,Xtest)
>
> plot(f)
> points(X,y)
> lines(Xtest,Ytest_rgasp$mean,col='blue')
> polygon(c(Xtest,rev(Xtest)),
+ c(Ytest_rgasp$mean+2*Ytest_rgasp$sd,rev(Ytest_rgasp$mean-2*Ytest_rgasp$sd)),
+ col=rgb(0,0,1,0.1), border=NA)
>
> lines(Xtest,Ytest_libK$mean,col='red')
> polygon(c(Xtest,rev(Xtest)),
+ c(Ytest_libK$mean+2*Ytest_libK$stdev,rev(Ytest_libK$mean-2*Ytest_libK$stdev)),
+ col=rgb(1,0,0,0.1), border=NA)
>
> precision <- 1e-3
> test_that(desc=paste0("pred mean is the same that RobustGaSP one"),
+ expect_equal(predict(r,0.7)$mean[1],predict(k,matrix(0.7))$mean,tol = precision))
Test passed 😸
> test_that(desc=paste0("pred sd is the same that RobustGaSP one"),
+ expect_equal(predict(r,0.7)$stdev[1],predict(k,matrix(0.7))$sd,tol = precision))
Test passed 🥇
>
>
> ## RobustGaSP examples
>
> #---------------------------------------
> # a 1 dimensional example
> #---------------------------------------
> context("RobustGaSP / 1 dimensional example")
>
>
> input=10*seq(0,1,1/14)
> output<-higdon.1.data(input)
> #the following code fit a GaSP with zero mean by setting zero.mean="Yes"
> model<- rgasp(design = input, response = output, zero.mean="No")
The upper bounds of the range parameters are 670.0756
The initial values of range parameters are 13.40151
Start of the optimization 1 :
The number of iterations is 30
The value of the marginal posterior function is -10.48964
Optimized range parameters are 13.2106
Optimized nugget parameter is 0
Convergence: TRUE
The initial values of range parameters are 0.08888889
Start of the optimization 2 :
The number of iterations is 30
The value of the marginal posterior function is -15.24592
Optimized range parameters are 0.1706386
Optimized nugget parameter is 0
Convergence: TRUE
> model
Call:
rgasp(design = input, response = output, zero.mean = "No")
Mean parameters: 2.174187e-10
Variance parameter: 4249.587
Range parameters: 13.2106
Noise parameter: 0
>
> testing_input = as.matrix(seq(0,10,1/100))
> model.predict<-predict(model,testing_input)
> names(model.predict)
[1] "mean" "lower95" "upper95" "sd"
>
> #########plot predictive distribution
> testing_output=higdon.1.data(testing_input)
> plot(testing_input,model.predict$mean,type='l',col='blue',
+ xlab='input',ylab='output')
> polygon( c(testing_input,rev(testing_input)),c(model.predict$lower95,
+ rev(model.predict$upper95)),col = "grey80", border = FALSE)
> lines(testing_input, testing_output)
> lines(testing_input,model.predict$mean,type='l',col='blue')
> lines(input, output,type='p')
>
> ## mean square erros
> mean((model.predict$mean-testing_output)^2)
[1] 4.63608e-05
>
> model_libK = Kriging(matrix(output,ncol=1), matrix(input,ncol=1),
+ kernel="matern5_2",
+ regmodel = "constant", normalize = FALSE,
+ optim = "BFGS",
+ objective = "LMP", parameters = NULL)
>
> lines(testing_input,predict(model_libK,testing_input)$mean,type='l',col='red')
> polygon(
+ c(testing_input,rev(testing_input)),
+ c(
+ predict(model_libK,testing_input)$mean+2*predict(model_libK,testing_input)$stdev,
+ rev(predict(model_libK,testing_input)$mean-2*predict(model_libK,testing_input)$stdev)),
+ col = rgb(1,0,0,0.1), border = FALSE)
>
> precision <- 1e-3
> test_that(desc=paste0("RobustGaSP / 1 dimensional example / pred mean is the same that RobustGaSP one"),
+ expect_equal(predict(model_libK,0.7)$mean[1],predict(model,matrix(0.7))$mean,tol = precision))
── Failure: RobustGaSP / 1 dimensional example / pred mean is the same that RobustGaSP one ──
predict(model_libK, 0.7)$mean[1] not equal to predict(model, matrix(0.7))$mean.
1/1 mismatches
[1] 0.621 - 0.623 == -0.00162
Error:
! Test failed
Backtrace:
▆
1. ├─testthat::test_that(...)
2. │ └─withr (local) `<fn>`()
3. └─reporter$stop_if_needed()
4. └─rlang::abort("Test failed", call = NULL)
Execution halted
Flavor: r-devel-linux-x86_64-fedora-clang
Version: 0.9-1
Check: tests
Result: ERROR
Running ‘test-AllKrigingConcistency.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’ [30s/30s]
Running ‘test-KrigingMethods.R’
Running ‘test-KrigingPredict.R’ [24s/28s]
Running ‘test-KrigingSimulate.R’
Running ‘test-KrigingUpdate.R’
Running ‘test-KrigingUpdateSimulate.R’
Running ‘test-LinearAlgebra.R’
Running ‘test-NoiseKrigingFit.R’ [11s/11s]
Running ‘test-NoiseKrigingLogLik.R’
Running ‘test-NoiseKrigingMethods.R’
Running ‘test-NoiseKrigingPredict.R’ [17s/19s]
Running ‘test-NoiseKrigingSimulate.R’ [10s/12s]
Running ‘test-NoiseKrigingUpdate.R’
Running ‘test-NoiseKrigingUpdateSimulate.R’
Running ‘test-NuggetKrigingFit.R’ [15s/16s]
Running ‘test-NuggetKrigingLogLik.R’ [10s/12s]
Running ‘test-NuggetKrigingLogMargPost.R’ [18s/21s]
Running ‘test-NuggetKrigingMethods.R’
Running ‘test-NuggetKrigingPredict.R’ [17s/19s]
Running ‘test-NuggetKrigingSimulate.R’
Running ‘test-NuggetKrigingUpdate.R’
Running ‘test-NuggetKrigingUpdateSimulate.R’
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-asDiceKriging.R’ [21s/26s]
Running ‘test-estimnone.R’
Running ‘test-normalize.R’
Running ‘test-rlibkriging-demo.R’
Running ‘test-unstableLL.R’
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)
#########
##
## Robust Gaussian Stochastic Process, RobustGaSP Package
## Copyright (C) 2016-2025 Mengyang Gu, Jesus Palomo and James O. Berger
#########
Attaching package: 'RobustGaSP'
The following object is masked from 'package:rlibkriging':
simulate
The following object is masked from 'package:stats':
simulate
>
> context("RobustGaSP / Fit: 1D")
>
> 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)
The upper bounds of the range parameters are 184.9743
The initial values of range parameters are 3.699485
Start of the optimization 1 :
The number of iterations is 30
The value of the marginal posterior function is 2.497978
Optimized range parameters are 0.1921691
Optimized nugget parameter is 0
Convergence: TRUE
The initial values of range parameters are 0.05223118
Start of the optimization 2 :
The number of iterations is 30
The value of the marginal posterior function is 1.035387
Optimized range parameters are 0.05296527
Optimized nugget parameter is 0
Convergence: TRUE
> #library(rlibkriging)
> r <- Kriging(y, X,
+ kernel="matern5_2",
+ regmodel = "constant", normalize = FALSE,
+ optim = "BFGS",
+ objective = "LMP")
> # m = as.list(r)
>
> # Check lmp function
>
> lmp_rgasp = function(X, model=k) {if (!is.matrix(X)) X = matrix(X,ncol=1);
+ # print(dim(X));
+ apply(X,1,
+ function(x) {
+ #y=-logMargPostFun(r,matrix(unlist(x),ncol=2))$logMargPost
+ y=RobustGaSP:::neg_log_marginal_post_approx_ref(param=(x),nugget=0, nugget.est=model@nugget.est,
+ R0=model@R0,X=model@X, zero_mean=model@zero_mean,output=model@output,
+ CL=model@CL,
+ a=0.2,
+ b=1/(length(model@output))^{1/dim(as.matrix(model@input))[2]}*(0.2+dim(as.matrix(model@input))[2]),
+ kernel_type=rep(as.integer(3),ncol(X)),alpha=model@alpha
+ )
+ y})}
> lmp_rgasp(1)
[1] -1.901254
>
> plot(lmp_rgasp,xlim=c(0.01,6))
> abline(v=(log(k@beta_hat)))
>
> lmp_lk = function(X) {if (!is.matrix(X)) X = matrix(X,ncol=1);
+ # print(dim(X));
+ apply(X,1,
+ function(x) {
+ y=-logMargPostFun(r,matrix(unlist(exp(-(x))),ncol=1))$logMargPost
+ y})}
> lmp_lk(1)
[1] -1.901254
>
> lines(seq(0.1,6,,5),lmp_lk(seq(0.1,6,,5)),col='red')
> abline(v=(log(1/as.list(r)$theta)),col='red')
>
> precision <- 1e-3
> test_that(desc=paste0("RobustGaSP / Fit: 1D / rgasp/lmp is the same that lk/lmp one"),
+ expect_equal(lmp_rgasp(1),lmp_lk(1),tol = precision))
Test passed 🥳
> test_that(desc=paste0("RobustGaSP / Fit: 1D / fitted theta is the same that RobustGaSP one"),
+ expect_equal(as.list(r)$theta[1],1/k@beta_hat,tol = precision))
Test passed 🥳
>
>
>
> dlmp_rgasp = function(X, model=k) {if (!is.matrix(X)) X = matrix(X,ncol=1);
+ # print(dim(X));
+ apply(X,1,
+ function(x) {
+
+ # print(RobustGaSP:::log_marginal_lik_deriv(param=(x),nugget=0,nugget_est=model@nugget.est,
+ # R0=model@R0,X=model@X, zero_mean=model@zero_mean,
+ # output=model@output,
+ # kernel_type=rep(as.integer(3),ncol(X)),alpha=model@alpha))
+ #
+ # print(RobustGaSP:::log_approx_ref_prior_deriv(param=(x),nugget=0, nugget_est=model@nugget.est,
+ # CL=model@CL,
+ # a=0.2,
+ # b=1/(length(model@output))^{1/dim(as.matrix(model@input))[2]}*(0.2+dim(as.matrix(model@input))[2])))
+
+
+ #y=-logMargPostFun(r,matrix(unlist(x),ncol=2))$logMargPost
+ y=RobustGaSP:::neg_log_marginal_post_approx_ref_deriv(param=(x),nugget=0, nugget.est=model@nugget.est,
+ R0=model@R0,X=model@X, zero_mean=model@zero_mean,output=model@output,
+ CL=model@CL,
+ a=0.2,
+ b=1/(length(model@output))^{1/dim(as.matrix(model@input))[2]}*(0.2+dim(as.matrix(model@input))[2]),
+ kernel_type=rep(as.integer(3),ncol(X)),alpha=model@alpha
+ )
+ y})}
> dlmp_rgasp(1)
[1] -1.703845
>
> dlmp_lk = function(X) {if (!is.matrix(X)) X = matrix(X,ncol=1);
+ apply(X,1,
+ function(x) {
+ y=-logMargPostFun(r,matrix(unlist(exp(-(x))),ncol=1),TRUE)$logMargPostGrad
+ y})}
> -exp(-1)*dlmp_lk(1)
[1] -1.703845
>
> precision <- 1e-3
> test_that(desc=paste0("RobustGaSP / Fit: 1D / rgasp/lmp deriv is the same that lk/lmp deriv"),
+ expect_equal(dlmp_rgasp(1),-exp(-1)*dlmp_lk(1),tol = precision))
Test passed 🎉
>
>
> # Check predict
>
> ntest <- 10
> Xtest <- seq(0,1,,ntest)
> Ytest_rgasp <- predict(k,matrix(Xtest,ncol=1))
> Ytest_libK <- predict(r,Xtest)
>
> plot(f)
> points(X,y)
> lines(Xtest,Ytest_rgasp$mean,col='blue')
> polygon(c(Xtest,rev(Xtest)),
+ c(Ytest_rgasp$mean+2*Ytest_rgasp$sd,rev(Ytest_rgasp$mean-2*Ytest_rgasp$sd)),
+ col=rgb(0,0,1,0.1), border=NA)
>
> lines(Xtest,Ytest_libK$mean,col='red')
> polygon(c(Xtest,rev(Xtest)),
+ c(Ytest_libK$mean+2*Ytest_libK$stdev,rev(Ytest_libK$mean-2*Ytest_libK$stdev)),
+ col=rgb(1,0,0,0.1), border=NA)
>
> precision <- 1e-3
> test_that(desc=paste0("pred mean is the same that RobustGaSP one"),
+ expect_equal(predict(r,0.7)$mean[1],predict(k,matrix(0.7))$mean,tol = precision))
Test passed 😸
> test_that(desc=paste0("pred sd is the same that RobustGaSP one"),
+ expect_equal(predict(r,0.7)$stdev[1],predict(k,matrix(0.7))$sd,tol = precision))
Test passed 🥇
>
>
> ## RobustGaSP examples
>
> #---------------------------------------
> # a 1 dimensional example
> #---------------------------------------
> context("RobustGaSP / 1 dimensional example")
>
>
> input=10*seq(0,1,1/14)
> output<-higdon.1.data(input)
> #the following code fit a GaSP with zero mean by setting zero.mean="Yes"
> model<- rgasp(design = input, response = output, zero.mean="No")
The upper bounds of the range parameters are 670.0756
The initial values of range parameters are 13.40151
Start of the optimization 1 :
The number of iterations is 30
The value of the marginal posterior function is -10.48964
Optimized range parameters are 13.2106
Optimized nugget parameter is 0
Convergence: TRUE
The initial values of range parameters are 0.08888889
Start of the optimization 2 :
The number of iterations is 30
The value of the marginal posterior function is -15.24592
Optimized range parameters are 0.1706386
Optimized nugget parameter is 0
Convergence: TRUE
> model
Call:
rgasp(design = input, response = output, zero.mean = "No")
Mean parameters: 2.174187e-10
Variance parameter: 4249.587
Range parameters: 13.2106
Noise parameter: 0
>
> testing_input = as.matrix(seq(0,10,1/100))
> model.predict<-predict(model,testing_input)
> names(model.predict)
[1] "mean" "lower95" "upper95" "sd"
>
> #########plot predictive distribution
> testing_output=higdon.1.data(testing_input)
> plot(testing_input,model.predict$mean,type='l',col='blue',
+ xlab='input',ylab='output')
> polygon( c(testing_input,rev(testing_input)),c(model.predict$lower95,
+ rev(model.predict$upper95)),col = "grey80", border = FALSE)
> lines(testing_input, testing_output)
> lines(testing_input,model.predict$mean,type='l',col='blue')
> lines(input, output,type='p')
>
> ## mean square erros
> mean((model.predict$mean-testing_output)^2)
[1] 4.63608e-05
>
> model_libK = Kriging(matrix(output,ncol=1), matrix(input,ncol=1),
+ kernel="matern5_2",
+ regmodel = "constant", normalize = FALSE,
+ optim = "BFGS",
+ objective = "LMP", parameters = NULL)
>
> lines(testing_input,predict(model_libK,testing_input)$mean,type='l',col='red')
> polygon(
+ c(testing_input,rev(testing_input)),
+ c(
+ predict(model_libK,testing_input)$mean+2*predict(model_libK,testing_input)$stdev,
+ rev(predict(model_libK,testing_input)$mean-2*predict(model_libK,testing_input)$stdev)),
+ col = rgb(1,0,0,0.1), border = FALSE)
>
> precision <- 1e-3
> test_that(desc=paste0("RobustGaSP / 1 dimensional example / pred mean is the same that RobustGaSP one"),
+ expect_equal(predict(model_libK,0.7)$mean[1],predict(model,matrix(0.7))$mean,tol = precision))
── Failure: RobustGaSP / 1 dimensional example / pred mean is the same that RobustGaSP one ──
predict(model_libK, 0.7)$mean[1] not equal to predict(model, matrix(0.7))$mean.
1/1 mismatches
[1] 0.621 - 0.623 == -0.00162
Error:
! Test failed
Backtrace:
▆
1. ├─testthat::test_that(...)
2. │ └─withr (local) `<fn>`()
3. └─reporter$stop_if_needed()
4. └─rlang::abort("Test failed", call = NULL)
Execution halted
Flavor: r-devel-linux-x86_64-fedora-gcc
Version: 0.9-1
Check: for GNU extensions in Makefiles
Result: NOTE
GNU make is a SystemRequirements.
Flavors: r-patched-linux-x86_64, r-release-linux-x86_64, r-release-macos-arm64, r-release-macos-x86_64, r-release-windows-x86_64, r-oldrel-macos-arm64, r-oldrel-macos-x86_64, r-oldrel-windows-x86_64
Version: 0.9-1
Check: installed package size
Result: NOTE
installed size is 71.3Mb
sub-directories of 1Mb or more:
include 7.3Mb
lib 37.3Mb
libs 26.2Mb
Flavors: r-release-macos-arm64, r-release-macos-x86_64, r-release-windows-x86_64, r-oldrel-macos-arm64, r-oldrel-macos-x86_64, r-oldrel-windows-x86_64