**Open Review**. We want your feedback to make the book better for you and other students. You may annotate some text by selecting it with the cursor and then click the on the pop-up menu. You can also see the annotations of others: click the in the upper right hand corner of the page

# 14 Introduction to Time Series Regression and Forecasting

Time series data is data is collected for a single entity over time. This is fundamentally different from cross-section data which is data on multiple entities at the same point in time. Time series data allows estimation of the effect on \(Y\) of a change in \(X\) *over time*. This is what econometricians call a *dynamic causal effect*. Let us go back to the application to cigarette consumption of Chapter 12 where we were interested in estimating the effect on cigarette demand of a price increase caused by a raise of the general sales tax. One might use time series data to assess the causal effect of a tax increase on smoking both initially and in subsequent periods.

Another application of time series data is forecasting. For example, weather services use time series data to predict tomorrow’s temperature by inter alia using today’s temperature and temperatures of the past. To motivate an economic example, central banks are interested in forecasting next month’s unemployment rates.

The remainder of Chapters in the book deals with the econometric techniques for the analysis of time series data and applications to forecasting and estimation of dynamic causal effects. This section covers the basic concepts presented in Chapter 14 of the book, explains how to visualize time series data and demonstrates how to estimate simple autoregressive models, where the regressors are past values of the dependent variable or other variables. In this context we also discuss the concept of stationarity, an important property which has far-reaching consequences.

Most empirical applications in this chapter are concerned with forecasting and use data on U.S. macroeconomic indicators or financial time series like Gross Domestic Product (GDP), the unemployment rate or excess stock returns.

The following packages and their dependencies are needed for reproduction of the code chunks presented throughout this chapter:

`AER`(Kleiber and Zeileis 2020)`dynlm`(Zeileis 2019)`forecast`(Hyndman et al. 2020)`readxl`(Wickham and Bryan 2019)`stargazer`(Hlavac 2018)`scales`(Wickham and Seidel 2020)`quantmod`(Ryan and Ulrich 2020)`urca`(Pfaff 2016)

Please verify that the following code chunk runs on your machine without any errors.

```
library(AER)
library(dynlm)
library(forecast)
library(readxl)
library(stargazer)
library(scales)
library(quantmod)
library(urca)
```

### References

Hlavac, Marek. 2018. *stargazer: Well-Formatted Regression and Summary Statistics Tables* (version 5.2.2). https://CRAN.R-project.org/package=stargazer.

Hyndman, Rob, George Athanasopoulos, Christoph Bergmeir, Gabriel Caceres, Leanne Chhay, Mitchell O’Hara-Wild, Fotios Petropoulos, Slava Razbash, Earo Wang, and Farah Yasmeen. 2020. *forecast: Forecasting Functions for Time Series and Linear Models* (version 8.12). https://CRAN.R-project.org/package=forecast.

Kleiber, Christian, and Achim Zeileis. 2020. *AER: Applied Econometrics with R* (version 1.2-9). https://CRAN.R-project.org/package=AER.

Pfaff, Bernhard. 2016. *urca: Unit Root and Cointegration Tests for Time Series Data* (version 1.3-0). https://CRAN.R-project.org/package=urca.

Ryan, Jeffrey A., and Joshua M. Ulrich. 2020. *quantmod: Quantitative Financial Modelling Framework* (version 0.4.17). https://CRAN.R-project.org/package=quantmod.

Wickham, Hadley, and Jennifer Bryan. 2019. *readxl: Read Excel Files* (version 1.3.1). https://CRAN.R-project.org/package=readxl.

Wickham, Hadley, and Dana Seidel. 2020. *scales: Scale Functions for Visualization* (version 1.1.1). https://CRAN.R-project.org/package=scales.

Zeileis, Achim. 2019. *dynlm: Dynamic Linear Regression* (version 0.3-6). https://CRAN.R-project.org/package=dynlm.