# NOT RUN {
### A simulated example from Gramacy and Lee (2012) ``Cases for the nugget
### in modeling computer experiments''. \emph{Statistics and Computing}, 22, 713-722.
#Training data
X<-c(0.775,0.83,0.85,1.05,1.272,1.335,1.365,1.45,1.639,1.675,
1.88,1.975,2.06,2.09,2.18,2.27,2.3,2.36,2.38,2.39)
yobs<-sin(10*pi*X)/(2*X)+(X-1)^4
#Testing data
UU<-seq(from=0.7,to=2.4,by=0.001)
y_true<-sin(10*pi*UU)/(2*UU)+(UU-1)^4
plot(UU,y_true,type="l",xlab="x",ylab="y")
points(X,yobs,col="red")
# }
# NOT RUN {
#Fit the CGP model
mod<-CGP(X,yobs)
summary(mod)
mod$objval
#-40.17315
mod$lambda
#0.01877432
mod$theta
#2.43932
mod$alpha
#578.0898
mod$bandwidth
#1
mod$rmscv
#0.3035192
#Predict for the testing data 'UU'
modpred<-predict(mod,UU)
#Plot the fitted CGP model
#Red: final predictor; Blue: global trend
lines(UU,modpred$Yp,col="red",lty=3,lwd=2)
lines(UU,modpred$gp,col="blue",lty=5,lwd=1.8)
# }
Run the code above in your browser using DataLab