Generalized.Rational.Kriging {rkriging} | R Documentation |
Generalized Rational Kriging
Description
This functions fits the generalized rational kriging model to the data.
Usage
Generalized.Rational.Kriging(
X,
y,
fit = TRUE,
kernel = NULL,
kernel.parameters = list(),
nlopt.parameters = list()
)
Arguments
X |
a matrix for input (feature) |
y |
a vector for output (target), only one-dimensional output is supported |
fit |
whether to fit the length scale parameters from data |
kernel |
a kernel class object |
kernel.parameters |
a list of parameters required for the kernel, if no kernel class object is provided |
nlopt.parameters |
a list of parameters required for NLopt, including choice of optimization algorithm and maximum number of evaluation |
Details
Ordinary kriging and rational kriging can be obtained as special cases of generalized rational kriging. Please see Joseph (2024) for details. The Spectra library is used for fast computation of the first eigenvalues/vectors. Only interpolation is available. Noisy output is not supported for generalized rational kriging.
The kernel choices are required and can be specified by
(i) providing the kernel class object to kernel
or (ii) specifying the kernel type and other parameters in kernel.parameters
.
Please see examples section of Fit.Kriging for detail usages.
When the lengthscale / correlation parameters are unknown,
all parameters including the constant mean can be estimated via Maximum Likelihood method by setting fit=TRUE
.
The initial / lower bound / upper bound of the lengthscale parameters can be provided in kernel.parameters
,
otherwise a good initial and range would be estimated from the data.
The optimization is performed via NLopt library,
a open-source library for nonlinear optimization.
All gradient-free optimization methods in NLopt
are supported and can be specified in nlopt.parameters
.
See nloptr::nloptr.print.options()
for the list of available derivative-free algorithms (prefix with NLOPT_GN or NLOPT_LN).
The maximum number of optimization steps can also be defined in nlopt.parameters
.
Please see examples section of Fit.Kriging for detail usages.
Value
A Generalized Rational Kriging Class Object.
Author(s)
Chaofan Huang and V. Roshan Joseph
References
Joseph, V. R. (2024). Rational Kriging. Journal of the American Statistical Association.
Qiu, Y., Guennebaud, G., & Niesen, J. (2015). Spectra: C++ library for large scale eigenvalue problems.
See Also
Fit.Kriging, Predict.Kriging, Get.Kriging.Parameters.
Examples
# one dimensional example
f <- function(x) {
x <- 0.5 + 2*x
y <- sin(10*pi*x)/(2*x) + (x-1)^4
return (y)
}
set.seed(1234)
# train set
n <- 30
p <- 1
X <- matrix(runif(n),ncol=p)
y <- apply(X, 1, f)
newX <- matrix(seq(0,1,length=1001), ncol=p)
# approach 1
kriging <- Generalized.Rational.Kriging(X, y, fit=TRUE,
kernel.parameters=list(type="RQ",alpha=1))
pred <- Predict.Kriging(kriging, newX)
plot(newX, f(newX), "l")
points(X, y, pch=16, col="blue")
lines(newX, pred$mean, col="red", lty=2)
lines(newX, pred$mean-2*pred$sd, col="red", lty=3)
lines(newX, pred$mean+2*pred$sd, col="red", lty=3)
Get.Kriging.Parameters(kriging)
# approach 2
kriging <- Fit.Kriging(X, y, interpolation=TRUE, fit=TRUE, model="GRK",
kernel.parameters=list(type="RQ",alpha=1))
pred <- Predict.Kriging(kriging, newX)
plot(newX, f(newX), "l")
points(X, y, pch=16, col="blue")
lines(newX, pred$mean, col="red", lty=2)
lines(newX, pred$mean-2*pred$sd, col="red", lty=3)
lines(newX, pred$mean+2*pred$sd, col="red", lty=3)
Get.Kriging.Parameters(kriging)