R 中的预测包 Prediction Horizon 问题
Forecast package Prediction Horizon issue in R
我是 R 的新手。我试图使用 holt 方法进行预测,但遇到了这个奇怪的错误。我正在使用带有 R(版本 3.2.5)和 Rstudio(版本 0.99.896)的预测包 V-7.1。我将所有内容从 R 重新安装到 Rstudio,但没有用。只有 h 从 1 到 10 有效。有什么想法吗??
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
其他测试用例:
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
您需要在调用 holt()
时指定 h
参数,而不是调用 forecast()
.
holt()
拟合模型 并且 计算预测。这与 "typical" R 用法和其他与预测相关的函数(如 ets()
、arima()
等)形成对比。因此您甚至不需要在输出上调用 forecast()
共 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
我是 R 的新手。我试图使用 holt 方法进行预测,但遇到了这个奇怪的错误。我正在使用带有 R(版本 3.2.5)和 Rstudio(版本 0.99.896)的预测包 V-7.1。我将所有内容从 R 重新安装到 Rstudio,但没有用。只有 h 从 1 到 10 有效。有什么想法吗??
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
其他测试用例:
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
您需要在调用 holt()
时指定 h
参数,而不是调用 forecast()
.
holt()
拟合模型 并且 计算预测。这与 "typical" R 用法和其他与预测相关的函数(如 ets()
、arima()
等)形成对比。因此您甚至不需要在输出上调用 forecast()
共 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