gpt4 book ai didi

r - 无法重现华宇所做的预测

转载 作者:行者123 更新时间:2023-12-04 10:14:57 24 4
gpt4 key购买 nike

我想手动检查函数 arima 所做的预测,但得到了不同的结果。以下是一个简单的 AR(1) 示例:

set.seed(123)
D<-rnorm(7)
> D
[1] -0.56047565 -0.23017749 1.55870831 0.07050839 0.12928774 1.71506499 0.46091621

M<-arima(D,order=c(1,0,0))
predict(M)
> predict(M)$pred[1]
[1] 0.4748763
# So, the one-step-ahead prediction is: 0.4748763

# I tried to calculate this manually using the intercept:M$coef[2] and the slope multiplied with the last observation: M$coef[1]*( 0.46091621)
M$coef[2]+M$coef[1]*( 0.46091621)
0.3863168
# As can be seen, the result now is: 0.3863168

谁能告诉我如何“手动”获得相同的结果?

最佳答案

当然,问得好。基本问题是 R 的作者称为 “截距” 的系数将更准确地识别为 “均值”

这里是您可以手动执行计算的方法

b <- coef(M)
b[[2]] + b[[1]]*(D[7] - b[[2]])
# [1] 0.4748763

here is a nice discussion "Time Series Analysis and Its Applications: With R Examples" 的作者提出的这个主题.

关于r - 无法重现华宇所做的预测,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21146734/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com