我希望随着我增加更多滞后,用于执行估算的观察数量会减少,但事实并非如此。你知道这是怎么回事吗?
fit1 <- arima(presidents, c(1, 0, 0))
fit3 <- arima(presidents, c(3, 0, 0))
paste0("length fit1: ", length(fit1$residuals))
paste0("length fit3: ",length(fit3$residuals))
paste0("length presidents: ",length(presidents))
# [1] "length fit1: 120"
# [1] "length fit3: 120"
# [1] "length presidents: 120"
更新
要清楚地看到它,我们可以使用另一种方式来创建数据。如果我不得不使用其他工具,我会做以下
a <- embed(presidents,3)
b <- embed(presidents,2) # setting the data for AR1 estimation
head(b)
paste0("nobs used to estimate AR1 is: ",nrow(b))
# : [,1] [,2]
# : [1,] 87 NA
# : [2,] 82 87
# : [3,] 75 82
# : [4,] 63 75
# : [5,] 50 63
# : [6,] 43 50
# : [1] "nobs used to estimate AR1 is: 119"