Learn R Programming

spectralGP (version 1.3.3)

gp: Create a new GP object

Description

Creates a Gaussian process (GP) object based on the spectral basis approximation of a GP on a grid. The advantage of this approach is that GPs can be simulated and sampled much more efficiently than standard GP representations. E.g., GPs can be simulated on fine grids of 256X256 locations, many more locations than can usually be predicted with standard computational approaches. Currently one and two dimensional GPs are supported.

Usage

gp(gridsize = c(64, 64), specdens = matern.specdens, specdens.param = c(1, 4),variance.param=1,const.fixed=FALSE)

Arguments

gridsize
Vector (or scalar for one dimension) of number of gridpoints in each direction. Number of gridpoints should be a power of two, and it is recommended that the number be the same for each dimension.
specdens
Function (as a function or text string of the function name) that calculates spectral density of correlation function desired; function should take a vector (scalar) of parameter values. See matern.specdens() for an example.
specdens.param
Vector of parameters to be supplied to the specdens.function function.
variance.param
Variance parameter used to scale the variances of all the coefficients. Note that this can also be done outside of the GP framework by scaling the predictions as in Wikle (2002).
const.fixed
Logical indicating whether the coefficient of the constant basis function is fixed at zero. Since this coefficient does not have sufficient flexibility under the prior in most situations, it is advisable to fix this coefficient and have a separate mean value/parameter outside of the gp object. However, in simulating realizations, one should not fix this parameter, so as to ensure the correct approximate covariance structure induced by the spectral density and parameter values chosen.

Value

An object of class gp. This includes the dimension of the space, the spectral density information, a matrix of coefficients, the Fourier frequencies, and prior variances.
gridsize
Vector (or scalar for one dimension) of number of gridpoints in each direction.
d
Dimension of the space (1 or 2).
specdens
Spectral density function of the correlation function of the GP.
coeff
Matrix of coefficient values (a one-column matrix for one-dimensional processes).
omega
A matrix of Fourier frequency values corresponding the basis functions in expand.grid() format.
variances
A matrix of coefficient variances.

Details

This function produces an object of class gp. More details on the spectral representation of GPs can be found in Paciorek (2006); see below.

References

Type 'citation("spectralGP")' for references.

See Also

simulate.gp, plot.gp, propose.coeff.gp, calc.variances.gp, new.mapping, logdensity.gp, predict.gp, add.blocks.gp

Examples

Run this code
library(spectralGP)
gp1=gp(128,matern.specdens,c(1,4))
gp2=gp(c(64,64),matern.specdens,c(1,4))
simulate(gp1)
simulate(gp2)
plot(gp1)
plot(gp2)

n=100
locs=cbind(runif(n,0.2,1.2),runif(n,-0.2,1.4))
locs.predict=cbind(runif(n,-0.4,0.8),runif(n,-0.1,1.7))
scaled.locs=xy2unit(locs,rbind(locs,locs.predict))
scaled.locs.predict=xy2unit(locs.predict,rbind(locs,locs.predict))
train.map=new.mapping(gp2,scaled.locs)
predict.map=new.mapping(gp2,scaled.locs.predict)
vals.train=predict(gp2,mapping=train.map)
vals.predict=predict(gp2,mapping=predict.map)

Run the code above in your browser using DataLab