Package ''

Title: Gaussian Process Modelling in 'greta'
Description: Provides a syntax to create and combine Gaussian process kernels in 'greta'. You can then them to define either full rank or sparse Gaussian processes. This is an extension to the 'greta' software, Golding (2019) <doi:10.21105/joss.01601>.
Authors: Nick Golding [aut, cph] , Jian Yen [ctb], Nicholas Tierney [aut, cre]
Maintainer: Nicholas Tierney <[email protected]>
License: Apache License (>= 2)
Built: 2024-06-28 04:02:03 UTC

Help Index

Define a Gaussian process


Define Gaussian processes, and project them to new coordinates.


gp(x, kernel, inducing = NULL, n = 1, tol = 1e-04)

project(f, x_new, kernel = NULL)


x, x_new

greta array giving the coordinates at which to evaluate the Gaussian process


a kernel function created using one of the kernel() methods


an optional greta array giving the coordinates of inducing points in a sparse (reduced rank) Gaussian process model


the number of independent Gaussian processes to define with the same kernel


a numerical tolerance parameter, added to the diagonal of the self-covariance matrix when computing the cholesky decomposition. If the sampler is hitting a lot of numerical errors, increasing this parameter could help


a greta array created with gp$gp representing the values of one or more Gaussian processes


gp() returns a greta array representing the values of the Gaussian process(es) evaluated at x. This Gaussian process can be made sparse (via a reduced-rank representation of the covariance) by providing an additional set of inducing point coordinates inducing. project() evaluates the values of an existing Gaussian process (created with gp()) to new data.


A greta array


## Not run: 
# build a kernel function on two dimensions
k1 <- rbf(lengthscales = c(0.1, 0.2), variance = 0.6)
k2 <- bias(variance = lognormal(0, 1))
K <- k1 + k2

# use this kernel in a full-rank Gaussian process
f <- gp(1:10, K)

# or in sparse Gaussian process
f_sparse <- gp(1:10, K, inducing = c(2, 5, 8))

# project the values of the GP to new coordinates
f_new <- project(f, 11:15)

# or project with a different kernel (e.g. a sub-kernel)
f_new_bias <- project(f, 11:15, k2)

## End(Not run)

Gaussian process modelling in greta


A greta module to create and combine covariance functions and use them to build Gaussian process models in greta. See kernels() and gp()


Maintainer: Nicholas Tierney [email protected] (ORCID)


Other contributors:

  • Jian Yen [contributor]

See Also

Useful links:

Gaussian process kernels


Create and combine Gaussian process kernels (covariance functions) for use in Gaussian process models.





iid(variance, columns = 1)

rbf(lengthscales, variance, columns = seq_along(lengthscales))

  columns = seq_along(lengthscales)

linear(variances, columns = seq_along(variances))

polynomial(variances, offset, degree, columns = seq_along(variances))

expo(lengthscales, variance, columns = seq_along(lengthscales))

mat12(lengthscales, variance, columns = seq_along(lengthscales))

mat32(lengthscales, variance, columns = seq_along(lengthscales))

mat52(lengthscales, variance, columns = seq_along(lengthscales))

cosine(lengthscales, variance, columns = seq_along(lengthscales))

periodic(period, lengthscale, variance)


variance, variances

(scalar/vector) the variance of a Gaussian process prior in all dimensions (variance) or in each dimension (variances)


(scalar/vector integer, not a greta array) the columns of the data matrix on which this kernel acts. Must have the same dimensions as lengthscale parameters.


(scalar) additional parameter in rational quadratic kernel


(scalar) offset in polynomial kernel


(scalar) degree of polynomial kernel


(scalar) the period of the Gaussian process

lengthscale, lengthscales

(scalar/vector) the correlation decay distance along all dimensions (lengthscale) or each dimension ((lengthscales)) of the Gaussian process


The kernel constructor functions each return a function (of class greta_kernel) which can be executed on greta arrays to compute the covariance matrix between points in the space of the Gaussian process. The + and * operators can be used to combine kernel functions to create new kernel functions.

Note that bias and constant are identical names for the same underlying kernel.

iid is equivalent to bias where all entries in columns match (where the absolute euclidean distance is less than 1e-12), and white where they don't; i.e. an independent Gaussian random effect.


greta kernel with class "greta_kernel"


## Not run: 
# create a radial basis function kernel on two dimensions
k1 <- rbf(lengthscales = c(0.1, 0.2), variance = 0.6)

# evaluate it on a greta array to get the variance-covariance matrix
x <- greta_array(rnorm(8), dim = c(4, 2))

# non-symmetric covariance between two sets of points
x2 <- greta_array(rnorm(10), dim = c(5, 2))
k1(x, x2)

# create a bias kernel, with the variance as a variable
k2 <- bias(variance = lognormal(0, 1))

# combine two kernels and evaluate
K <- k1 + k2
K(x, x2)

# other kernels
constant(variance = lognormal(0, 1))
white(variance = lognormal(0, 1))
iid(variance = lognormal(0,1))
rational_quadratic(lengthscales = c(0.1, 0.2), alpha = 0.5, variance = 0.6)
linear(variances = 0.1)
polynomial(variances = 0.6, offset = 0.8, degree = 2)
expo(lengthscales = 0.6 ,variance = 0.9)
mat12(lengthscales = 0.5, variance = 0.7)
mat32(lengthscales = 0.4, variance = 0.8)
mat52(lengthscales = 0.3, variance = 0.9)
cosine(lengthscales = 0.68, variance = 0.8)
periodic(period = 0.71, lengthscale = 0.59, variance = 0.2)

## End(Not run)