Learn R Programming

KrigInv (version 1.3.1)

predict_update_km: Quick computation of updated kriging means and variances.

Description

This function uses kriging update formula to quickly compute kriging mean and variances at points newdata, when a point newX is added. The required additional informations are the old kriging mean and variance at point newX, the output value f(newX), the old kriging mean and variances at points newdata and the kriging covariance between newX and newdata.

Usage

predict_update_km(newXmean, newXvar, newXvalue, 
newdata.oldmean, newdata.oldsd, kn)

Arguments

newXmean

Scalar: old kriging mean at newX (before adding newX to the design).

newXvar

Scalar: old kriging variance at newX (before adding newX to the design).

newXvalue

Scalar: value of the objective function at newX, f(newX).

newdata.oldmean

Vector: old kriging mean at the points newdata (before adding newX to the design)

newdata.oldsd

Vector: old kriging standard deviations at the points newdata (before adding newX to the design)

kn

Kriging covariances between the points newdata and newX. These covariances can be computed using the function computeQuickKrigcov

Value

A list with the following fields:

mean

Updated kriging mean at points newdata

sd

Updated kriging standard deviation at points newdata

lambda

New kriging weight of newX for the prediction at points newdata

References

Chevalier C., Bect J., Ginsbourger D., Vazquez E., Picheny V., Richet Y. (2011), Fast parallel kriging-based stepwise uncertainty reduction with application to the identification of an excursion set ,http://hal.archives-ouvertes.fr/hal-00641108/

Chevalier C., Ginsbourger D. (2012), Corrected Kriging update formulae for batch-sequential data assimilation ,http://arxiv.org/pdf/1203.6452.pdf

See Also

precomputeUpdateData, predict_nobias_km, computeQuickKrigcov

Examples

Run this code
# NOT RUN {
#predict_update_km

set.seed(8)
N <- 9 #number of observations
testfun <- branin

#a 9 points initial design
design <- data.frame( matrix(runif(2*N),ncol=2) )
response <- testfun(design)

#km object with matern3_2 covariance
#params estimated by ML from the observations
model <- km(formula=~., design = design, 
	response = response,covtype="matern3_2")

#points where we want to compute prediction (if a point new.x is added to the doe)
n.grid <- 20 #you can run it with 100
x.grid <- y.grid <- seq(0,1,length=n.grid)
newdata <- expand.grid(x.grid,y.grid)
precalc.data <- precomputeUpdateData(model=model,integration.points=newdata)
pred2 <- predict_nobias_km(object=model,newdata=newdata,type="UK",se.compute=TRUE)
newdata.oldmean <- pred2$mean; newdata.oldsd <- pred2$sd

new.x <- matrix(c(0.6,0.6),ncol=2)   #the point that we are going to add
pred1 <- predict_nobias_km(object=model,newdata=new.x,type="UK",se.compute=TRUE)
newXmean <- pred1$mean; newXvar <- pred1$sd^2; newXvalue <- pred1$mean + 2*pred1$sd

kn <- computeQuickKrigcov(model=model,integration.points=newdata,X.new=new.x,
                    precalc.data=precalc.data,F.newdata=pred1$F.newdata,
                    c.newdata=pred1$c)

updated.predictions <- predict_update_km(newXmean=newXmean,newXvar=newXvar,
newXvalue=newXvalue,newdata.oldmean=newdata.oldmean,
newdata.oldsd=newdata.oldsd,kn=kn)

#the new kriging variance is usually lower than the old one
updated.predictions$sd - newdata.oldsd 

z.grid1 <- matrix(newdata.oldsd, n.grid, n.grid)
z.grid2 <- matrix(updated.predictions$sd, n.grid, n.grid)

par(mfrow=c(1,2))

#plots: contour of the criterion, doe points and new point
image(x=x.grid,y=y.grid,z=z.grid1,col=grey.colors(10))
contour(x=x.grid,y=y.grid,z=z.grid1,15,add=TRUE)
points(design, col="black", pch=17, lwd=4,cex=2)
title("Kriging standard deviation")

image(x=x.grid,y=y.grid,z=z.grid2,col=grey.colors(10))
contour(x=x.grid,y=y.grid,z=z.grid2,15,add=TRUE)
points(design, col="black", pch=17, lwd=4,cex=2)
points(new.x, col="red", pch=17, lwd=4,cex=2)
title("updated Kriging standard deviation")

# }

Run the code above in your browser using DataLab