A mathematically grounded R toolkit for Gaussian processes, with an emphasis on transparent implementations, numerical stability, uncertainty quantification, and reproducible statistical workflows.
Goals
This project provides:
- covariance kernels with a consistent and composable API;
- exact Gaussian-process regression built from stable linear algebra;
- posterior prediction with explicit latent and observation uncertainty;
- marginal-likelihood based hyperparameter estimation;
- diagnostics and calibration tools;
- multidimensional ARD and time-series workflows;
- heteroscedastic and sparse FITC extensions;
- reproducible simulations and benchmarks;
- mathematics-first vignettes mapping equations directly to implementation objects.
The package is developed from first principles. Established R packages may be used as optional references for validation, but the core implementation remains explicit and inspectable.
Installation
The package depends only on base R. Install a released version from the source tarball attached to its GitLab release:
install.packages("gaussianprocesses_1.0.0.tar.gz", repos = NULL, type = "source")Or install the development version from GitLab:
# install.packages("remotes")
remotes::install_gitlab("DiogoRibeiro7/gaussian-processes-r", build_vignettes = TRUE)From a local clone, run R CMD INSTALL . in the repository root.
Example
library(gaussianprocesses)
set.seed(1)
x <- seq(-3, 3, length.out = 40)
y <- sin(x) + rnorm(length(x), sd = 0.1)
# Estimate kernel and noise hyperparameters by maximizing the marginal likelihood.
model <- optimize_gp(x, y, kernel = rbf_kernel(), noise_variance = 0.05)
# Latent-function and noisy-observation intervals are reported separately.
prediction <- predict_gp(model, c(-4, 0, 4))
prediction$latent_interval
prediction$prediction_intervalInside the data (x = 0) the latent interval is narrow and the prediction interval adds the estimated observation noise; outside the data (x = -4, x = 4) both widen. The vignettes and the worked time-series example develop this further.
Package structure
R/ R source code
man/ generated/reference documentation
tests/testthat/ unit tests
vignettes/ mathematical derivations and worked examples
inst/ examples, benchmark scripts, and technical notes
ci/ scripts run by the GitLab CI jobs
Mathematical vignettes
The documentation is organized as a sequence rather than a single large tutorial:
- Gaussian-Process Regression from First Principles — prior, conditioning, exact fitting, and latent versus observation uncertainty.
- Covariance Kernels and Composition — RBF, Matérn, rational quadratic, periodic structure, and kernel algebra.
- Marginal Likelihood, Prediction, and Uncertainty — exact log marginal likelihood, hyperparameter estimation, LOO identities, and universal kriging with estimated or marginalized trend coefficients.
- Numerical Stability in Gaussian-Process Computation — Cholesky solves, jitter, conditioning, and posterior-variance safeguards.
- Multidimensional Gaussian Processes and ARD — scaled distance, vector length scales, interpretation, optimization paths, and additive models built from kernels on subsets of the input columns.
- Gaussian Processes for Time Series — explicit time indexing, structured kernels, interpolation versus extrapolation, rolling-origin evaluation, and structural breaks with changepoint kernels.
- Derivatives of Covariance Kernels — analytical derivatives with respect to log parameters and to the inputs for every kernel and for sums, products, and scaled kernels, kernel smoothness, the posterior gradient of the latent function, and conditioning on observed derivatives.
Research notes under inst/notes/ document the heteroscedastic approximation, FITC approximation, and benchmark protocol separately. The documentation site publishes them alongside the vignettes and worked examples: a time-series workflow and a spectral-mixture kernel on Mauna Loa CO2.
Local development
Install the development dependencies:
install.packages(c(
"testthat",
"roxygen2",
"knitr",
"rmarkdown"
))Suggested packages, which the validation references compare against (their tests are skipped without them):
install.packages(c(
"DiceKriging",
"gplite",
"kernlab",
"nlme"
))Run tests:
testthat::test_local()Build the vignettes:
devtools::build_vignettes()Run package checks:
devtools::check()Build the documentation site locally (requires pkgdown); it is written to public/:
pkgdown::build_site()Continuous integration and releases
GitLab CI runs R CMD check on merge requests, builds the documentation site with pkgdown, and publishes it to GitLab Pages from the default branch at https://gaussian-processes-r-12efed.gitlab.io/. The pipeline is designed to use little compute; see CONTRIBUTING.md for its design and for reproducing every job locally with Docker. Releases are published from a manual pipeline as described in RELEASING.md, and changes are recorded in NEWS.md.
Design principles
- Prefer mathematically explicit implementations over opaque abstractions.
- Avoid explicit matrix inversion in Gaussian-process inference.
- Treat numerical stability as part of the statistical implementation.
- Validate inputs and fail clearly when assumptions are violated.
- Distinguish latent-function uncertainty from observation uncertainty.
- Keep numerical jitter separate from statistical observation noise.
- Keep dependencies minimal.
- Make simulations and benchmarks reproducible.
- Keep exact GP regression as the numerical reference for approximations.
Development status
Every exported function is marked stable or experimental on its help page, and the reference index is grouped by tier:
- Stable: exact regression, kernels, means, sampling, leave-one-out and scores, and the time-series workflow.
- Experimental: the sparse, latent, heteroscedastic, and state-space methods, the newest kernels, hyperparameter uncertainty, and the benchmark helpers.
Stable interfaces change incompatibly only in a major release, and experimental ones may change in a minor release; ?gaussianprocesses sets out the policy. Changes are listed in NEWS.md, released versions are on the GitLab releases page, and bugs and planned work are tracked in the GitLab issue tracker.
Citation
After installing the package, use:
citation("gaussianprocesses")The package-native citation metadata is defined in inst/CITATION.
License
MIT License. See LICENSE.