Package {FastGP}


Type: Package
Title: Efficiently Using Gaussian Processes with Rcpp and RcppEigen
Version: 1.4
Date: 2026-09-19
Maintainer: Giri Gopalan <gopalan88@gmail.com>
Description: Contains Rcpp and RcppEigen implementations of matrix operations useful for Gaussian process models, such as the inverse and determinant of a symmetric and positive-definite Toeplitz matrix, sampling from multivariate normal distributions, evaluation of the log-density of a multivariate normal vector, and Bayesian inference for latent variable Gaussian process models with elliptical slice sampling (Murray, Adams, and MacKay 2010).
License: GPL-2
Imports: Rcpp, MASS, mvtnorm, stats
LinkingTo: Rcpp, RcppEigen
Repository: CRAN
NeedsCompilation: yes
RoxygenNote: 7.3.1
Author: Giri Gopalan [aut, cre], Luke Bornn [aut]
Packaged: 2026-09-20 01:49:15 UTC; ggopalan
Date/Publication: 2026-09-20 03:10:10 UTC

Posterior Sampling Using Elliptical Slice Sampling

Description

The ess function uses elliptical slice sampling to sample from the posterior distribution within a Bayesian model in which the prior is a Gaussian process/multivariate normal. If the covariance matrix corresponding to the prior is also Toeplitz, use ess_Toep for a faster version.

Elliptical slice sampling is a valid Markov chain Monte Carlo algorithm for posterior sampling when the prior is a Gaussian process/multivariate normal.

Murray, I., Adams, R., & MacKay, D. (2010, March). Elliptical slice sampling. In Proceedings of the thirteenth international conference on artificial intelligence and statistics (pp. 541-548). JMLR Workshop and Conference Proceedings.

Usage

ess(log.lik,Y, Sig, N_mcmc,burn_in,N,flag)
ess_Toep(log.lik,Y, Sig, N_mcmc,burn_in,N)

Arguments

log.lik

Log-lik function in model which is assumed to take two arguments: the first contains the parameters/latent variables and the second the observed data Y.

Y

Observed data.

Sig

Covariance matrix associated with the prior distribution on the parameters/latent variable vector.

N_mcmc

Number of desired mcmc samples.

burn_in

Number of burn-in iterations.

N

Dimensionality of parameter/latent variable vector.

flag

Set to TRUE for MASS implementation of mvrnorm, FALSE for FastGP implementation of rcpp_rmvnorm.

Author(s)

Giri Gopalan gopalan88@gmail.com

Examples

# See demo/FastGPdemo.r.

Matrix Operations Using Rcpp and RcppEigen

Description

Performs useful matrix operations using Rcpp and RcppEigen, and some custom C++ to handle symmetric, positive definite, Toeplitz matrices.

Usage

rcppeigen_invert_matrix(A)
rcppeigen_get_det(A)
rcppeigen_get_chol(A)
rcppeigen_get_chol_stable(A)
rcppeigen_get_chol_diag(A)
tinv(A)
tdet(A)

Arguments

A

Matrix to perform operation on.

Details

Functions with "rcppeigen" directly call RcppEigen implementations of the associated functions; rcppeigen_get_chol_stable retrieves L and rcppeigen_get_chol_diag(A) retrieves D in A = LDL^T form, whereas rcppeigen_get_chol(A) retrieves L in A = LL^T form. The function tinv computes an inverse and tdet returns the log-determinant of a symmetric, positive-definite, Toeplitz matrix using methods from Trench and Durbin from "Matrix Computations" by Golub and Van Loan.

Author(s)

gopalan88@gmail.com

Examples

# See demo/FastGPdemo.R

Multivariate Normal Sampling and Log-Density Evaluation

Description

These functions allow for the sampling of and evaluation of the log-density of a multivariate normal vector.

Usage

rcpp_log_dmvnorm(S,mu,x, istoep)
rcpp_rmvnorm(n,S,mu)
rcpp_rmvnorm_Toep(n,S,mu)
rcpp_rmvnorm_stable(n,S,mu)

Arguments

S

Covariance matrix of associated multivariate normal.

n

Number of (independent) samples to generate.

mu

Mean vector.

x

Vector of observations to evaluate the log-density of.

istoep

set this to TRUE if S is Toeplitz.

Author(s)

Giri Gopalan gopalan88@gmail.com

Examples

#See demo/FastGPdemo.R