R: Predict from the composite Gaussian process model
predict.CGP
R Documentation
Predict from the composite Gaussian process model
Description
Compute predictions from the composite Gaussian process (CGP) model. 95% prediction intervals can also be calculated.
Usage
## S3 method for class 'CGP'
predict(object, newdata = NULL, PI = FALSE, ...)
Arguments
object
An object of class "CGP"
newdata
Optional. The matrix of predictive input locations, where each row of newdata corresponds to one predictive location
PI
If TRUE, 95% prediction intervals are also calculated. Default is FALSE
...
For compatibility with generic method predict
Details
Given an object of “CGP” class, this function predicts responses at unobserved newdata locations. If the PI is set to be TRUE, 95% predictions intervals are also computed.
If newdata is equal to the design matrix of the object, predictions from the CGP model will be identical to the yobs component of the object and the width of the prediction intervals will be shrunk to zero. This is due to the interpolating property of the predictor.
Value
The function returns a list containing the following components:
Yp
Vector of predictive values at newdata locations (Yp=gp+lp)
gp
Vector of predictive values at newdata locations from the global process
lp
Vector of predictive values at newdata locations from the local process
v
Vector of predictive standardized local volatilities at newdata locations
Y_low
If PI=TRUE, vector of 5% predictive quantiles at newdata locations
Y_up
If PI=TRUE, vector of 95% predictive quantiles at newdata locations
Author(s)
Shan Ba <shanbatr@gmail.com> and V. Roshan Joseph <roshan@isye.gatech.edu>
References
Ba, S. and V. Roshan Joseph (2012) “Composite Gaussian Process Models for Emulating Expensive Functions”. Annals of Applied Statistics, 6, 1838-1860.
See Also
CGP, print.CGP, summary.CGP
Examples
### 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")
#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)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(CGP)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/CGP/predict.CGP.Rd_%03d_medium.png", width=480, height=480)
> ### Name: predict.CGP
> ### Title: Predict from the composite Gaussian process model
> ### Aliases: predict.CGP
>
> ### ** Examples
>
> ### 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")
>
> #Fit the CGP model
> mod<-CGP(X,yobs)
> summary(mod)
$call
CGP.default(X = X, yobs = yobs)
$Lambda
[1] 0.01878833
$Theta
[,1]
[1,] 2.438516
$Alpha
[,1]
[1,] 578.0889
$Bandwidth
[1] 1
$rmscv
[1] 0.303545
$mu
[,1]
[1,] 1.610951
$tau2
[,1]
[1,] 4.140466
$best.start
[1] 5.144455e-02 5.202971e+01 2.996905e+03 5.930693e-01
$objval
[1] -40.17315
attr(,"class")
[1] "summary.CGP"
>
> mod$objval
[1] -40.17315
> #-40.17315
> mod$lambda
[1] 0.01878833
> #0.01877432
> mod$theta
[,1]
[1,] 2.438516
> #2.43932
> mod$alpha
[,1]
[1,] 578.0889
> #578.0898
> mod$bandwidth
[1] 1
> #1
> mod$rmscv
[1] 0.303545
> #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)
>
>
>
>
>
>
> dev.off()
null device
1
>