updateData.tempGP {DSWE} | R Documentation |
Update the data in a tempGP object
Description
This function updates trainX
, trainY
, and trainT
in a tempGP
object. By default, if the new data has m
data points, the function removes top m
data points from the tempGP object and appends the new data at the bottom, thus keeping the total number of data points the same. This can be overwritten by setting replace = FALSE
to keep all the data points (old and new). The method also updates modelG
by computing and updating residuals at the new data points. modelF
can be also be updated by setting the argument updateModelF
to TRUE
, though not required generally (see comments in the Arguments
.)
Usage
## S3 method for class 'tempGP'
updateData(
object,
newX,
newY,
newT = NULL,
replace = TRUE,
updateModelF = FALSE,
...
)
Arguments
object |
An object of class tempGP. |
newX |
A matrix with each column corresponding to one input variable. |
newY |
A vector with each element corresponding to the output at the corresponding row of |
newT |
A vector with time indices of the new datapoints. If |
replace |
A boolean to specify whether to replace the old data with the new one, or to add the new data while still keeping all the old data. Default is TRUE, which replaces the top |
updateModelF |
A boolean to specify whether to update |
... |
additional arguments for future development |
Value
An updated object of class tempGP
.
Examples
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)
newdata = DSWE::data1[101:110,] # defining new data
newX = as.matrix(newdata[,xCol, drop = FALSE])
newY = as.numeric(newdata[,yCol])
tempGPupdated = updateData(tempGPObject, newX, newY)