2014-03-05 46 views
0

我花了相當多的時間,我認爲我無處可去。我試圖在predict方法使用預測間隔。在這裏,我試圖根據日誌回報生成的AR模型預測日誌回報的未來值。我如何可以找到使用R中的AR模型預報的預測區間?

> model_1 <- ar(data1[,'Log Return'], aic = TRUE, order.max = NULL, method = c("mle")) 
> predict(model_1, data1[,'Log Return'], n.ahead = 8, level = 0.95, interval = "prediction") 

然而,R拒絕給我任何預測區間輸出:

$pred 
Time Series: 
Start = 264 
End = 271 
Frequency = 1 
[1] 0.005904645 0.006259840 0.007770717 0.007785322 0.007944444 0.007832193 0.007811966 0.007772691 

$se 
Time Series: 
Start = 264 
End = 271 
Frequency = 1 
[1] 0.009038997 0.009569202 0.009830485 0.009831987 0.009831988 0.009834717 0.009835227 0.009835437 

我到處找也沒有用,而且我開始懷疑predict方法可以」給出AR模型的預測區間。

回答

1

因爲我們沒有數據,我將使用從ar幫助文件的模型和預測關閉該。預測間隔不需要predict。使用n.ahead論點ar,並從forecast包的預測區間。

> (sunspot.ar <- ar(sunspot.year, n.ahead = 8)) 

Call: 
ar(x = sunspot.year, n.ahead = 8) 

Coefficients: 
     1  2  3  4  5  6  7  8  9 
1.1305 -0.3524 -0.1745 0.1403 -0.1358 0.0963 -0.0556 0.0076 0.1941 

Order selected 9 sigma^2 estimated as 267.5 

> library(forecast) 
> forecast(sunspot.ar, levels = 95) 
    Point Forecast  Lo 80  Hi 80  Lo 95  Hi 95 
1989  135.25933 114.299317 156.21935 103.203755 167.31491 
1990  148.09051 116.455825 179.72519 99.709436 196.47158 
1991  133.98476 96.875479 171.09404 77.231012 190.73851 
1992  106.61344 68.200200 145.02667 47.865460 165.36141 
1993  71.21921 32.673811 109.76461 12.269108 130.16932 
1994  40.84057 2.193737 79.48741 -18.264662 99.94581 
1995  18.70100 -20.206540 57.60853 -40.802945 78.20494 
1996  11.52416 -27.675854 50.72418 -48.427088 71.47541 
1997  27.24208 -12.115656 66.59982 -32.950383 87.43454 
1998  56.99888 17.600443 96.39731 -3.255828 117.25359 
相關問題