Learn R Programming

GPFDA (version 1.1)

gpr: Gaussian Process regression for single curve

Description

Gaussian Process regression for single curve with train data.

Usage

gpr(Data, response, Cov=c('linear','pow.ex'), hyper=NULL, NewHyper=NULL, mean=0, gamma=1,
          itermax=100,reltol=8e-10,trace=0)

Arguments

Data
The input data from train data. Matrix or vectors are both acceptable. Some data.frames are not acceptable.
response
The response data from train data. Matrix or vectors are both acceptable. Some data.frames are not acceptable.
Cov
The kernel functions or covariance functions to use. Default is the sum of 'linear' and 'power exponentiation'.
hyper
The hyper parameters. Default is NULL. If not NULL, then must be a list with certain names.
NewHyper
Vector of the names of the new hyper parameters from customized kernel function. The names of the hyper-parameters must have the format: xxxxxx.x, i.e. '6 digit' plus 'a dot' plus '1 digit'. This is required for both 'hyper' and 'NewHyper'
mean
Is the mean taken out when analysis? Default to be 0, which assumes the mean is zero. if assume mean is a constant, mean=1; if assume mean is a linear trend, mean='t'.
gamma
Power parameter used in powered exponential kernel function.
itermax
Number of maximum iteration in optimization function. Default to be 100. Normally the number of optimization steps is around 20. If reduce 'reltol', the iterations needed will be less.
reltol
Relative convergence tolerance. Smaller reltol means more accurate and slower to converge.
trace
The value of the objective function and the parameters is printed every trace'th iteration. Defaults to 0 which indicates no trace information is to be printed.

Value

  • CovFunCovariance function type
  • fittedFitted value of training data
  • fitted.sdStandard deviation of the fitted value of training data
  • gammaParameter used in powered exponential covariance function
  • hyperHyper-parameter estimated from training data
  • IVariance of the estimated hyper-parameters
  • train.xTraining covariates
  • train.yTraining response
  • QCovariance matrix
  • invInverse of the covariance matrix
  • meanThe mean assumed in the analysis
  • lrm'lm' object if mean is a linear regression. NULL otherwise.
  • conv0 means converge; 1 otherwise.
  • hyper0starting point of the hyper-parameters

Details

The most important function in the package, for fitting the GP model and store everything necessary for prediction. The optimization used in the function is 'nlminb'. Optimization might break down if the noise for the curve are too far away from normal. Jitter, LU decomposition and sparse matrix inverse are used to ensure the matrix inverse can always get an answer.

The names for the hyper parameters should be:"linear.a" for linear covariance function, "pow.ex.w", "pow.ex.v" for power exponential, "rat.qu.s", "rat.qu.a" for rational quadratic, "vv" for white noise. All hyper parameters should be in one list.

References

Shi, J Q., and Choi, T. (2011), Gaussian Process Regression Analysis for Functional Data, Springer, New York.

See Also

gppredict; cov.linear; cov.pow.ex; cov.rat.qu; gpfr

Examples

Run this code
library(GPFDA)
library(MASS) ## used to generate data
hp <- list('pow.ex.w'=log(10),'linear.a'=log(10),'pow.ex.v'=log(5),'vv'=log(1))
c <- seq(0,1,len=40)
idx <- sort(sample(1:40,21))
X <- as.matrix(c[idx])
Y <- (mvrnorm(n=40,mu=c-c,Sigma=(cov.linear(hp,c)+cov.pow.ex(hp,c)))[,1])*0.1+sin(c*6)
Y <- as.matrix(Y[idx])
x <- as.matrix(seq(0,1,by=0.03))
a <- gpr(X,Y,c('linear','pow.ex'))

## NOT RUN
## Further codes to provide preditions and plot can be found in demos, for example
## > demo('gpr_ex1')
## END

Run the code above in your browser using DataLab