Title: | Efficiently Using Gaussian Processes with Rcpp and RcppEigen |
---|---|
Description: | Contains Rcpp and RcppEigen implementations of matrix operations useful for Gaussian process models, such as the inversion of a symmetric 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). |
Authors: | Giri Gopalan, Luke Bornn |
Maintainer: | Giri Gopalan <[email protected]> |
License: | GPL-2 |
Version: | 1.2 |
Built: | 2024-11-26 03:51:07 UTC |
Source: | https://github.com/cran/FastGP |
This function uses elliptical slice sampling to sample from a Bayesian model in which the prior is multivariate normal (JMLR Murray, Adams, and MacKay 2010)
ess(log.lik,Y, Sig, N_mcmc,burn_in,N,flag)
ess(log.lik,Y, Sig, N_mcmc,burn_in,N,flag)
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 (which may be more stable but slow), FALSE for FastGP implementation of rcpp_rmvnorm (which is faster but less stable) |
Giri Gopalan [email protected]
# See demo/FastGPdemo.r.
# See demo/FastGPdemo.r.
Performs useful matrix operations using Rcpp and RcppEigen.
rcppeigen_invert_matrix(A) rcppeigen_get_det(A) rcppeigen_get_chol(A) rcppeigen_get_chol_stable(A) rcppeigen_get_chol_diag(A) tinv(A)
rcppeigen_invert_matrix(A) rcppeigen_get_det(A) rcppeigen_get_chol(A) rcppeigen_get_chol_stable(A) rcppeigen_get_chol_diag(A) tinv(A)
A |
Matrix to perform operation on. |
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. Thanks to Jared Knowles who pointed out that the former variant is more stable (with a potential speed trade-off) and has found it useful for his package merTools. tinv
inverts a symmetric Toeplitz matrix using methods from Trench and Durbin from "Matrix Computations" by Golub and Van Loan using Rcpp.
# See demo/FastGPdemo.R
# See demo/FastGPdemo.R
These functions allow for the sampling of and evaluation of the log-density of a multivariate normal vector.
rcpp_log_dmvnorm(S,mu,x, istoep) rcpp_rmvnorm(n,S,mu) rcpp_rmvnorm_stable(n,S,mu)
rcpp_log_dmvnorm(S,mu,x, istoep) rcpp_rmvnorm(n,S,mu) rcpp_rmvnorm_stable(n,S,mu)
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 |
Giri Gopalan [email protected]
#See demo/FastGPdemo.R
#See demo/FastGPdemo.R