| covRadial {kergp} | R Documentation |
Creator for the Class "covRadial"
Description
Creator for the class "covRadial", which describes radial
kernels.
Usage
covRadial(k1Fun1 = k1Fun1Gauss,
cov = c("corr", "homo"),
iso = 0, hasGrad = TRUE,
inputs = NULL, d = NULL,
parNames, par = NULL,
parLower = NULL, parUpper = NULL,
label = "Radial kernel",
...)
Arguments
k1Fun1 |
A function of a scalar numeric variable, and possibly of an
extra "shape" parameter. This function should return the first-order
derivative or the two-first order derivatives as an attribute with
name |
cov |
A character string specifying the kind of covariance kernel:
correlation kernel ( |
iso |
Integer. The value |
hasGrad |
Integer or logical. Tells if the value returned by the function
|
inputs |
Character. Names of the inputs. |
d |
Integer. Number of inputs. |
par, parLower, parUpper |
Optional numeric values for the lower bounds on the parameters. Can be
|
parNames |
Names of the parameters. By default, ranges are prefixed
|
label |
A short description of the kernel object. |
... |
Other arguments passed to the method |
Details
A radial kernel on the d-dimensional Euclidean space
takes the form
K(\mathbf{x},\,\mathbf{x}') = \sigma^2 k_1(r)
where k_1(r) is a suitable correlation kernel for a
one-dimensional input, and r is given by
r = \left\{\sum_{\ell = 1}^d [x_\ell - x'_\ell]^2 / \theta_\ell^2
\right\}^{1/2}.
In this default form, the radial kernel depends on d + 1 parameters:
the ranges \theta_\ell >0 and the
variance \sigma^2.
An isotropic form uses the same range \theta for
all inputs, i.e. sets \theta_\ell =
\theta for all \ell. This is obtained
by using iso = TRUE.
A correlation version uses \sigma^2 = 1. This
is obtained by using cov = "corr".
Finally, the correlation kernel k_1(r) can depend on a
"shape" parameter, e.g. have the form k_1(r;\,\alpha). The extra shape parameter \alpha will be
considered then as a parameter of the resulting radial kernel, making
it possible to estimate it by ML along with the range(s) and the
variance.
Value
An object with class "covRadial".
Note
When k1Fun1 has more than one formal argument, its arguments
with position > 1 are assumed to be "shape" parameters of the
model. Examples are functions with formals function(x, shape =
1.0) or function(x, alpha = 2.0, beta = 3.0), corresponding to
vector of parameter names c("shape") and c("alpha",
"beta"). Using more than one shape parameter has not been tested
yet.
Remind that using a one-dimensional correlation kernel
k_1(r) here does not warrant that a positive
semi-definite kernel will result for any dimension
d. This question relates to Schoenberg's theorem and the concept
of completely monotone functions.
References
Gregory Fassauher and Michael McCourt (2016) Kernel-based Approximation Methods using MATLAB. World Scientific.
See Also
k1Fun1Exp, k1Fun1Matern3_2,
k1Fun1Matern5_2 or k1Fun1Gauss for
examples of functions that can be used as values for the k1Fun1
formal.
Examples
set.seed(123)
d <- 2; ng <- 20
xg <- seq(from = 0, to = 1, length.out = ng)
X <- as.matrix(expand.grid(x1 = xg, x2 = xg))
## ============================================================================
## A radial kernel using the power-exponential one-dimensional
## function
## ============================================================================
d <- 2
myCovRadial <- covRadial(k1Fun1 = k1Fun1PowExp, d = 2, cov = "homo", iso = 1)
coef(myCovRadial)
inputNames(myCovRadial) <- colnames(X)
coef(myCovRadial) <- c(alpha = 1.8, theta = 2.0, sigma2 = 4.0)
y <- simulate(myCovRadial, X = X, nsim = 1)
persp(x = xg, y = xg, z = matrix(y, nrow = ng))
## ============================================================================
## Define the inverse multiquadric kernel function. We return the first two
## derivatives and the gradient as attributes of the result.
## ============================================================================
myk1Fun <- function(x, beta = 2) {
prov <- 1 + x * x
res <- prov^(-beta)
der <- matrix(NA, nrow = length(x), ncol = 2)
der[ , 1] <- - beta * 2 * x * res / prov
der[ , 2] <- -2 * beta * (1 - (1 + 2 * beta) * x * x) * res / prov / prov
grad <- -log(prov) * res
attr(res, "gradient") <- grad
attr(res, "der") <- der
res
}
myCovRadial1 <- covRadial(k1Fun1 = myk1Fun, d = 2, cov = "homo", iso = 1)
coef(myCovRadial1)
inputNames(myCovRadial1) <- colnames(X)
coef(myCovRadial1) <- c(beta = 0.2, theta = 0.4, sigma2 = 4.0)
y1 <- simulate(myCovRadial1, X = X, nsim = 1)
persp(x = xg, y = xg, z = matrix(y1, nrow = ng))