Learn R Programming

spectralGP (version 1.3.3)

predict.gp: Prediction from a spectral GP object

Description

Produces the process values of a spectral GP object on the defined grid or predicts process values for a new set of inputs (domain points).

Usage

"predict"(object,newdata=NULL,mapping=NULL,...)

Arguments

object
A GP object, created by gp.
newdata
An optional two-column matrix-like object (vector for one-dimensional data) of locations of interest, for which the first column is the first coordinate and the second column the second coordinate. Locations should lie in $(0,1)^d$, as the process representation is on a grid on $(0,1)^d$.
mapping
Optional output of new.mapping, which creates a vector of indices mapping the prediction locations to their nearest gridpoints.
...
Other arguments.

Value

A vector of process values (matrix for two-dimensional processes in which prediction on the grid is requested).

Details

Does prediction for a spectral GP, either at the gridpoints or for locations by associating locations with the nearest gridpoint, depending on the arguments supplied. If newdata and mapping are both NULL, then prediction is done on the grid. If only newdata is supplied, the mapping is done using new.mapping and then the prediction is done. If mapping is supplied (this should be done for computational efficiency if prediction at the same locations will be done repeatedly) then the mapping is used directly to calculate the predictions.

References

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

See Also

gp, new.mapping, plot.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)
gridvals=predict(gp1)
gridvals2=predict(gp2)

loc1=runif(100)
loc2=cbind(runif(100),runif(100,0,1))
map1=new.mapping(gp1,loc1)
map2=new.mapping(gp2,loc2)
vals1=predict(gp1,mapping=map1)
vals2=predict(gp2,mapping=map2)
#equivalently:
vals1=predict(gp1,loc1)
vals2=predict(gp2,loc2)
plot(gp1)
points(loc1,vals1)

Run the code above in your browser using DataLab