为什么我的时间序列预测出现跳跃?
Why do I see a jump in my time series forecast?
我正在使用 forecast
包中的 auto.arima()
,并且在预测中得到了一些奇怪的结果。
library(forecast)
x <- structure(c(1.92, 2.1, 1.73, 1.35, 1.29, 1.35, 1.42, 1.46, 1.6,
1.67, 1.98, 1.78, 1.77, 2.35, 1.93, 1.43, 1.29, 1.26, 1.93, 2.33,
2.22, 2.19, 2.15, 2.25, 3.12, 3.32, 2.72, 2.28, 2.28, 2.16, 2.81,
3.12, 2.85, 2.98, 3.3, 3.06, 3.56, 3.81, 3.48, 2.64, 2.91, 3.35,
3.73, 3.58, 4, 3.94, 3.79, 3.85), .Tsp = c(2012, 2015.91666666667,
12), class = "ts")
fit <- auto.arima(x)
plot(forecast(fit, 12)) #forecast and actual data
f2 <- fitted.values(fit)
lines(f2, col="red") #add predicted values during training
我不明白拟合值(红线)如何非常接近观察值(黑色),但在第一个预测中有如此大的跳跃。
知道为什么我们会看到这种跳跃吗?我在 Stack Exchange 上看到了其他 posts,其中使用了 xreg
选项,但这并没有这样做,所以我无法找到类似的 post.
一般来说,我倾向于认为 auto.arima
稍微过度拟合数据。使用 ACF 进行的一些快速探索性分析表明 (0,1,2)(0,1,0)[12]
已经是一个不错的模型。我将使用 R 基础中的 arima0
来拟合此模型:
fit0 <- arima0(x, order = c(0,1,2), seasonal = c(0,1,0))
预测/预测是用predict.arima0
:
完成的
pred <- predict(fit0, n.ahead = 12, se.fit = FALSE)
让我们绘制观察到的序列并一起预测:
ts.plot(x, pred, col = 1:2)
还有一个跳跃。但与序列的变异性相比,变异是相当合理的。
没问题。 当我们从 x[1:48]
预测 x[49]
时,它会与 x[48]
不同。通常,(0,1,2)(0,1,0)[12]
具有线性趋势和季节性影响。它有助于按季节可视化您的时间序列和预测季节:
ts.plot(window(x, 2012, 2012 + 11/12),
window(x, 2013, 2013 + 11/12),
window(x, 2014, 2014 + 11/12),
window(x, 2015, 2015 + 11/12),
pred, col = 1:5)
我正在使用 forecast
包中的 auto.arima()
,并且在预测中得到了一些奇怪的结果。
library(forecast)
x <- structure(c(1.92, 2.1, 1.73, 1.35, 1.29, 1.35, 1.42, 1.46, 1.6,
1.67, 1.98, 1.78, 1.77, 2.35, 1.93, 1.43, 1.29, 1.26, 1.93, 2.33,
2.22, 2.19, 2.15, 2.25, 3.12, 3.32, 2.72, 2.28, 2.28, 2.16, 2.81,
3.12, 2.85, 2.98, 3.3, 3.06, 3.56, 3.81, 3.48, 2.64, 2.91, 3.35,
3.73, 3.58, 4, 3.94, 3.79, 3.85), .Tsp = c(2012, 2015.91666666667,
12), class = "ts")
fit <- auto.arima(x)
plot(forecast(fit, 12)) #forecast and actual data
f2 <- fitted.values(fit)
lines(f2, col="red") #add predicted values during training
我不明白拟合值(红线)如何非常接近观察值(黑色),但在第一个预测中有如此大的跳跃。
知道为什么我们会看到这种跳跃吗?我在 Stack Exchange 上看到了其他 posts,其中使用了 xreg
选项,但这并没有这样做,所以我无法找到类似的 post.
一般来说,我倾向于认为 auto.arima
稍微过度拟合数据。使用 ACF 进行的一些快速探索性分析表明 (0,1,2)(0,1,0)[12]
已经是一个不错的模型。我将使用 R 基础中的 arima0
来拟合此模型:
fit0 <- arima0(x, order = c(0,1,2), seasonal = c(0,1,0))
预测/预测是用predict.arima0
:
pred <- predict(fit0, n.ahead = 12, se.fit = FALSE)
让我们绘制观察到的序列并一起预测:
ts.plot(x, pred, col = 1:2)
还有一个跳跃。但与序列的变异性相比,变异是相当合理的。
没问题。 当我们从 x[1:48]
预测 x[49]
时,它会与 x[48]
不同。通常,(0,1,2)(0,1,0)[12]
具有线性趋势和季节性影响。它有助于按季节可视化您的时间序列和预测季节:
ts.plot(window(x, 2012, 2012 + 11/12),
window(x, 2013, 2013 + 11/12),
window(x, 2014, 2014 + 11/12),
window(x, 2015, 2015 + 11/12),
pred, col = 1:5)