Principles of Econometrics with R - Time Series Analysis PDF
Document Details
Tags
Related
- Applied Econometrics ARIMA Models Lecture Handout 5 PDF
- Applied Econometrics GARCH Models Lecture Handout PDF
- Applied Econometrics Forecasting with ARMA & GARCH Models PDF
- Decomposing Time Series Data PDF
- Economic Forecasting - Time Series Analysis PDF
- Unit 10+11: Introduction to Time Series Analysis PDF
Summary
This textbook chapter introduces time series analysis, covering stationary variables and finite distributed lag models. It demonstrates the usage of R programming for econometric analysis.
Full Transcript
Chapter 9 Time-Series: Stationary Variables rm(list=ls()) #Removes all items in Environment! library(dynlm) #for the `dynlm()` function library(orcutt) # for the `cochrane.orcutt()` function library(nlWaldTest) # for the `nlWaldtest()` function library(zoo) # for time series functions (not much us...
Chapter 9 Time-Series: Stationary Variables rm(list=ls()) #Removes all items in Environment! library(dynlm) #for the `dynlm()` function library(orcutt) # for the `cochrane.orcutt()` function library(nlWaldTest) # for the `nlWaldtest()` function library(zoo) # for time series functions (not much used here) library(pdfetch) # for retrieving data (just mentioned here) library(lmtest) #for `coeftest()` and `bptest()`. library(broom) #for `glance(`) and `tidy()` library(PoEdata) #for PoE4 datasets library(car) #for `hccm()` robust standard errors library(sandwich) library(knitr) #for kable() library(forecast) New packages: dynlm (Zeileis 2016); orcutt (Spada, Quartagno, and Tamburini 2012); nlWaldTest (Komashko 2016); zoo [R-zoo]; pdfetch (Reinhart 2015); and forecast (Hyndman 2016). Time series are data on several variables on an observational unit (such as an individual, country, or firm) when observations span several periods. Correlation among subsequent observations, the importance of the natural order in the data and dynamics (past values of data influence present and future values) are features of time series that do not occur in cross-sectional data. Time series models assume, in addition to the usual linear regression assumptions, that the esries is stationary, that is, the distribution of the error term, as well as the 137 138 CHAPTER 9. TIME-SERIES: STATIONARY VARIABLES correlation between error terms a few periods apart are constant over time. Constant distribution requires, in particular, that the variable does not display a trend in its mean or variance; constant correlation implies no clustering of observations in certain periods. 9.1 An Overview of Time Series Tools in R R creates a time series variable or dataset using the function ts(), with the following main arguments: your data file in matrix or data frame form, the start period, the end period, the frequency of the data (1 is annual, 4 is quarterly, and 12 is monthly), and the names of your column variables. Another class of time series objects is created by the function zoo() in the package zoo, which, unlike ts(), can handle irregular or high-frequency time series. Both ts and zoo classes of objects can be used by the function dynlm() in the package with the same name to solve models that include lags and other time series specific operators. In standard R, two functions are very useful when working with time series: the difference function, dif f (yt ) = yt − yt−1 , and the lag function, lag(yt ) = yt−1. The package pdfetch is a very useful tool for getting R-compatible time series data from different online sources such as the World Bank, Eurostat, European Central Bank, and Yahoo Finance. The package WDI retrieves data from the very rich World Development Indicators database, maintained by the World Bank. 9.2 Finite Distributed Lags A finite distributed lag model (FDL) assumes a linear relationship between a depen- dent variable y and several lags of an independent variable x. Equation 9.1 shows a finite distributed lag model of order q. yt = α + β0 xt + β1 xt−1 +... + βq xt−q + et (9.1) The coefficient βs is an s-period delay multiplier, and the coefficient β0 , the immediate (contemporaneous) impact of a change in x on y, is an impact multiplier. If x increases by one unit today, the change in y will be β0 +β1 +...+βs after s periods; this quantity is called the s-period interim multiplier. The total multiplier is equal to the sum of all βs in the model. Let us look at Okun’s law as an example of an FDL model. Okun’s law relates contemporaneous (time t) change in unemployment rate, DUt , to present and past levels of economic growth rate, Gt−s. 9.2. FINITE DISTRIBUTED LAGS 139 Table 9.1: The ‘okun‘ dataset with differences and lags g u uL1 du gL1 gL2 gL3 1.4 7.3 NA NA NA NA NA 2.0 7.2 7.3 -0.1 1.4 NA NA 1.4 7.0 7.2 -0.2 2.0 1.4 NA 1.5 7.0 7.0 0.0 1.4 2.0 1.4 0.9 7.2 7.0 0.2 1.5 1.4 2.0 1.5 7.0 7.2 -0.2 0.9 1.5 1.4 Table 9.2: The ‘okun‘ distributed lag model with three lags term estimate std.error statistic p.value (Intercept) 0.5810 0.0539 10.7809 0.0000 L(g, 0:3)0 -0.2021 0.0330 -6.1204 0.0000 L(g, 0:3)1 -0.1645 0.0358 -4.5937 0.0000 L(g, 0:3)2 -0.0716 0.0353 -2.0268 0.0456 L(g, 0:3)3 0.0033 0.0363 0.0911 0.9276 data("okun", package="PoEdata") library(dynlm) check.ts