Time Series Analysis R

  • View
    981

  • Download
    2

Embed Size (px)

Text of Time Series Analysis R

Analysis of Time Series Data Using R1ZONGWU CAIa,b,cE-mail address: zcai@uncc.eduaDepartment of Mathematics & Statistics and Department of Economics,University of North Carolina, Charlotte, NC 28223, U.S.A.bWang Yanan Institute for Studies in Economics, Xiamen University, ChinacCollege of Economics and Management, Shanghai Jiaotong University, ChinaJuly 30, 2006c 2006, ALL RIGHTS RESERVED by ZONGWU CAI1This manuscript may be printed and reproduced for individual or instructional use, but maynot be printed for commercial purposes.PrefaceThe purpose of this lecture notes is designed to provide an overview of methods thatare useful for analyzing univariate and multivariate phenomena measured over time. Sincethis is a course emphasizing applications with both theory and applications, the reader isguided through examples involving real time series in the lectures. A collection of simpletheoretical and applied exercises assuming a background that includes a beginning levelcourse in mathematical statistics and some computing skills follows each chapter. Moreimportantly, the computer code in Rand datasets are provided for most of examples analyzedin this lecture notes.Some materials are based on the lecture notes given by Professor Robert H. Shumway,Department of Statistics, University of California at Davis and my colleague, ProfessorStanislav Radchenko, Department of Economics, University of North Carolina at Charlotte.Some datasets are provided by Professor Robert H. Shumway, Department of Statistics, Uni-versity of California at Davis and Professor Phillips Hans Franses at University of Rotterdam,Netherland. I am very grateful to them for providing their lecture notes and datasets.Contents1 Package R and Simple Applications 11.1 Computational Toolkits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 How to Install R ? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.3 Data Analysis and Graphics Using R An Introduction (109 pages) . . . . . 41.4 CRAN Task View: Empirical Finance . . . . . . . . . . . . . . . . . . . . . . 41.5 CRAN Task View: Computational Econometrics . . . . . . . . . . . . . . . . 82 Characteristics of Time Series 152.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152.2 Stationary Time Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172.2.1 Detrending . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212.2.2 Dierencing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242.2.3 Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262.2.4 Linear Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282.3 Other Key Features of Time Series . . . . . . . . . . . . . . . . . . . . . . . 302.3.1 Seasonality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302.3.2 Aberrant Observations . . . . . . . . . . . . . . . . . . . . . . . . . . 332.3.3 Conditional Heteroskedasticity . . . . . . . . . . . . . . . . . . . . . . 342.3.4 Nonlinearity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362.4 Time Series Relationships . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382.4.1 Autocorrelation Function . . . . . . . . . . . . . . . . . . . . . . . . . 392.4.2 Cross Correlation Function . . . . . . . . . . . . . . . . . . . . . . . . 402.4.3 Partial Autocorrelation Function . . . . . . . . . . . . . . . . . . . . 452.5 Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 492.6 Computer Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 532.7 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 663 Univariate Time Series Models 693.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 693.2 Least Squares Regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 743.3 Model Selection Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 793.3.1 Subset Approaches . . . . . . . . . . . . . . . . . . . . . . . . . . . . 793.3.2 Sequential Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 833.3.3 Likelihood Based-Criteria . . . . . . . . . . . . . . . . . . . . . . . . 853.3.4 Cross-Validation and Generalized Cross-Validation . . . . . . . . . . 87iiCONTENTS iii3.3.5 Penalized Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 883.4 Integrated Models - I(1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 903.5 Autoregressive Models - AR(p) . . . . . . . . . . . . . . . . . . . . . . . . . 933.5.1 Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 933.5.2 Forecasting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 993.6 Moving Average Models MA(q) . . . . . . . . . . . . . . . . . . . . . . . . 1023.7 Autoregressive Integrated Moving Average Model - ARIMA(p, d, q) . . . . . 1063.8 Seasonal ARIMA Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1083.9 Regression Models With Correlated Errors . . . . . . . . . . . . . . . . . . . 1203.10 Estimation of Covariance Matrix . . . . . . . . . . . . . . . . . . . . . . . . 1303.11 Long Memory Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1333.12 Periodicity and Business Cycles . . . . . . . . . . . . . . . . . . . . . . . . . 1363.13 Impulse Response Function . . . . . . . . . . . . . . . . . . . . . . . . . . . 1413.13.1 First Order Dierence Equations . . . . . . . . . . . . . . . . . . . . 1423.13.2 Higher Order Dierence Equations . . . . . . . . . . . . . . . . . . . 1463.14 Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1503.15 Computer Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1573.16 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1824 Non-stationary Processes and Structural Breaks 1854.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1854.2 Random Walks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1884.2.1 Inappropriate Detrending . . . . . . . . . . . . . . . . . . . . . . . . 1894.2.2 Spurious (nonsense) Regressions . . . . . . . . . . . . . . . . . . . . . 1904.3 Unit Root and Stationary Processes . . . . . . . . . . . . . . . . . . . . . . . 1904.3.1 Comparison of Forecasts of TS and DS Processes . . . . . . . . . . . 1914.3.2 Random Walk Components and Stochast