composition: Compositional kernels

Description Usage Arguments Value See Also Examples

Description

Construct a new kernel by combining existing kernels, either by summation, multiplication or the kronecker product.

Summation and multiplication require that the covariance matrices produced the two kernels have the same dimension (same number of rows in the input columns) and result in a kernel with the same dimension as its inputs.

The kronecker product doesn't require that the input functions have the same dimension, and the dimension of the output is the product of the dimensions of the inputs (i.e. an m-by-m matrix kroneckered with an n-by-n matrix gives rise to an nm-by-nm matrix).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## S3 method for class 'kernel'
sum(..., na.rm = FALSE)

## S3 method for class 'kernel'
kernel1 + kernel2

## S3 method for class 'kernel'
prod(..., na.rm = FALSE)

## S3 method for class 'kernel'
kernel1 * kernel2

## S3 method for class 'kernel'
kernel ^ power

kron(kernel1, kernel2)

kernel1 %x% kernel2

Arguments

na.rm

an unused argument for consistency with the generic sum function

kernel, kernel1, kernel2

kernel objects to be combined

power

an integer (or integer-esque numeric) giving the power to which to raise the kernel function. If power is not integer-esque (that is power != round(power)) a warning is issued and the power rounded.

...

several kernel objects to be combined

Value

A kernel object for which there are a range of associated functions, see kernel and access for details.

See Also

Other kernel.constructors: expo, iid, int, lin, mat32, mat52, per, rbf, rq

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# construct a kernel with one feature
k1 <- rbf('temperature')

# and another with two features
k2 <- rbf(c('temperature', 'pressure'))


# sum lots of kernels
k_sum <- sum(k1, k2, k1)

# evaluate the function and look at the matrix
image(k_sum(pressure))
 

# sum two kernels
k_1p2 <- k1 + k2

# evaluate the function and look at the matrix
image(k_1p2(pressure))
 

# multiply lots of kernels
k_prod <- prod(k1, k2, k1)

# evaluate the function and look at the matrix
image(k_prod(pressure))
 

# multiply two kernels
k_1_2 <- k1 * k2

# evaluate the function and look at the matrix
image(k_1_2(pressure))
 
# get a cubic kernel
k <- int() + lin('pressure', c = 400, sigma = 0.003)
k_cu <- k ^ 3

# evaluate the function and look at the matrix
image(k_cu(pressure))

# look at example draws from the original and cubed kernel
demoKernel(k, pressure) 
demoKernel(k_cu, pressure) 
 

# get the kronecker product of two kernels
k_kron <- kron(k1, k2)

# evaluate the function and look at the matrix
image(k_kron(pressure))
 

# get the kronecker product of two kernels again
k_kron <- k1 %x% k2

# evaluate the function and look at the matrix
image(k_kron(pressure))
 

goldingn/gpe documentation built on May 17, 2019, 7:41 a.m.