updateData.tempGP {DSWE}R Documentation

Update the data in a tempGP object


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.)


## S3 method for class 'tempGP'
  newT = NULL,
  replace = TRUE,
  updateModelF = FALSE,



An object of class tempGP.


A matrix with each column corresponding to one input variable.


A vector with each element corresponding to the output at the corresponding row of newX.


A vector with time indices of the new datapoints. If NULL, the function assigns natural numbers starting with one larger than the existing time indices in trainT.


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 m rows from the old data, where m is the number of data points in the new data.


A boolean to specify whether to update modelF as well. If the original tempGP model is trained on a sufficiently large dataset (say one year), updating modelF regularly may not result in any significant improvement, but can be computationally expensive.


additional arguments for future development


An updated object of class tempGP.


   data = DSWE::data1
   trainindex = 1:100 #using the first 100 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)

[Package DSWE version 1.5.1 Index]