Dynamic regression Rob Hyndman Author, forecast Forecasting Using - - PowerPoint PPT Presentation

dynamic regression
SMART_READER_LITE
LIVE PREVIEW

Dynamic regression Rob Hyndman Author, forecast Forecasting Using - - PowerPoint PPT Presentation

FORECASTING USING R Dynamic regression Rob Hyndman Author, forecast Forecasting Using R Dynamic regression Regression model with ARIMA errors y t = 0 + 1 x 1, t + + r x r , t + e t modeled as function of r explanatory


slide-1
SLIDE 1

FORECASTING USING R

Dynamic regression

Rob Hyndman

Author, forecast

slide-2
SLIDE 2

Forecasting Using R

Dynamic regression

Regression model with ARIMA errors

  • modeled as function of r explanatory variables
  • In dynamic regression, we allow to be an ARIMA process
  • In ordinary regression, we assume that is white noise

yt = β0 + β1x1,t + · · · + βrxr,t + et

et

yt

et

x1,t, ... , xr,t

slide-3
SLIDE 3

Forecasting Using R

US personal consumption and income

> autoplot(uschange[,1:2], facets = TRUE) + xlab("Year") + ylab("") + ggtitle("Quarterly changes in US consumption and personal income")

slide-4
SLIDE 4

Forecasting Using R

US personal consumption and income

> ggplot(aes(x = Income, y = Consumption), data = as.data.frame(uschange)) + geom_point() + ggtitle("Quarterly changes in US consumption and personal income")

slide-5
SLIDE 5

Forecasting Using R

Dynamic regression model for US personal consumption

> fit <- auto.arima(uschange[,"Consumption"], xreg = uschange[,"Income"]) > fit Series: uschange[, "Consumption"] Regression with ARIMA(1,0,2) errors Coefficients: ar1 ma1 ma2 intercept origxreg 0.6191 -0.5424 0.2367 0.6099 0.2492 s.e. 0.1422 0.1475 0.0685 0.0777 0.0459 sigma^2 estimated as 0.334: log likelihood=-195.22 AIC=402.44 AICc=402.82 BIC=422.99

slide-6
SLIDE 6

Forecasting Using R

Residuals from dynamic regression model

> checkresiduals(fit) Ljung-Box test data: residuals Q* = 5.5543, df = 3, p-value = 0.1354 Model df: 5. Total lags used: 8

slide-7
SLIDE 7

Forecasting Using R

Forecasts from dynamic regression model

> fcast <- forecast(fit, xreg = rep(0.8, 8)) > autoplot(fcast) + xlab("Year") + ylab("Percentage change")

slide-8
SLIDE 8

FORECASTING USING R

Let’s practice!

slide-9
SLIDE 9

FORECASTING USING R

Dynamic harmonic regression

slide-10
SLIDE 10

Forecasting Using R

Dynamic harmonic regression

  • seasonal period
  • Every periodic function can be approximated by sums of sin and cos terms

for large enough K

  • Regression coefficients: and
  • can be modeled as a non-seasonal ARIMA process
  • Assumes seasonal paern is unchanging

Periodic seasonality can be handled using pairs of Fourier terms:

αk

yt = β0 +

K

  • k=1

[αksk(t) + γkck(t)] + et

et

γk

m =

sk(t) = sin 2πkt m

  • ck(t) = cos

2πkt m

slide-11
SLIDE 11

Forecasting Using 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)

slide-12
SLIDE 12

Forecasting Using 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)

slide-13
SLIDE 13

Forecasting Using 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)

slide-14
SLIDE 14

Forecasting Using 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)

slide-15
SLIDE 15

Forecasting Using 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)

slide-16
SLIDE 16

Forecasting Using 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)

slide-17
SLIDE 17

Forecasting Using R

Dynamic harmonic regression

  • Other predictor variables can be added as well:
  • Choose K to minimize the AICc
  • K can not be more than m/2
  • This is particularly useful for weekly data, daily data and sub-daily

data

data.

yt = β0 + β1xt,1 + · · · + βt,rxt,r +

K

  • k=1

[αksk(t) + γkck(t)] + et

xt,1, ... , xt,r

slide-18
SLIDE 18

FORECASTING USING R

Let’s practice!

slide-19
SLIDE 19

FORECASTING USING R

TBATS models

slide-20
SLIDE 20

Forecasting Using R

TBATS model

  • Trigonometric terms for seasonality
  • Box-Cox transformations for heterogeneity
  • ARMA errors for short-term dynamics
  • Trend (possibly damped)
  • Seasonal (including multiple and non-integer periods)
slide-21
SLIDE 21

Forecasting Using R

US Gasoline data

> gasoline %>% tbats() %>% forecast() %>% autoplot() + xlab("Year") + ylab("thousand barrels per day")

slide-22
SLIDE 22

Forecasting Using R

Call center data

> calls %>% window(start = 20) %>% tbats() %>% forecast() %>% autoplot() + xlab("Weeks") + ylab("Calls")

slide-23
SLIDE 23

Forecasting Using R

TBATS model

  • Trigonometric terms for seasonality
  • Box-Cox transformations for heterogeneity
  • ARMA errors for short-term dynamics
  • Trend (possibly damped)
  • Seasonal (including multiple and non-integer periods)
  • Handles non-integer seasonality, multiple seasonal periods
  • Entirely automated
  • Prediction intervals oen too wide
  • Very slow on long series
slide-24
SLIDE 24

FORECASTING USING R

Let’s practice!