covOrd: Warping-Based Covariance for an Ordinal Input

Description Usage Arguments Details Value See Also Examples

View source: R/covQualOrd.R

Description

Creator function for the class covOrd-class

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
covOrd(ordered, 
       k1Fun1 = k1Fun1Matern5_2, 
       warpFun = c("norm", "unorm", "power", "spline1", "spline2"), 
       cov = c("corr", "homo"), 
       hasGrad = TRUE, inputs = "u", 
       par = NULL, parLower = NULL, parUpper = NULL, 
       warpKnots = NULL, nWarpKnots = NULL,
       label = "Ordinal kernel", 
       intAsChar = TRUE, 
       ...)

Arguments

ordered

An object coerced to ordered representing an ordinal input. Only the levels and their order will be used.

k1Fun1

A function representing a 1-dimensional stationary kernel function, with no or fixed parameters.

warpFun

Character corresponding to an increasing warping function. See warpFun.

cov

Character indicating whether a correlation or homoscedastic kernel is used.

hasGrad

Object of class "logical". If TRUE, both k1Fun1 and warpFun must return the gradient as an attribute of the result.

inputs

Character: name of the ordinal input.

par, parLower, parUpper

Numeric vectors containing covariance parameter values/bounds in the following order: warping, range and variance if required (cov == "homo").

warpKnots

Numeric vector containing the knots used when a spline warping is chosen. The knots must be in [0, 1], and 0 and 1 are automatically added if not provided. The number of knots cannot be greater than the number of levels.

nWarpKnots

Number of knots when a spline warping is used. Ignored if warpKnots is given. nWarpKnots cannot be greater than the number of levels.

label

Character giving a brief description of the kernel.

intAsChar

Logical. If TRUE (default), an integer-valued input will be coerced into a character. Otherwise, it will be coerced into a factor.

...

Not used at this stage.

Details

Covariance kernel for qualitative ordered inputs obtained by warping.

Let u be an ordered factor with levels u[1], ..., u[L]. Let k1 be a 1-dimensional stationary kernel (with no or fixed parameters), F a warping function i.e. an increasing function on the interval [0,1] and theta a scale parameter. Then k is defined by:

k(u[i], u[j]) = k1([F(z[i]) - F(z[j])]/theta)

where z[1], ..., z[L] form a regular sequence from 0 to 1 (included). At this stage, the possible choices are:

Notice that for unnormalized F, we set theta to 1, in order to avoid overparameterization.

Value

An object of class covOrd-class, inheriting from covQual-class.

See Also

covOrd-class, warpFun

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
u <- ordered(1:6, labels = letters[1:6])

myCov <- covOrd(ordered = u, cov = "homo", intAsChar = FALSE)
myCov
coef(myCov) <- c(mean = 0.5, sd = 1, theta = 3, sigma2 = 2)
myCov

checkX(myCov, X = data.frame(u = c(1L, 3L)))
covMat(myCov, X = data.frame(u = c(1L, 3L)))

myCov2 <- covOrd(ordered = u, k1Fun1 = k1Fun1Cos, warpFun = "power")
coef(myCov2) <- c(pow = 1, theta = 1) 
myCov2

plot(myCov2, type = "cor", method = "ellipse")
plot(myCov2, type = "warp", col = "blue", lwd = 2)

myCov3 <- covOrd(ordered = u, k1Fun1 = k1Fun1Cos, warpFun = "spline1")
coef(myCov3) <- c(rep(0.5, 2), 2, rep(0.5, 2))
myCov3

plot(myCov3, type = "cor", method = "ellipse")
plot(myCov3, type = "warp", col = "blue", lwd = 2)


str(warpPower)  # details on the list describing the Power cdf
str(warpNorm)   # details on the list describing the Normal cdf

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