Dynamic harmonic regression

Forecasting in R

Rob J. Hyndman

Professor of Statistics at Monash University

Dynamic harmonic regression

ch5_vid2_slides.003.png

Forecasting in R

Dynamic harmonic regression

ch5_vid2_slides.004.png

  • $m =$ seasonal period

  • Every periodic function can be approximated by sums of sin and cos terms for large enough K

  • Regression coefficients: $\alpha_k$ and $\gamma_k$

  • $e_t$ can be modeled as a non-seasonal ARIMA process

  • Assumes seasonal pattern is unchanging

Forecasting in R

Example: Australian cafe expenditure

fit <- auto.arima(cafe, xreg = fourier(cafe, K = 1),
                  seasonal = FALSE, lambda = 0)
fit %>% forecast(xreg = fourier(cafe, K = 1, h = 24)) %>%
   autoplot() + ylim(1.6, 5.1)

ch5_vid2_cafe_fcast.png

Forecasting in R

Example: Australian cafe expenditure

fit <- auto.arima(cafe, xreg = fourier(cafe, K = 2),
                  seasonal = FALSE, lambda = 0)
fit %>% forecast(xreg = fourier(cafe, K = 2, h = 24)) %>%
   autoplot() + ylim(1.6, 5.1)

ch5_vid2_cafe_fcast_2.png

Forecasting in R

Example: Australian cafe expenditure

fit <- auto.arima(cafe, xreg = fourier(cafe, K = 3),
                  seasonal = FALSE, lambda = 0)
fit %>% forecast(xreg = fourier(cafe, K = 3, h = 24)) %>%
   autoplot() + ylim(1.6, 5.1)

ch5_vid2_cafe_fcast_3.png

Forecasting in R

Example: Australian cafe expenditure

fit <- auto.arima(cafe, xreg = fourier(cafe, K = 4),
                  seasonal = FALSE, lambda = 0)
fit %>% forecast(xreg = fourier(cafe, K = 4, h = 24)) %>%
   autoplot() + ylim(1.6, 5.1)

ch5_vid2_cafe_fcast_4.png

Forecasting in R

Example: Australian cafe expenditure

fit <- auto.arima(cafe, xreg = fourier(cafe, K = 5),
                  seasonal = FALSE, lambda = 0)
fit %>% forecast(xreg = fourier(cafe, K = 5, h = 24)) %>%
   autoplot() + ylim(1.6, 5.1)

ch5_vid2_cafe_fcast_5.png

Forecasting in R

Example: Australian cafe expenditure

fit <- auto.arima(cafe, xreg = fourier(cafe, K = 6),
                  seasonal = FALSE, lambda = 0)
fit %>% forecast(xreg = fourier(cafe, K = 6, h = 24)) %>%
   autoplot() + ylim(1.6, 5.1)

ch5_vid2_cafe_fcast_6.png

Forecasting in R

Dynamic harmonic regression

ch5_vid2_slides.025.png

  • Other predictor variables can be added as well: $x_{t,1},...,x_{t,r}$
  • Choose K to minimize the $AIC_c$
  • K can not be more than m/2
  • This is particularly useful for weekly data, daily data and sub-daily data.
Forecasting in R

Let's practice!

Forecasting in R

Preparing Video For Download...