covANOVA: Creator for the Class '"covANOVA"'

Description Usage Arguments Details Value Examples

View source: R/covANOVA.R

Description

Creator for the class "covANOVA".

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
covANOVA(k1Fun1 = k1Fun1Gauss,
      cov = c("corr", "homo"),
      iso = 0, iso1 = 1L,
      hasGrad = TRUE,
      inputs = NULL,
      d = NULL,
      parNames,
      par = NULL, parLower = NULL, parUpper = NULL,
      label = "ANOVA kernel",
      ...)

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 value of the variance parameter δ for the covariance kernel. Contrarily to other kernel classes, that parameter is not equal to the variance. Thus, mind that choosing ("corr") corresponds to δ=1 but does not correspond to a correlation kernel, see details below. 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 covANOVA object with their name suffixed by the dimension. When iso1 is 1 only one shape parameter will be created in the covANOVA 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 ANOVA kernel on the d-dimensional Euclidean space takes the form

K(x1, x2) = δ^2 * prod_l (1 + τ[l]^2 k1(r[l])

where k1(r) is a suitable correlation kernel for a one-dimensional input, and r[l] is given by r[l] = (x2[l] - x2[l]) / θ[l] for l =1 to d.

In this default form, the ANOVA kernel depends on 2d + 1 parameters: the ranges θ[l] > 0, the variance ratios τ[l]^2, and the variance parameter δ^2.

An isotropic form uses the same range θ for all inputs, i.e. sets θ[l]=θ for all l. This is obtained by using iso = TRUE.

A correlation version uses δ^2 = 1. This is obtained by using cov = "corr". Mind that it does not correspond to a correlation kernel. Indeed, in general, the variance is equal to

K(x, x) = δ^2 * prod_l (1 + τ[l]^2).

Finally, the correlation kernel k1(r) can depend on a "shape" parameter, e.g. have the form k1(r, α). The extra shape parameter α will be considered then as a parameter of the resulting ANOVA kernel, making it possible to estimate it by ML along with the range(s) and the variance.

Value

An object with class "covANOVA".

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
## Not run: 
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 <- covANOVA(k1Fun1 = k1Fun1Matern5_2, d = 2, cov = "homo")
    coefUpper(mycov) <- c(2.0, 2.0, 5.0, 5.0, 1e10)
    mygp <- gp(y ~ 1, data = data.frame(X, y),
               cov = mycov, multistart = 100, noise = TRUE)

    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)))
    
}

## End(Not run)

kergp documentation built on March 18, 2021, 5:06 p.m.