我正在使用R中的ROBETS包进行预测。我需要在延长的时间序列中重新训练我的模型。以下是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)
我收到以下错误:
Error in robetsTargetFunctionInit(par = par, y = y, errortype = errortype, :
k Problem!
答案 0 :(得分:1)
解决问题的一个简单方法是添加参数use.initial.values = TRUE
。该参数指出model.robets
与model.robets.retrain
使用相同的初始值。这是有道理的,因为默认情况下,初始值是在短启动周期内估算的,两个时间序列都是相同的。
解决方案:
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)
但是,您描述的错误不应该发生。因此我更改了默认设置,并解决了您找到的错误。新版robets
即将出现在CRAN上。