R Under development (unstable) (2024-09-15 r87152 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 > > X <- as.matrix(c(0.0, 0.2, 0.5, 0.8, 1.0)) > f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) > y <- f(X) > > #library(rlibkriging) > k_R <- Kriging(y, X, "gauss") > > print(k_R) * data: 5x[0,1] -> 5x[0.030241,0.772403] * trend constant (est.): 0.453087 * variance (est.): 0.0653536 * covariance: * kernel: gauss * range (est.): 0.02 * fit: * objective: LL * optim: BFGS > > x <- as.matrix(seq(0, 1, , 100)) > p <- predict(k_R, x, TRUE, FALSE) > > pdf("rplot.pdf") # plot to file > plot(f) > points(X, y) > > lines(x, p$mean, col = 'blue') > polygon(c(x, rev(x)), c(p$mean - 2 * p$stdev, rev(p$mean + 2 * p$stdev)), border = NA, col = rgb(0, 0, 1, 0.2)) > > s <- simulate(k_R,nsim = 10, seed = 123, x=x) > plot(f) > points(X,y) > matplot(x,s,col=rgb(0,0,1,0.2),type='l',lty=1,add=T) > > Xn <- as.matrix(c(0.3,0.4)) > yn <- f(Xn) > print(k_R) * data: 5x[0,1] -> 5x[0.030241,0.772403] * trend constant (est.): 0.453087 * variance (est.): 0.0653536 * covariance: * kernel: gauss * range (est.): 0.02 * fit: * objective: LL * optim: BFGS > update(k_R, yn, Xn) > print(k_R) * data: 7x[0,1] -> 7x[0.030241,1.01542] * trend constant (est.): 0.50458 * variance (est.): 0.0979075 * covariance: * kernel: gauss * range (est.): 0.117859 * fit: * objective: LL * optim: BFGS > > proc.time() user system elapsed 0.40 0.14 0.54