# Additional examples including real-world computer experiments are available at:
# https://bitbucket.org/gramacylab/deepgp-ex/
# \donttest{
# Booth function (inspired by the Higdon function)
f <- function(x) {
i <- which(x <= 0.58)
x[i] <- sin(pi * x[i] * 6) + cos(pi * x[i] * 12)
x[-i] <- 5 * x[-i] - 4.9
return(x)
}
# Training data
x <- seq(0, 1, length = 25)
y <- f(x)
# Testing data
xx <- seq(0, 1, length = 200)
yy <- f(xx)
plot(xx, yy, type = "l")
points(x, y, col = 2)
# Example 1: full model (nugget fixed)
fit <- fit_one_layer(x, y, nmcmc = 2000, true_g = 1e-6)
plot(fit)
fit <- trim(fit, 1000, 2)
fit <- predict(fit, xx, cores = 1)
plot(fit)
# Example 2: full model (nugget estimated, EI calculated)
fit <- fit_one_layer(x, y, nmcmc = 2000)
plot(fit)
fit <- trim(fit, 1000, 2)
fit <- predict(fit, xx, cores = 1, EI = TRUE)
plot(fit)
par(new = TRUE) # overlay EI
plot(xx[order(xx)], fit$EI[order(xx)], type = 'l', lty = 2,
axes = FALSE, xlab = '', ylab = '')
# Example 3: Vecchia approximated model (nugget estimated)
fit <- fit_one_layer(x, y, nmcmc = 2000, vecchia = TRUE, m = 10)
plot(fit)
fit <- trim(fit, 1000, 2)
fit <- predict(fit, xx, cores = 1)
plot(fit)
# }
Run the code above in your browser using DataLab