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

 

 

 

 

 

Summary

 

367

Coefficients:

 

 

 

 

 

 

 

 

ar1

ar2

ma1

 

ma2

 

 

 

 

 

1.35 -0.396 -1.77

0.810

 

 

 

 

s.e.

0.03

0.029

0.02

 

0.019

 

 

 

 

sigma^2 estimated as 243:

 

log likelihood=-11746

 

AIC=23501

AICc=23501

BIC=23531

 

 

 

> forecast(fit, 3)

 

 

 

 

 

 

 

 

Point Forecast

 

Lo

80

Hi 80

Lo 95

Hi 95

Jan

1984

40.437722

20.4412613

60.43418

9.855774

71.01967

Feb

1984

41.352897

18.2795867

64.42621

6.065314

76.64048

Mar

1984

39.796425

15.2537785

64.33907

2.261686

77.33116

> accuracy(fit)

 

 

 

 

 

 

 

 

 

 

ME RMSE

MAE

MPE MAPE MASE

 

 

Training set -0.02673 15.6

11.03

NaN

Inf 0.32

 

 

The function selects an ARIMA model with p=2, d=1, and q=2. These are values that minimize the AIC criterion over a large number of possible models. The MPE and MAPE accuracy blow up because there are zero values in the series (a drawback of these two statistics). Plotting the results and evaluating the fit are left for you as an exercise.

15.5 Going further

There are many good books on time-series analysis and forecasting. If you’re new to the subject, I suggest starting with the book Time Series (Open University, 2006). Although it doesn’t include R code, it provides a very understandable and intuitive introduction. A Little Book of R for Time Series by Avril Coghlan (http://mng.bz/8fz0, 2010) pairs well with the Open University text and includes R code and examples.

Forecasting: Principles and Practice (http://otexts.com/fpp, 2013) is a clear and concise online textbook written by Rob Hyndman and George Athanasopoulos; it includes R code throughout. I highly recommend it. Additionally, Cowpertwait & Metcalfe (2009) have written an excellent text on analyzing time series with R. A more advanced treatment that also includes R code can be found in Shumway & Stoffer (2010).

Finally, you can consult the CRAN Task View on Time Series Analysis (http:// cran.r-project.org/web/views/TimeSeries.html). It contains a comprehensive summary of all of R’s time-series capabilities.

15.6 Summary

Forecasting has a long and varied history, from early shamans predicting the weather to modern data scientists predicting the results of recent elections. Prediction is fundamental to both science and human nature. In this chapter, we’ve looked at how to create time series in R, assess trends, and examine seasonal effects. Then we

368

CHAPTER 15 Time series

considered two of the most popular approaches to forecasting: exponential models and ARIMA models.

Although these methodologies can be crucial in understanding and predicting a wide variety of phenomena, it’s important to remember that they each entail extrapo- lation—going beyond the data. They assume that future conditions mirror current conditions. Financial predictions made in 2007 assumed continued economic growth in 2008 and beyond. As we all know now, that isn’t exactly how things turned out. Significant events can change the trend and pattern in a time series, and the farther out you try to predict, the greater the uncertainty.

In the next chapter, we’ll shift gears and look at methodologies that are important to anyone trying to classify individuals or observations into discrete groups.

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