Gaussian Process Modelling in 'greta'

Provides a syntax to create and combine Gaussian process kernels in 'greta'. You can then use these kernels to define either full rank or sparse Gaussian processes, and project a fitted process to new coordinates. This lets you include Gaussian process components in the statistical models you write with 'greta'. This is an extension to the 'greta' software, Golding (2019) .


greta.gp: Gaussian Process in greta

R-CMD-check CRANstatus Codecov testcoverage

greta.gp extends greta to let you define Gaussian processes as part of your model. It provides a syntax to create and combine GP kernels, and use them to define either full rank or sparse Gaussian processes.

Installation

You can install the current release version of greta.gp from CRAN:

install.packages("greta.gp")

Or install the development version of greta.gp from r-universe:

install.packages("greta.gp", repos = "https://greta-dev.r-universe.dev")

You can also install the development version of greta.gp via GitHub:

remotes::install_github("greta-dev/greta.gp")

Example usage

# simulate data
x <- runif(20, 0, 10)
y <- sin(x) + rnorm(20, 0, 0.5)
x_plot <- seq(-1, 11, length.out = 200)
library(greta)
library(greta.gp)

# hyperparameters
rbf_var <- lognormal(0, 1)
rbf_len <- lognormal(0, 1)
obs_sd <- lognormal(0, 1)

# kernel & GP
kernel <- rbf(rbf_len, rbf_var) + bias(1)
f <- gp(x, kernel)

# likelihood
distribution(y) <- normal(f, obs_sd)

# prediction
f_plot <- project(f, x_plot)
# fit the model by Hamiltonian Monte Carlo
m <- model(f_plot)
draws <- mcmc(m, n_samples = 250)
# plot 200 posterior samples
# plot 200 posterior samples
plot(
  y ~ x,
  pch = 16,
  col = grey(0.4),
  xlim = c(0, 10),
  ylim = c(-2.5, 2.5),
  las = 1,
  fg = grey(0.7),
)
for (i in 1:200) {
  lines(draws[[1]][i, ] ~ x_plot,
    lwd = 2,
    col = rgb(0.7, 0.1, 0.4, 0.1)
  )
}

Code of Conduct

Please note that the greta.gp project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("greta.gp")

0.2.3 by Nicholas Tierney, 3 months ago


https://github.com/greta-dev/greta.gp, https://greta-dev.github.io/greta.gp/


Report a bug at https://github.com/greta-dev/greta.gp/issues


Browse source code at https://github.com/cran/greta.gp


Authors: Nick Golding [aut, cph] (ORCID: , Jian Yen [ctb] , Nicholas Tierney [aut, cre] (ORCID:


Documentation:   PDF Manual  


Apache License (>= 2) license


Imports cli, glue, rlang, tensorflow

Depends on greta

Suggests covr, knitr, rmarkdown, spelling, testthat

System requirements: Python (>= 3.7.0) with header files and shared library; TensorFlow (>= v2.0.0; https://www.tensorflow.org/); TensorFlow Probability (v0.8.0; https://www.tensorflow.org/probability/)


See at CRAN