Learn R Programming

kergp (version 0.5.7)

covTP: Creator for the Class "covTP"

Description

Creator for the class "covTP".

Usage

covTP(k1Fun1 = k1Fun1Gauss,
      cov = c("corr", "homo"),
      iso = 0, iso1 = 1L,
      hasGrad = TRUE,
      inputs = NULL,
      d = NULL,
      parNames,
      par = NULL, parLower = NULL, parUpper = NULL,
      label = "Tensor product kernel",
      ...)

Value

An object with class "covTP".

Arguments

k1Fun1

A kernel function of a scalar numeric variable, and possibly of an extra "shape" parameter. This function can also return the first-order derivative or the two-first order derivatives as an attribute with name "der" and with a matrix content. When an extra shape parameter exists, the gradient can also be returned as an attribute with name "gradient", see Examples later. The name of the function can be given as a character string.

cov

A character string specifying the kind of covariance kernel: correlation kernel ("corr") or kernel of a homoscedastic GP ("homo"). Partial matching is allowed.

iso

Integer. The value 1L corresponds to an isotropic covariance, with all the inputs sharing the same range value.

iso1

Integer. This applies only when k1Fun1 contains one or more parameters that can be called 'shape' parameters. At now, only one such parameter can be found in k1Fun1 and consequently iso1 must be of length one. With iso1 = 0 the shape parameter in k1Fun1 will generate d parameters in the covTP object with their name suffixed by the dimension. When iso1 is 1 only one shape parameter will be created in the covTP object.

hasGrad

Integer or logical. Tells if the value returned by the function k1Fun1 has an attribute named "der" giving the derivative(s).

inputs

Character. Names of the inputs.

d

Integer. Number of inputs.

parNames

Names of the parameters. By default, ranges are prefixed "theta_" in the non-iso case and the range is named "theta" in the iso case.

par

Numeric values for the parameters. Can be NA.

parLower

Numeric values for the lower bounds on the parameters. Can be -Inf.

parUpper

Numeric values for the upper bounds on the parameters. Can be Inf.

label

A short description of the kernel object.

...

Other arguments passed to the method new.

Details

A tensor-product kernel on the \(d\)-dimensional Euclidean space takes the form $$K(\mathbf{x},\,\mathbf{x}') = \sigma^2 \prod_{\ell = 1}^d \kappa(r_\ell)$$ where \(\kappa(r)\) is a suitable correlation kernel for a one-dimensional input, and \(r_\ell\) is given by \(r_\ell := [x_\ell - x'_\ell] / \theta_\ell\) for \(\ell = 1\) to \(d\).

In this default form, the tensor-product 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 \(\kappa(r)\) can depend on a "shape" parameter, e.g. have the form \(\kappa(r;\,\alpha)\). The extra shape parameter \(\alpha\) will be considered then as a parameter of the resulting tensor-product kernel, making it possible to estimate it by ML along with the range(s) and the variance.

Examples

Run this code
if (FALSE) {
if (require(DiceKriging)) {
    ## a 16-points factorial design and the corresponding response
    d <- 2; n <- 16; x <- seq(from = 0.0, to = 1.0, length.out = 4)
    X <- expand.grid(x1 = x, x2 = x)
    y <- apply(X, 1, DiceKriging::branin)

    ## kriging model with matern5_2 covariance structure, constant
    ## trend. A crucial point is to set the upper bounds!
    mycov <- covTP(k1Fun1 = k1Fun1Matern5_2, d = 2, cov = "homo")
    coefUpper(mycov) <- c(2.0, 2.0, 1e10)
    mygp <- gp(y ~ 1, data = data.frame(X, y),
               cov = mycov, multistart = 100, noise = FALSE)

    nGrid <- 50; xGrid <- seq(from = 0, to = 1, length.out = nGrid)
    XGrid <- expand.grid(x1 = xGrid, x2 = xGrid)
    yGrid <- apply(XGrid, 1, DiceKriging::branin)
    pgp <- predict(mygp, XGrid)$mean

    mykm <- km(design = X, response = y)
    pkm <- predict(mykm, XGrid, "UK")$mean
    c("km" = sqrt(mean((yGrid - pkm)^2)),
      "gp" = sqrt(mean((yGrid - pgp)^2)))
    
}
}

Run the code above in your browser using DataLab