Obtain predictions from a fitted GP model. There are several options:

  1. (Default) Use predictmethod="loo" for leave-one-out prediction using the training data.

  2. Use predictmethod="lto" for leave-timepoint-out prediction using the training data. This will leave out values with the same time index across multiple populations, rather than each individual datapoint. If there is only one population, "lto" will be equivalent to "loo".

  3. Use predictmethod="sequential" for sequential (leave-future-out) prediction using the training data.

  4. If data frame data was supplied, supply data frame newdata containing same column names. Column for y is optional, unless E and tau were supplied in lieu of x.

  5. If vectors/matrices were supplied for y, x, etc, equivalent vector/matrices xnew, popnew (if pop was supplied), and timenew (optional). ynew is optional, unless E and tau were supplied in lieu of x.

It should be noted that "loo" is not a "true" leave-one-out, for although each prediction is made by removing one of the training points, the hyperparameters are fit using all of the training data. The same goes for "sequential" and "lto".

# S3 method for class 'GP'
predict(
  object,
  predictmethod = c("loo", "lto", "sequential"),
  newdata = NULL,
  xnew = NULL,
  popnew = NULL,
  timenew = NULL,
  ynew = NULL,
  returnGPgrad = FALSE,
  exclradius = 0,
  ...
)

Arguments

object

Output from fitGP.

predictmethod

Using the training data, loo does leave-one-out prediction, lto does leave-timepoint-out prediction, and sequential does sequential (leave-future-out) prediction.

newdata

Data frame containing the same columns supplied in the original model.

xnew

New predictor matrix or vector. Not required if newdata is supplied.

popnew

New population vector. Not required if newdata is supplied.

timenew

New time vector. Not required if newdata is supplied.

ynew

New response vector. Optional, unless E and tau were supplied in lieu of x. Not required if newdata is supplied.

returnGPgrad

Return the gradient (derivative) of the GP model at each time point with respect to each input. This is only computed for out-of-sample predictions using newdata, loo, or lto. If you want the in-sample gradient, pass the original dataset as newdata. Defaults to FALSE.

exclradius

For predictmethod="loo" and predictmethod="lto", the number of points on either side of the focal point to leave out of the training data. Defaults to 0.

...

Other args (not used).

Value

A list (class GPpred) with the following elements:

outsampresults

Data frame with out-of-sample predictions (if requested). predfsd is the standard deviation of the GP function, predsd includes process error.

outsampfitstats

Fit statistics for out-of-sample predictions. Only computed if using a predictmethod, if y is found in newdata, or if ynew supplied (i.e. if the observed values are known).

outsampfitstatspop

If >1 population, fit statistics for out-of-sample predictions by population.

GPgrad

If returnGPgrad=T, a data frame with the partial derivatives of the function with respect to each input.