R Under development (unstable) (2024-08-23 r87049 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > 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) > ##library(rlibkriging, lib.loc="bindings/R/Rlibs") > #rlibkriging:::optim_log(2) > #rlibkriging:::optim_use_reparametrize(FALSE) > #rlibkriging:::optim_set_theta_lower_factor(0.02) > > > f = function(x) 1-1/2*(sin(12*x)/(1+x)+2*cos(7*x)*x^5+0.7) > n <- 5 > set.seed(123) > X <- as.matrix(runif(n)) > y = f(X) > > #library(rlibkriging) > > > context("Kriging") > > r_noestim <- Kriging(y, X, "gauss", optim="none", parameters=list(theta= matrix(0.1) ,sigma2= 0.01 ,beta= matrix(0.123))) > print(r_noestim) * data: 5x[0.287578,0.940467] -> 5x[0.194057,1.00912] * trend constant: 0.123 * variance: 0.01 * covariance: * kernel: gauss * range: 0.1 * fit: * objective: LL * optim: none > test_that(desc="theta noestim", + expect_equal( r_noestim$theta()[1] , 0.1 ,tol=1E-10)) Test passed 🥳 > test_that(desc="sigma2 noestim", + expect_equal( r_noestim$sigma2() , 0.01 ,tol=1E-10)) Test passed 🥳 > test_that(desc="beta noestim", + expect_equal( r_noestim$beta()[1] , 0.123 ,tol=1E-10)) Test passed 🎉 > > > context("NuggetKriging") > > rnu_noestim <- NuggetKriging(y, X, "gauss", optim="none", parameters=list(theta= matrix(0.1) ,sigma2= 0.01 ,beta= matrix(0.123), nugget= 0.0456)) > print(rnu_noestim) * data: 5x[0.287578,0.940467] -> 5x[0.194057,1.00912] * trend constant: 0.123 * variance: 0.01 * covariance: * kernel: gauss * range: 0.1 * nugget: 0.0456 * fit: * objective: LL * optim: none > test_that(desc="theta noestim", + expect_equal( rnu_noestim$theta()[1] , 0.1 ,tol=1E-10)) Test passed 😸 > test_that(desc="sigma2 noestim", + expect_equal( rnu_noestim$sigma2() , 0.01 ,tol=1E-10)) Test passed 🥇 > test_that(desc="beta noestim", + expect_equal( rnu_noestim$beta()[1] , 0.123 ,tol=1E-10)) Test passed 🌈 > test_that(desc="nugget noestim", + expect_equal( rnu_noestim$nugget() , 0.0456 ,tol=1E-10)) Test passed 🎉 > > context("NoiseKriging") > > rno_noestim <- NoiseKriging(y, rep(0.05,nrow(X)) , X, "gauss", optim="none", parameters=list(theta= matrix(0.1) ,sigma2= 0.01 ,beta= matrix(0.123))) > print(rno_noestim) * data: 5x[0.287578,0.940467] -> 5x[0.194057,1.00912] * noise: 5x[0.05,0.05] * trend constant: 0.123 * variance: 0.01 * covariance: * kernel: gauss * range: 0.1 * fit: * objective: LL * optim: none > test_that(desc="theta noestim", + expect_equal( rno_noestim$theta()[1] , 0.1 ,tol=1E-10)) Test passed 🎉 > test_that(desc="sigma2 noestim", + expect_equal( rno_noestim$sigma2() , 0.01 ,tol=1E-10)) Test passed 😀 > test_that(desc="beta noestim", + expect_equal( rno_noestim$beta()[1] , 0.123 ,tol=1E-10)) Test passed 🥳 > > proc.time() user system elapsed 2.31 0.25 2.56