Forecast :: ets,auto.arima偏移一 [英] forecast::ets, auto.arima offset by one

查看:128
本文介绍了Forecast :: ets,auto.arima偏移一的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定这是否是预期的行为.考虑以下代码片段-

I'm not sure if this is intended behaviour. Consider the following snippet of code -

library(forecast)
x <- c(
  0, 0, 0, 0, 0.00217764964493354, 0.00339032724317772, 0.00357374918778428, 
  0.00282328811130057, 0.00272679331678393, 0.0030360769697858, 
  0.00316665914235777, 0.00163300219677676, 0.00249817841157489, 
  0.00207838479809976, 0.00192104504850639, 0.00209700948212983, 
  0.00216356555603635, 0.00250983016815862, 0.0017474879860201
)
tsData <- ts(data = x, start = 2000, frequency = 1)
df <- data.frame(
  x = x, 
  fittedets = fitted(forecast(ets(tsData), h = 7)), 
  fittedarima = fitted(forecast(auto.arima(tsData), h = 7))
)
df

             x     fittedets fittedarima
1  0.000000000 -6.997521e-07 0.000000000
2  0.000000000 -7.065016e-11 0.000000000
3  0.000000000 -7.133162e-15 0.000000000
4  0.000000000 -7.201966e-19 0.000000000
5  0.002177650  0.000000e+00 0.000000000
6  0.003390327  2.177430e-03 0.002007587
7  0.003573749  3.390205e-03 0.003125561
8  0.002823288  3.573731e-03 0.003294659
9  0.002726793  2.823364e-03 0.002602805
10 0.003036077  2.726803e-03 0.002513846
11 0.003166659  3.036046e-03 0.002798976
12 0.001633002  3.166646e-03 0.002919360
13 0.002498178  1.633157e-03 0.001505474
14 0.002078385  2.498091e-03 0.002303084
15 0.001921045  2.078427e-03 0.001916074
16 0.002097009  1.921061e-03 0.001771022
17 0.002163566  2.096992e-03 0.001933245
18 0.002509830  2.163559e-03 0.001994603
19 0.001747488  2.509795e-03 0.002313826

实际值直到第五个值都为0,而在两个模型中,拟合值大约为0直到第六个值.

The actual values are 0 until the fifth value, while in case of both models, the fitted values are about 0 until the sixth value.

我会假设前五个值的值大约为0,例如x列.我缺少基本的东西吗?

I would assume them to be approximately 0 for the first five values, like the x column. Am I missing something basic?

推荐答案

它还与auto.arima适合您的数据的ARIMA模型有关.如果您查看适合的模型:

It also has to do with the ARIMA model that auto.arima is fitting to your data. If you look at the model that it's being fitted:

Series: tsData 
ARIMA(1,0,0) with zero mean 

Coefficients:
         ar1
      0.9219
s.e.  0.0638

sigma^2 estimated as 6.076e-07:  log likelihood=108.59
AIC=-213.17   AICc=-212.42   BIC=-211.28

请记住,ARIMA代表自回归综合移动平均值,并且输出告诉我们,仅拟合了模型的AR部分,这使其成为AR(1)模型:

Remember that ARIMA stands for Autoregressive Integrated Moving Average, and the output tells us that only the AR part of the model was fitted, which makes it an AR(1) model:

y [t] = c + p1 * y [t-1]

y[t] = c + p1 * y[t-1]

有了这个等式,您可以了解这里发生的事情:

With this equation you can get a sense of what happened here:

             x     fittedets fittedarima
1  0.000000000 -6.997521e-07 0.000000000
2  0.000000000 -7.065016e-11 0.000000000 # .9219 * 0 = 0
3  0.000000000 -7.133162e-15 0.000000000 # .9219 * 0 = 0
4  0.000000000 -7.201966e-19 0.000000000 # .9219 * 0 = 0
5  0.002177650  0.000000e+00 0.000000000 # .9219 * 0 = 0
6  0.003390327  2.177430e-03 0.002007587 # .9219 * .00217 = .002007
7  0.003573749  3.390205e-03 0.003125561 # .9219 * .00339 = .003125

您还可以通过绘图来观察这种行为:

You can also observe this behavior with a plot:

library(ggplot2)
fcast <- forecast(auto.arima(tsData), h = 7)

autoplot(fcast) + 
  autolayer(fitted(fcast))

对于ets模型,发生了类似的事情,但是我希望这可以弄清楚为什么auto.arima会得到这样的结果.下次您可以探索forecast软件包中包含的更多预测模型.

For the ets model a similar thing happens, but I hope this made it clear why auto.arima had such result. Next time you could explore more forecasting models that are included in the forecast package.

希望这对您有帮助!

这篇关于Forecast :: ets,auto.arima偏移一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆