##To begin, make sure you have loaded adapt, calibrator, emulator, and ##mvtnorm using the package manager. x.training<-seq(0,1,0.1) dim(x.training) <- c(11,1) f<-function(x) { 1 } datagenerator<- function(x) { exp(-x)*sin((2*pi*x)) + x } y.training <- datagenerator(x.training) ##We plot the true function for illustrative purposes x.pred<-seq(0,1,.01) plot(x.pred, datagenerator(x.pred),type="l", ylab="y(x)",col = "green", lwd=1.5) ## Note that the values of scales.start, lower, and upper below are the ## values of the natural logarithms of the scale parameters. ## You can adjust the start , lower, and upper values to see what effect ## these have on the mle computed by scales.optim scales.optim <- optimal.scales(val = x.training, scales.start = 10, d = y.training, method="L-BFGS-B", lower=1, upper=100, give=FALSE) A <- corr.matrix(xold = x.training, scales = scales.optim) Ainv <- solve(A) x.pred <-seq(0,1,0.01) dim(x.pred)<-c(101,1) newpreds <- interpolant.quick(x.pred, y.training, x.training, Ainv, scales = scales.optim, func = f, give.Z = TRUE, power = 2) inputs <- x.pred predictions <- newpreds$mstar.star std.errs <- newpreds$Z results <- data.frame(inputs, predictions, std.errs) results lines(inputs, predictions, type="l", lty = 4, col = "red", lwd=1.5) lines(inputs, predictions + 2*std.errs, lty = 4, lwd=1.5) lines(inputs, predictions - 2*std.errs, lty = 4, lwd=1.5)