I am using the package ROBETS in R to make forecast. I need to re-train my model on a extended time series. Below is the MWE:
library(robets)
ts.train <- ts(c(60,209,51,34,208,64,122,99,82,194,136,177,110,332,300,151,128,206,129,92,164,814,1286,826,893,949,1014,830,877,605,773,870,1610,970,1192,1222,466,1963,841), start=c(20001, 1), frequency=12)
model.robets <- robets(ts.train)
ts.train.dev <- ts(c(60,209,51,34,208,64,122,99,82,194,136,177,110,332,300,151,128,206,129,92,164,814,1286,826,893,949,1014,830,877,605,773,870,1610,970,1192,1222,466,1963,841,830,812,160,238,53,760), start=c(20001, 1), frequency=12)
model.robets.retrain <- robets(ts.train.dev, model=model.robets)
I get the following error:
Error in robetsTargetFunctionInit(par = par, y = y, errortype = errortype, :
k Problem!
An easy solution to your problem is adding the argument use.initial.values = TRUE
. This argument states that the same initial values are used for model.robets
as for model.robets.retrain
. That makes sense, since by default the initial values are estimated in a short startup period, which is the same for both time series.
The solution:
library(robets)
ts.train <- ts(c(60,209,51,34,208,64,122,99,82,194,136,177,110,332,300,151,128,206,129,92,164,814,1286,826,893,949,1014,830,877,605,773,870,1610,970,1192,1222,466,1963,841), start=c(20001, 1), frequency=12)
model.robets <- robets(ts.train)
ts.train.dev <- ts(c(60,209,51,34,208,64,122,99,82,194,136,177,110,332,300,151,128,206,129,92,164,814,1286,826,893,949,1014,830,877,605,773,870,1610,970,1192,1222,466,1963,841,830,812,160,238,53,760), start=c(20001, 1), frequency=12)
model.robets.retrain <- robets(ts.train.dev, model=model.robets, use.initial.values = TRUE)
However, the error you describe should not happen. Therefore I changed the default setting, and I solved the bug you found. A new version of robets
will soon appear on CRAN.