Learn R Programming

DSWE (version 1.8.2)

predict.tempGP: predict from temporal Gaussian process

Description

predict function for tempGP objects. This function computes the prediction f(x) or f(x) + g(t) depending on the temporal distance between training and test points and whether the time indices for the test points are provided.

Usage

# S3 method for tempGP
predict(object, testX, testT = NULL, trainT = NULL, ...)

Value

A vector of predictions at the testpoints in testX.

Arguments

object

An object of class tempGP.

testX

A matrix with each column corresponding to one input variable.

testT

A vector of time indices of the test points. When NULL, only function f(x) is used for prediction. Default is NULL.

trainT

Optional argument to override the existing trainT indices of the tempGP object.

...

additional arguments for future development

Examples

Run this code
   data = DSWE::data1
   trainindex = 1:50 #using the first 50 data points to train the model
   traindata = data[trainindex,]
   xCol = 2 #input variable columns
   yCol = 7 #response column
   trainX = as.matrix(traindata[,xCol])
   trainY = as.numeric(traindata[,yCol])
   tempGPObject = tempGP(trainX, trainY)
   testdata = DSWE::data1[101:110,] # defining test data 
   testX = as.matrix(testdata[,xCol, drop = FALSE])
   predF = predict(tempGPObject, testX)

Run the code above in your browser using DataLab