我需要为正在尝试执行的预测获得80%和95%的置信度,并且简单的移动平均函数除了提供95%的置信度外,不提供任何其他功能。 有没有办法解决此问题或采取任何其他变通方法来获得80%的置信度?
这是示例代码,您会注意到下限(上限)的输出80%和下限(上限)的输出95%完全相同。
library(smooth)
library(forecast)
iris
x1 = sma(iris$Sepal.Length, level = .80)
x2 = sma(iris$Sepal.Length, level = .95)
forecast(x1)
forecast(x2)
> forecast(x1)
Time Series:
Start = 151
End = 160
Frequency = 1
Point forecast Lower bound (2.5%) Upper bound (97.5%)
151 6.320000 5.153756 7.486244
152 6.244000 5.054660 7.433340
153 6.232800 5.010969 7.454631
154 6.179360 4.912203 7.446517
155 6.175232 4.845518 7.504946
156 6.230278 4.815333 7.645224
157 6.212334 4.755426 7.669243
158 6.206001 4.702861 7.709141
159 6.200641 4.648248 7.753034
160 6.204897 4.602211 7.807583
> forecast(x2)
Time Series:
Start = 151
End = 160
Frequency = 1
Point forecast Lower bound (2.5%) Upper bound (97.5%)
151 6.320000 5.153756 7.486244
152 6.244000 5.054660 7.433340
153 6.232800 5.010969 7.454631
154 6.179360 4.912203 7.446517
155 6.175232 4.845518 7.504946
156 6.230278 4.815333 7.645224
157 6.212334 4.755426 7.669243
158 6.206001 4.702861 7.709141
159 6.200641 4.648248 7.753034
160 6.204897 4.602211 7.807583
答案 0 :(得分:0)
您有两种选择方式来查找预测间隔。在第一个sma
模型中,没有指定期望的水平或预测范围。然后可以使用软件包forecast
中的函数smooth
:
x1 <- sma(iris$Sepal.Length)
x2 <- sma(iris$Sepal.Length)
smooth::forecast(x1, level = 0.80, h=12) # no need to used forecast package
smooth::forecast(x2, level = 0.95, h=12)
第二个选项是在sma
调用中指定预测属性:
x1 <- sma(iris$Sepal.Length, level = 0.80, h=12, intervals="parametric")
预测数据存储在变量x1中
x1$forecast
x1$lower
x1$upper