Forecast package Prediction Horizon issue in R

Kal

I am new to R. I was trying to predict using holt method but getting this strange error. I am using forecast package V-7.1 with R (version 3.2.5) and Rstudio (Version 0.99.896). I reinstall all from R to Rstudio but did not work. Only h from 1 to 10 works. Any idea??

  library(forecast)
  library(stats)
  library(base)
  x=data$cost
  k<-holt(x,damped=TRUE)
  m=forecast(k,h=20)

  Error in forecast.forecast(k, h = 20) : 
  Please select a longer horizon when the forecasts are first computed

Other testing cases:

 m=forecast(k,h=2000)
 Error in forecast.forecast(k, h = 2000) : 
 Please select a longer horizon when the forecasts are first computed

 m=forecast(k,h=10)
 m=forecast(k,h=11)
 Error in forecast.forecast(k, h = 11) : 
 Please select a longer horizon when the forecasts are first computed

 m=forecast(k,h=100)
 Error in forecast.forecast(k, h = 100) : 
 Please select a longer horizon when the forecasts are first computed
Stephan Kolassa

You need to specify the h parameter in the call to holt(), not in the call to forecast().

holt() fits a model and computes the forecast. This is in contrast to "typical" R usage and other forecasting-related functions, like ets(), arima() etc. So you don't even need to call forecast() on the output of holt():

> print(holt(airmiles,h=15))
     Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
1961       32772.01 31455.62 34088.39 30758.77 34785.24
1962       34877.47 32594.37 37160.56 31385.77 38369.16
1963       36982.93 33767.27 40198.59 32065.00 41900.85
1964       39088.39 34912.84 43263.94 32702.44 45474.34
1965       41193.85 36015.50 46372.21 33274.24 49113.47
1966       43299.31 37070.39 49528.24 33773.00 52825.63
1967       45404.78 38076.33 52733.23 34196.88 56612.67
1968       47510.24 39033.57 55986.91 34546.29 60474.19
1969       49615.70 39942.98 59288.42 34822.56 64408.84
1970       51721.16 40805.71 62636.62 35027.41 68414.91
1971       53826.62 41622.95 66030.30 35162.71 72490.53
1972       55932.09 42395.93 69468.25 35230.32 76633.86
1973       58037.55 43125.82 72949.27 35232.03 80843.06
1974       60143.01 43813.77 76472.25 35169.60 85116.42
1975       62248.47 44460.85 80036.09 35044.65 89452.29

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

R中的预测包Prediction Horizon问题

来自分类Dev

在 Ubuntu 17.10 上升级 CUDA-9.1 后,在 Forecast Package 安装过程中出现 R 错误

来自分类Dev

在R中使用Forecast()时获取预测值

来自分类Dev

R的预测包中的Forecast()中使用哪种预测模型?

来自分类Dev

在R中使用Forecast()时获取预测值

来自分类Dev

当在Forecast()和ar()中传递参数时,R中的预测误差

来自分类Dev

R中的Forecast()函数的默认训练和测试集大小是多少?

来自分类Dev

R中的预测包中的Forecast()中使用了哪种预测模型?

来自分类Dev

Horizon无法启动

来自分类Dev

R tm package and cyrillic text

来自分类Dev

Unable to install cachem package for R

来自分类Dev

OpenStack Horizon无法找到令牌

来自分类Dev

Excel 中 FORECAST 和 FORECAST.LINEAR 的区别

来自分类Dev

C#和Forecast API

来自分类Dev

Openweathermap API Forecast 访问数组

来自分类Dev

R-Package“闪亮”。如何退出程序?

来自分类Dev

Unable to install XML package in R on CentOS

来自分类Dev

R-package的添加和编辑功能

来自分类Dev

package.R 無法解決

来自分类Dev

在Horizon集合中增加价值

来自分类Dev

无法浏览Horizon“ OpenStack-dashboard”

来自分类Dev

Horizon:import_module上的Apache异常

来自分类Dev

Horizon:import_module上的Apache异常

来自分类Dev

无法浏览Horizon“ OpenStack-dashboard”

来自分类Dev

如何安装Horizon仪表板?

来自分类Dev

在Horizon集合中增加价值

来自分类Dev

Laravel Horizon 工作没有出现

来自分类Dev

卸载 VMware Horizon 客户端问题

来自分类Dev

Weka Prediction with Java