welcome to forecasting using r
play

Welcome to Forecasting Using R Rob Hyndman Author, forecast - PowerPoint PPT Presentation

FORECASTING USING R Welcome to Forecasting Using R Rob Hyndman Author, forecast Forecasting Using R What you will learn Exploring and visualizing time series Simple benchmark methods for forecasting Exponential smoothing and


  1. FORECASTING USING R Welcome to Forecasting Using R Rob Hyndman Author, forecast

  2. Forecasting Using R What you will learn ● Exploring and visualizing time series ● Simple benchmark methods for forecasting ● Exponential smoothing and ARIMA models ● Advanced forecasting methods ● Measuring forecast accuracy ● Choosing the best method

  3. Forecasting Using R Course textbook Hyndman, R. J. & Athanasopoulos, G. (2017) Forecasting: principles and practice , 2nd edition ● Free and online at OTexts.org/fpp2/ ● Data sets in associated R package fpp2 ● R code for all examples

  4. Forecasting Using R Time series data ● Series of data observed over time ● Eg.: Daily IBM stock prices, monthly rainfall in London,… Forecasting is estimating how the sequence of observations will continue into the future.

  5. Forecasting Using R Forecasts of monthly Australian expenditure on eating out ● What forecasting methods are available that take account of trend, seasonality and other features of the data? ● How to measure the accuracy of your forecasts? ● How to choose a good forecasting model?

  6. FORECASTING USING R Let’s practice!

  7. FORECASTING USING R Trends, seasonality, and cyclicity

  8. Forecasting Using R Time series pa � erns Pa � ern Description A pa � ern exists involving a long-term increase OR decrease in Trend the data A periodic pa � ern exists due to the calendar Seasonal (e.g. the quarter, month, or day of the week) A pa � ern exists where the data exhibits rises and falls that are Cyclic not of fixed period (duration usually of at least 2 years)

  9. Forecasting Using R Examples of time series pa � erns

  10. Forecasting Using R Examples of time series pa � erns

  11. Forecasting Using R Examples of time series pa � erns

  12. Forecasting Using R Examples of time series pa � erns

  13. Forecasting Using R Seasonal or cyclic? Di ff erences between seasonal and cyclic pa � erns: Seasonal pa � ern constant length vs. cyclic pa � ern variable ● length Average length of cycle longer than length of seasonal pa � ern ● ● Magnitude of cycle more variable than magnitude of seasonal pa � ern The timing of peaks and troughs is predictable with seasonal data, but unpredictable in the long term with cyclic data.

  14. FORECASTING USING R Let’s practice!

  15. FORECASTING USING R White noise

  16. Forecasting Using R White noise > set.seed(3) # Reproducibility > wn <- ts(rnorm(36)) # White noise > autoplot(wn) # Plot! "White noise" is just a time series of iid data

  17. Forecasting Using R White noise ACF > ggAcf(wn) + ggtitle("Sample ACF for white noise") Expectation: each autocorrelation is close to zero 95% of all autocorrelations for white If not: series is probably noise should lie within the blue lines not white noise

  18. Forecasting Using R Example: Pigs slaughtered > autoplot(pigs/1000) + > xlab("Year") + > ylab("thousands") + > ggtitle("Monthly number of pigs slaughtered in Victoria")

  19. Forecasting Using R Example: Pigs slaughtered > ggAcf(pigs) + > ggtitle("ACF of monthly pigs slaughtered in Victoria") significant autocorrelation at lags 1, 2, and 3 Not a white noise series: there is info in the data that can be used to forecast future values

  20. 
 Forecasting Using R Ljung-Box test The Ljung-Box test considers the first h autocorrelation values together . 
 A significant test (small p-value) indicates the data are probably not white noise. > Box.test(pigs, lag = 24, fitdf = 0, type = "Lj") Box-Ljung test data: pigs X-squared = 634.15, df = 24, p-value < 2.2e-16

  21. Forecasting Using R White noise summary ● White noise is a time series that is purely random ● We can test for white noise by looking at an ACF plot or by doing a Ljung-Box test

  22. FORECASTING USING R Let’s practice!

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend