Preface

These notes are based on the Time Series with R skill track at DataCamp and Forecasting: Principles and Practice (Rob J Hyndman 2021).

Not all forecasting is quantitative - if you have no data you use qualitative judgment procedures. But quantitative forecasting isn’t necessarily based on time series models - your model may be a cross-sectional analysis of relevant factors, perhaps even including time-related factors such as month of year or day of week. Time series forecasting is a specific type of forecasting: it is a quantitative forecast of future outcomes based, at least in part, on the assumption that future outcomes are functionally dependent upon prior outcomes.

In most cases your forecasting objective is to project a time series. In these cases, the time series forecast is either an exercise of decomposing a time series into trend and seasonality components (exponential smoothing models) or describing the autocorrelation within the data (ARIMA models). There may also be cases where you include other predictor variables (dynamic models).

These notes are structured as four sections. The toolbox section is about using R to explore and wrangle time series data. The next three sections describe the three main modeling techniques: exponential smoothing, ARIMA, and dynamic models.

library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5     v purrr   0.3.4
## v tibble  3.1.2     v dplyr   1.0.7
## v tidyr   1.1.3     v stringr 1.4.0
## v readr   1.4.0     v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(tsibble)
## 
## Attaching package: 'tsibble'
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, union
library(fpp3)
## -- Attaching packages -------------------------------------------- fpp3 0.4.0 --
## v lubridate   1.7.10     v feasts      0.2.2 
## v tsibbledata 0.3.0      v fable       0.3.1
## -- Conflicts ------------------------------------------------- fpp3_conflicts --
## x lubridate::date()     masks base::date()
## x dplyr::filter()       masks stats::filter()
## x tsibble::intersect()  masks base::intersect()
## x lubridate::interval() masks tsibble::interval()
## x dplyr::lag()          masks stats::lag()
## x tsibble::setdiff()    masks base::setdiff()
## x tsibble::union()      masks base::union()
library(fable)
library(patchwork) # for arranging plots
library(glue) # for informative labels
## 
## Attaching package: 'glue'
## The following object is masked from 'package:dplyr':
## 
##     collapse
library(xts)
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following object is masked from 'package:tsibble':
## 
##     index
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## 
## Attaching package: 'xts'
## The following objects are masked from 'package:dplyr':
## 
##     first, last

References

Rob J Hyndman, George Athanasopoulos. 2021. Forecasting: Principles and Practice. 3rd ed. Otexts. https://otexts.com/fpp3/.