gpr: Gaussian process regression (GPR) model

Description Usage Arguments Details Value References Examples

View source: R/gp.functions6.R

Description

Gaussian process regression for a single or multiple independent realisations.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
gpr(
  response,
  input,
  Cov = "pow.ex",
  m = NULL,
  hyper = NULL,
  NewHyper = NULL,
  meanModel = 0,
  mu = NULL,
  gamma = 2,
  nu = 1.5,
  useGradient = T,
  iter.max = 100,
  rel.tol = 8e-10,
  trace = 0,
  nInitCandidates = 1000
)

Arguments

response

Response data. It should be a matrix, where each column is a realisation. It can be a vector if there is only one realisation.

input

Input covariates. It must be either a matrix, where each column represents a covariate, or a vector if there is only one covariate.

Cov

Covariance function(s) to use. Options are: 'linear', 'pow.ex', 'rat.qu', and 'matern'. Default to 'power.ex'.

m

If Subset of Data is to be used, m denotes the subset size and cannot be larger than the total sample size. Default to NULL.

hyper

The hyperparameters. Default to NULL. If not NULL, then it must be a list with appropriate names.

NewHyper

Vector of names of the new hyperparameters of the customized kernel function. These names must have the format: xxxxxx.x, i.e. '6 digit' followed by 'a dot' followed by '1 digit'. This is required for both 'hyper' and 'NewHyper'

meanModel

Type of mean function. It can be

0

Zero mean function

1

Constant mean function to be estimated

't'

Linear model for the mean function

'avg'

The average across replications is used as the mean function. This is only used if there are more than two realisations observed at the same input coordinate values.

Default to 0. If argument 'mu' is specified, then 'meanModel' will be set to 'userDefined'.

mu

Mean function specified by the user. It must be a vector. Its length must be the same as the sample size, that is, nrow(response).

gamma

Power parameter used in powered exponential kernel function. It must be 0<gamma<=2.

nu

Smoothness parameter of the Matern class. It must be a positive value.

useGradient

Logical. If TRUE, first derivatives will be used in the optimization.

iter.max

Maximum number of iterations allowed. Default to 100. If 'rel.tol' is reduced, then the number of iterations needed will be less.

rel.tol

Relative convergence tolerance. Default to 8e-10. Smaller rel.tol means higher accuracy and more time 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.

nInitCandidates

Number of initial hyperparameter vectors. The optimization starts with the best.

Details

The most important function of the package. It fits the GPR model and stores everything necessary for prediction. The optimization used in the function is 'nlminb'. The names for the hyperparameters 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, "matern.w", "matern.v" for Matern, "vv" for variance of Gaussian white noise. All hyperparameters should be in one list.

Value

A list containing:

hyper

Hyperparameters vector estimated from training data

var.hyper

Variance of the estimated hyperparameters

fitted.mean

Fitted values for the training data

fitted.sd

Standard deviation of the fitted values for the training data

train.x

Training covariates

train.y

Training response

train.yOri

Original training response

train.DataOri

Original training covariates

idxSubset

Index vector identifying which observations were selected if Subset of Data was used.

CovFun

Covariance function type

gamma

Parameter used in powered exponential covariance function

nu

Parameter used in Matern covariance function

Q

Covariance matrix

mean

Mean function

meanModel

Mean model used

meanLinearModel

'lm' object if mean is a linear regression. NULL otherwise.

conv

An integer. 0 means converge; 1 otherwise.

hyper0

Starting point of the hyperparameters vector.

References

Shi, J. Q., and Choi, T. (2011), “Gaussian Process Regression Analysis for Functional Data”, CRC Press.

Examples

1
2
3
4
5
## See examples in vignettes:

# vignette("gpr_ex1", package = "GPFDA")
# vignette("gpr_ex2", package = "GPFDA")
# vignette("co2", package = "GPFDA")

Example output

Loading required package: fda.usc
Loading required package: fda
Loading required package: splines
Loading required package: Matrix
Loading required package: fds
Loading required package: rainbow
Loading required package: MASS
Loading required package: pcaPP
Loading required package: RCurl

Attaching package:fdaThe following object is masked frompackage:graphics:

    matplot

Loading required package: mgcv
Loading required package: nlme
This is mgcv 1.8-33. For overview type 'help("mgcv-package")'.
----------------------------------------------------------------------------------
 Functional Data Analysis and Utilities for Statistical Computing
 fda.usc version 2.0.2 (built on 2020-02-17) is now loaded
 fda.usc is running sequentially usign foreach package
 Please, execute ops.fda.usc() once to run in local parallel mode
 Deprecated functions: min.basis, min.np, anova.hetero, anova.onefactor, anova.RPm
 New functions: optim.basis, optim.np, fanova.hetero, fanova.onefactor, fanova.RPm
----------------------------------------------------------------------------------

Loading required package: spam
Loading required package: dotCall64
Loading required package: grid
Spam version 2.5-1 (2019-12-12) is loaded.
Type 'help( Spam)' or 'demo( spam)' for a short introduction 
and overview of this package.
Help for individual functions is also obtained by adding the
suffix '.spam' to the function name, e.g. 'help( chol.spam)'.

Attaching package:spamThe following object is masked frompackage:Matrix:

    det

The following objects are masked frompackage:base:

    backsolve, forwardsolve

GPFDA documentation built on Jan. 29, 2021, 5:14 p.m.