# \donttest{
################################################################################
### Variance of trace criterion landscape
################################################################################
library(hetGP)
set.seed(42)
nvar <- 2
n <- 20
# theta gives the subspace direction
f <- function(x, theta = pi/6, nugget = 1e-6){
if(is.null(dim(x))) x <- matrix(x, 1)
xact <- cos(theta) * x[,1] - sin(theta) * x[,2]
return(hetGP::f1d(xact) +
rnorm(n = nrow(x), sd = rep(nugget, nrow(x))))
}
design <- matrix(signif(runif(nvar*n), 2), ncol = nvar)
response <- apply(design, 1, f)
model <- mleHomGP(design, response, lower = rep(1e-4, nvar),
upper = rep(0.5,nvar), known = list(g = 1e-4))
C_hat <- C_GP(model)
ngrid <- 101
xgrid <- seq(0, 1,, ngrid)
Xgrid <- as.matrix(expand.grid(xgrid, xgrid))
filled.contour(matrix(f(Xgrid), ngrid))
Ctr_grid <- apply(Xgrid, 1, C_tr, C = C_hat)
filled.contour(matrix(Ctr_grid, ngrid), color.palette = terrain.colors,
plot.axes = {axis(1); axis(2); points(design, pch = 20)})
# }
Run the code above in your browser using DataLab