if (FALSE) {
if (require(DiceKriging)) {
## a 16-points factorial design and the corresponding response
d <- 2; n <- 16; x <- seq(from = 0.0, to = 1.0, length.out = 4)
X <- expand.grid(x1 = x, x2 = x)
y <- apply(X, 1, DiceKriging::branin)
## kriging model with matern5_2 covariance structure, constant
## trend. A crucial point is to set the upper bounds!
mycov <- covANOVA(k1Fun1 = k1Fun1Matern5_2, d = 2, cov = "homo")
coefUpper(mycov) <- c(2.0, 2.0, 5.0, 5.0, 1e10)
mygp <- gp(y ~ 1, data = data.frame(X, y),
cov = mycov, multistart = 100, noise = TRUE)
nGrid <- 50; xGrid <- seq(from = 0, to = 1, length.out = nGrid)
XGrid <- expand.grid(x1 = xGrid, x2 = xGrid)
yGrid <- apply(XGrid, 1, DiceKriging::branin)
pgp <- predict(mygp, XGrid)$mean
mykm <- km(design = X, response = y)
pkm <- predict(mykm, XGrid, "UK")$mean
c("km" = sqrt(mean((yGrid - pkm)^2)),
"gp" = sqrt(mean((yGrid - pgp)^2)))
}
}
Run the code above in your browser using DataLab