我使用以下示例代码,对数据运行AR1进程 (只是我选择检查功能的数字):
> data
[1] 3 7 4 6 2 8 5 4
> data_ts
Time Series:
Start = 1
End = 8
Frequency = 1
[1] 3 7 4 6 2 8 5 4
> arima(data_ts,order=c(1,0,0))
Call:
arima(x = data_ts, order = c(1, 0, 0))
Coefficients:
ar1 intercept
-0.6965 5.0323
s.e. 0.2334 0.2947
sigma^2 estimated as 1.769: log likelihood = -13.97, aic = 33.93
残差是:
> arima(data_ts,order=c(1,0,0))$resid
Time Series:
Start = 1
End = 8
Frequency = 1
[1] -1.4581973 0.5521706 0.3383218 0.2487084 -2.3582160 0.8556328 2.0348596
[8] -1.0547538
现在,系数应为-0.6965,截距为5.0323。我想验证结果。所以我相应地分配参数,即:
data[8] = intercept + coefficcient_data[7] + residual[8]
但它永远不会正确。我究竟做错了什么? BTW - 尝试ar函数会产生不同的结果:
ar(x = data_ts, aic = FALSE, order.max = 1, method = "ols")
Coefficients:
1
-0.6786
Intercept: 0.3527 (0.4951)
订单选择1 sigma ^ 2估计为1.709。而且 - 当我将时间序列参数分配给估计的方程+误差时,结果是不正确的。有什么想法吗?