在原始数据上绘制拟合的 ARIMA 结果时,拟合值有时会出现一个时间步长:
library(forecast)
set.seed(1)
#simualted ts
eg <- arima.sim(n = 100, list(order = c(1,1,2), ar = -0.5, ma = c(.1, -0.3)),
sd = 1)
#fitted Arima with same order
eg_aa <- forecast::Arima(eg, order = c(1,1,2))
par(mfrow = c(2,1),
oma = c(0,0,0,0),
mar = c(2,4,1,1))
plot(eg, main="as-is") # plot original sim
lines(fitted(eg_aa), col = "red") # plot fitted values
legend("topleft", legend = c("original","fitted"), col = c("black","red"),lty = 1)
plot(eg, main = "time-deltat") # plot original sim
points(time(fitted(eg_aa))-deltat(eg), # plot fitted values shifted back one time-step
fitted(eg_aa),
type = "l", col = "red")
但并非总是如此,拟合值在此示例中排列:in-r-plot-arima-fitted-model-with-the-original-series
根据我在时间序列课程中的记忆,曾经有差异的模型应该只适合第一次之后的观察,所以我不清楚 arima() 在哪里得到 t=1 拟合。但最重要的是,我想知道明显的时移是错误还是 arima 模型的奇怪结果。有任何想法吗?