View source: R/buildKrigingForrester.R
| buildKriging | R Documentation |
This function builds a Kriging model based on code by Forrester et al.. By default exponents (p) are fixed at a value of two, and a nugget (or regularization constant) is used. To correct the uncertainty estimates in case of nugget, re-interpolation is also by default turned on.
buildKriging(x, y, control = list())
x |
design matrix (sample locations) |
y |
vector of observations at |
control |
(list), with the options for the model building procedure. Note: This can also be changed after the model has been built, by manipulating the respective
|
The model uses a Gaussian kernel: k(x,z)=exp(-sum(theta_i * |x_i-z_i|^p_i)). By default, p_i = 2.
Note that if dimension x_i is a factor variable (see parameter types), Hamming distance will be used
instead of |x_i-z_i|.
an object of class kriging. Basically a list, with the options
and found parameters for the model which has to be passed to the predictor function:
x sample locations (scaled to values between 0 and 1)
y observations at sample locations (see parameters)
thetaLower lower boundary for theta (see parameters)
thetaUpper upper boundary for theta (see parameters)
algTheta algorithm to find theta (see parameters)
budgetAlgTheta budget for the above mentioned algorithm (see parameters)
optimizeP boolean that specifies whether the exponents (p) were optimized (see parameters)
normalizeymin minimum in normalized space
normalizeymax maximum in normalized space
normalizexmin minimum in input space
normalizexmax maximum in input space
dmodeltheta vector of activity parameters
Theta log_10 vector of activity parameters (i.e. log10(dmodeltheta))
dmodellambda regularization constant (nugget)
Lambda log_10 of regularization constant (nugget) (i.e. log10(dmodellambda))
yonemu Ay-ones*mu
ssq sigma square
mu mean mu
Psi matrix large Psi
Psinv inverse of Psi
nevals number of Likelihood evaluations during MLE
Forrester, Alexander I.J.; Sobester, Andras; Keane, Andy J. (2008). Engineering Design via Surrogate Modelling - A Practical Guide. John Wiley & Sons.
predict.kriging
## Create design points
set.seed(1)
x <- cbind(runif(20)*15-5,runif(20)*15)
y <- funBranin(x)
## Create model with default settings
fit <- buildKriging(x,y,control = list(algTheta=optimLHD))
## Print model parameters
print(fit)
## Predict at new location
predict(fit,cbind(1,2))
## True value at location
funBranin(matrix(c(1,2), 1))
##
## Next Example: Handling factor variables
## create a test function:
braninFunctionFactor <- function (x) {
y <- (x[2] - 5.1/(4 * pi^2) * (x[1] ^2) + 5/pi * x[1] - 6)^2 +
10 * (1 - 1/(8 * pi)) * cos(x[1] ) + 10
if(x[3]==1)
y <- y +1
else if(x[3]==2)
y <- y -1
y
}
## create training data
set.seed(1)
x <- cbind(runif(50)*15-5,runif(50)*15,sample(1:3,50,replace=TRUE))
y <- as.matrix(apply(x,1,braninFunctionFactor))
## fit the model (default: assume all variables are numeric)
fitDefault <- buildKriging(x,y,control = list(algTheta=optimDE))
## fit the model (give information about the factor variable)
fitFactor <- buildKriging(x,y,control =
list(algTheta=optimDE,types=c("numeric","numeric","factor")))
## create test data
xtest <- cbind(runif(200)*15-5,runif(200)*15,sample(1:3,200,replace=TRUE))
ytest <- as.matrix(apply(xtest,1,braninFunctionFactor))
## Predict test data with both models, and compute error
ypredDef <- predict(fitDefault,xtest)$y
ypredFact <- predict(fitFactor,xtest)$y
mean((ypredDef-ytest)^2)
mean((ypredFact-ytest)^2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.