模型不是从 R 中的 ARFIMA 生成的

Model is not generated from ARFIMA in R

我想用卡尔曼滤波器预测 ARFIMA,但无法将 arfima 模型拟合到卡尔曼预测中。

 library(base)
 library(stats)
 library(parallel)
 library(forecast)
 sink(file='/home/nero/KF_arfima.log')
 f=COST$COST
 x=logb(p,10)
 # Start the clock!
 ptm <- proc.time()
 p=arfima(x[1:50], drange=c(0, 0.5),estim=c("mle"))
 pr <- KalmanForecast(2, p$model)
 y=x[51:52] 
 yhat=pr$pred #predicted value
 map=mean(abs((y - yhat)/y)) #MAPE
 proc.time() - ptm
 print(map)

我遇到了错误

Error in KalmanForecast(2, p$model) : invalid argument type"

我也查了一下,也没有叫model的对象。我浪费了三天时间来解决它。我尝试了各种 R 包,但 none 已经解决了它。请让我知道如何解决它。

数据样本:

Timestamp,COST
2015-09-21T00:00:00+00:00,6
2015-09-21T00:06:00+00:00,7
2015-09-21T00:12:00+00:00,7
2015-09-21T00:18:00+00:00,7
2015-09-21T00:24:00+00:00,7
2015-09-21T00:30:00+00:00,7
2015-09-21T00:36:00+00:00,7
2015-09-21T00:42:00+00:00,6
2015-09-21T00:48:00+00:00,7
2015-09-21T00:54:00+00:00,6
2015-09-21T01:00:00+00:00,6
2015-09-21T01:06:00+00:00,7
2015-09-21T01:12:00+00:00,7
2015-09-21T01:18:00+00:00,7
2015-09-21T01:24:00+00:00,7
2015-09-21T01:30:00+00:00,7
2015-09-21T01:36:00+00:00,7
2015-09-21T01:42:00+00:00,6
2015-09-21T01:48:00+00:00,7
2015-09-21T01:54:00+00:00,6
2015-09-21T02:00:00+00:00,6
2015-09-21T02:06:00+00:00,8
2015-09-21T02:12:00+00:00,8
2015-09-21T02:18:00+00:00,7
2015-09-21T02:24:00+00:00,8
2015-09-21T02:30:00+00:00,7
2015-09-21T02:36:00+00:00,7
2015-09-21T02:42:00+00:00,7
2015-09-21T02:48:00+00:00,8
2015-09-21T02:54:00+00:00,7
2015-09-21T03:00:00+00:00,6
2015-09-21T03:06:00+00:00,7
2015-09-21T03:12:00+00:00,7
2015-09-21T03:18:00+00:00,7
2015-09-21T03:24:00+00:00,7
2015-09-21T03:30:00+00:00,7
2015-09-21T03:36:00+00:00,7
2015-09-21T03:42:00+00:00,7
2015-09-21T03:48:00+00:00,6
2015-09-21T03:54:00+00:00,6
2015-09-21T04:00:00+00:00,6
2015-09-21T04:06:00+00:00,7
2015-09-21T04:12:00+00:00,7
2015-09-21T04:18:00+00:00,7
2015-09-21T04:24:00+00:00,7
2015-09-21T04:30:00+00:00,6
2015-09-21T04:36:00+00:00,6
2015-09-21T04:42:00+00:00,6
2015-09-21T04:48:00+00:00,6
2015-09-21T04:54:00+00:00,7
2015-09-21T05:00:00+00:00,6
2015-09-21T05:06:00+00:00,7
2015-09-21T05:12:00+00:00,7

KalmanForecast的帮助文件清楚地描述了需要什么样的模型。 arfima 函数未生成所需类型的输出。

除了使用 KalmanForecast,您还可以使用 forecast 包中的 forecast 函数来生成预测。它还使用卡尔曼滤波器来计算预测。

如果你真的想使用 KalmanForecast 来完成这项工作,你将不得不自己弄清楚如何创建 mod 参数。