Regression models

pbenavides
library(tidyverse)
library(fpp3)
library(ggtime)

Regression Models for Time Series forecasting

Introduction

Regression models can be powerful tools for understanding and forecasting time series when the relationship between a dependent variable and one or more explanatory variables is approximately linear. Unlike ARIMA models, regression models explicitly model deterministic components such as trend and seasonality.

Introduction

Regression models can help identify and forecast deterministic patterns in time series. They are particularly useful when explanatory variables or known calendar effects drive much of the observed variation.

Time Series Regression Models

A time series regression model expresses a variable y_t as a linear combination of explanatory variables:

y_t = \beta_0 + \beta_1 x_{1t} + \beta_2 x_{2t} + \dots + \varepsilon_t

where \varepsilon_t is the random error term.

We will use the us_change dataset from the fpp3 package, which contains quarterly percentage changes in US consumption, income, production, savings, and unemployment.

library(fpp3)

us_change |> 
  glimpse()
Rows: 198
Columns: 6
$ Quarter      <qtr> 1970 Q1, 1970 Q2, 1970 Q3, 1970 Q4, 1971 Q1, 1971 Q2, 197…
$ Consumption  <dbl> 0.61856640, 0.45198402, 0.87287178, -0.27184793, 1.901344…
$ Income       <dbl> 1.0448013, 1.2256472, 1.5851538, -0.2395449, 1.9759249, 1…
$ Production   <dbl> -2.45248553, -0.55145947, -0.35865175, -2.18569087, 1.909…
$ Savings      <dbl> 5.2990141, 7.7898938, 7.4039841, 1.1698982, 3.5356669, 5.…
$ Unemployment <dbl> 0.9, 0.5, 0.5, 0.7, -0.1, -0.1, 0.1, 0.0, -0.2, -0.1, -0.…

A simple regression model relating Consumption to Income can be fit using:

us_change |>
model(OLS = TSLM(Consumption ~ Income)) |>
report()
Series: Consumption 
Model: TSLM 

Residuals:
     Min       1Q   Median       3Q      Max 
-2.58236 -0.27777  0.01862  0.32330  1.42229 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  0.54454    0.05403  10.079  < 2e-16 ***
Income       0.27183    0.04673   5.817  2.4e-08 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.5905 on 196 degrees of freedom
Multiple R-squared: 0.1472, Adjusted R-squared: 0.1429
F-statistic: 33.84 on 1 and 196 DF, p-value: 2.4022e-08

Interpretation

The estimated coefficient for Income represents the average change in consumption (percentage points) associated with a one–percentage-point change in income.