Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
R in Action, Second Edition.pdf
Скачиваний:
540
Добавлен:
26.03.2016
Размер:
20.33 Mб
Скачать

366

CHAPTER 15 Time series

Forecasts from ARIMA(0,1,1)

 

1400

 

 

 

 

 

1200

 

 

 

 

Flow

1000

 

 

 

 

Annual

800

 

 

 

 

 

600

 

 

 

 

 

1880

1900

1920

1940

1960

 

 

 

Year

 

 

Figure 15.14 Three-year forecast for the Nile time series from a fitted ARIMA(0,1,1) model. Blue dots represent point estimates, and the light and dark gray bands represent the 80% and 95% confidence bands limits, respectively.

Listing 15.10 Forecasting with an ARIMA model

> forecast(fit, 3)

 

 

 

 

 

Point Forecast

Lo 80

Hi 80

Lo 95

Hi 95

1971

798.3673

614.4307

982.3040

517.0605

1079.674

1972

798.3673

607.9845

988.7502

507.2019

1089.533

1973

798.3673

601.7495

994.9851

497.6663

1099.068

> plot(forecast(fit, 3), xlab="Year", ylab="Annual Flow")

The plot() function is used to plot the forecast in figure 15.14. Point estimates are given by the blue dots, and 80% and 95% confidence bands are represented by dark and light bands, respectively.

15.4.3Automated ARIMA forecasting

In section 15.2.3, you used the ets() function in the forecast package to automate the selection of a best exponential model. The package also provides an auto.arima() function to select a best ARIMA model. The next listing applies this approach to the sunspots time series described in the chapter introduction.

Listing 15.11 Automated ARIMA forecasting

>library(forecast)

>fit <- auto.arima(sunspots)

>fit

Series: sunspots

ARIMA(2,1,2)

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]