Arima中的拟合值(样本外的一步预测)-包“预测”

时间:2019-05-16 04:29:49

标签: r arima

我有一个参数为ar1=0.999095139ar2=-0.003696142的ARIMA模型(2,0,0)。

我在R中使用forecast::Arima。在这种情况下,我想知道如何在测试集上的ARIMAfit2$fitted函数中计算第一个和第二个值(样本外分步预测)?

# Training data
train = c(0.8393574,0.8313253,0.8232932,0.9959839,0.9879518,0.9799197,0.9558233,0.8273092,0.8313253,0.8232932)
# Test data 
test=c(1,1,1,1,1,1,1,1,1,1,1)
# Estimating in training data
ARIMAfit = Arima(train, order = c(2,0,0), method = 'CSS',include.mean = FALSE)
# Re-estimating in test data
ARIMAfit2 = Arima(test, model = ARIMAfit)
# Model parameters 
ARIMA(2,0,0) with zero mean
ar1=0.999095139 
ar2=-0.003696142
# Fitted values one-step forecast, 1st to 11th. How the 1st and 2nd values are calculated?  
ARIMAfit2$fitted
0.9043602 0.9954160 0.995399 0.995399 0.995399 0.995399 0.995399 0.995399 0.995399 0.995399 0.995399
# One step by hand, 3rd to 11th  
oneStepByHand = 0.999095139*test[1:9] - 0.003696142*test[2:10]
0.995399 0.995399 0.995399 0.995399 0.995399 0.995399 0.995399 0.995399 0.995399

0 个答案:

没有答案