Obtains predictions for newdata given a GP model, but sequentially adds each new observation to the training data and refits the model. This simulates a real-time forecasting application.

predict_seq(object, newdata, restart.initpars = F, refit.b = F)

Arguments

object

Output from fitGP.

newdata

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

restart.initpars

Set initpars to pars of the previous model (FALSE, default), or restart with the default initspars each time (TRUE). Starting at the last values can reduce the number of iterations required, saving time, but might trap you in a local minimum.

refit.b

If a "fisheries model", should the b parameter be refit at each iteration? Defaults to FALSE (b fixed to value in original model).

Value

A list (class GP and GPpred) with the same elements as fitGP. The model information will be for the final model including all of the original training data plus newdata. The outsampresults and outsampfitstats will be for the sequentially updated predictions.

Details

In comparison to predict.GP, this prediction method is similar to predictmethod="sequential" (leave-future-out), but in this case, the future time points are not included in the training data. It is also similar to the train/test split using newdata, but in this case, the training data and model are updated with each timestep.

Using this method requires the use of data with pre-generated lags (option A1 in fitGP), that a time column is specified, that newdata has exactly the same columns as data, and that newdata contains observed values.

The original data data frame is obtained from the global environment, so results will be not be accurate if it is changed. Also, if for whatever reason you want to use update on the output of predict_seq, it will probably not work unless you respecify data and initpars.