Analysis of Time Series Data Using R + Code 
this book provide an overview of methods that are useful for analyzing univariate 
and multivariate phenomena measured over time. Since 
this is a course emphasizing applications with both theory and applications, the reader is 
guided through examples involving real time series in the lectures. A collection of simple 
theoretical and applied exercises assuming a background that includes a beginning level 
course in mathematical statistics and some computing skills follows each chapter. More 
importantly, the computer code in R and datasets are provided for most of examples analyzed 
in this book. 
本帖主要为学习R的朋友准备,不用R软件的朋友不必下载。 
是一本没有出版的书,目录: 
Contents 
1 Package R and Simple Applications 1 
1.1 Computational Toolkits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 
1.2 How to Install R ? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 
1.3 Data Analysis and Graphics Using R – An Introduction (109 pages) . . . . . 4 
1.4 CRAN Task View: Empirical Finance . . . . . . . . . . . . . . . . . . . . . . 4 
1.5 CRAN Task View: Computational Econometrics . . . . . . . . . . . . . . . . 8 
2 Characteristics of Time Series 15 
2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 
2.2 Stationary Time Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 
2.2.1 Detrending . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 
2.2.2 Differencing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 
2.2.3 Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 
2.2.4 Linear Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 
2.3 Other Key Features of Time Series . . . . . . . . . . . . . . . . . . . . . . . 30 
2.3.1 Seasonality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 
2.3.2 Aberrant Observations . . . . . . . . . . . . . . . . . . . . . . . . . . 33 
2.3.3 Conditional Heteroskedasticity . . . . . . . . . . . . . . . . . . . . . . 34 
2.3.4 Nonlinearity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 
2.4 Time Series Relationships . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 
2.4.1 Autocorrelation Function . . . . . . . . . . . . . . . . . . . . . . . . . 39 
2.4.2 Cross Correlation Function . . . . . . . . . . . . . . . . . . . . . . . . 40 
2.4.3 Partial Autocorrelation Function . . . . . . . . . . . . . . . . . . . . 45 
2.5 Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 
2.6 Computer Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 
2.7 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 
3 Univariate Time Series Models 69 
3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 
3.2 Least Squares Regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 
3.3 Model Selection Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 
3.3.1 Subset Approaches . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 
3.3.2 Sequential Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 
3.3.3 Likelihood Based-Criteria . . . . . . . . . . . . . . . . . . . . . . . . 85 
3.3.4 Cross-Validation and Generalized Cross-Validation . . . . . . . . . . 87 
ii 
CONTENTS iii 
3.3.5 Penalized Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 
3.4 Integrated Models - I(1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 
3.5 Autoregressive Models - AR(p) . . . . . . . . . . . . . . . . . . . . . . . . . 93 
3.5.1 Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 
3.5.2 Forecasting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 
3.6 Moving Average Models – MA(q) . . . . . . . . . . . . . . . . . . . . . . . . 102 
3.7 Autoregressive Integrated Moving Average Model - ARIMA(p, d, q) . . . . . 106 
3.8 Seasonal ARIMA Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 
3.9 Regression Models With Correlated Errors . . . . . . . . . . . . . . . . . . . 120 
3.10 Estimation of Covariance Matrix . . . . . . . . . . . . . . . . . . . . . . . . 130 
3.11 Long Memory Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 
3.12 Periodicity and Business Cycles . . . . . . . . . . . . . . . . . . . . . . . . . 136 
3.13 Impulse Response Function . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 
3.13.1 First Order Difference Equations . . . . . . . . . . . . . . . . . . . . 142 
3.13.2 Higher Order Difference Equations . . . . . . . . . . . . . . . . . . . 146 
3.14 Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 
3.15 Computer Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 
3.16 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 
4 Non-stationary Processes and Structural Breaks 185 
4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 
4.2 Random Walks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 
4.2.1 Inappropriate Detrending . . . . . . . . . . . . . . . . . . . . . . . . 189 
4.2.2 Spurious (nonsense) Regressions . . . . . . . . . . . . . . . . . . . . . 190 
4.3 Unit Root and Stationary Processes . . . . . . . . . . . . . . . . . . . . . . . 190 
4.3.1 Comparison of Forecasts of TS and DS Processes . . . . . . . . . . . 191 
4.3.2 Random Walk Components and Stochastic Trends . . . . . . . . . . . 193 
4.4 Trend Estimation and Forecasting . . . . . . . . . . . . . . . . . . . . . . . . 194 
4.4.1 Forecasting a Deterministic Trend . . . . . . . . . . . . . . . . . . . . 194 
4.4.2 Forecasting a Stochastic Trend . . . . . . . . . . . . . . . . . . . . . . 195 
4.4.3 Forecasting ARMA models with Deterministic Trends . . . . . . . . . 195 
4.4.4 Forecasting of ARIMA Models . . . . . . . . . . . . . . . . . . . . . . 196 
4.5 Unit Root Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 
4.5.1 The Dickey-Fuller and Augmented Dickey-Fuller Tests . . . . . . . . 197 
4.5.2 Cautions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 
4.6 Structural Breaks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 
4.6.1 Testing for Breaks . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 
4.6.2 Zivot and Andrews’s Testing Procedure . . . . . . . . . . . . . . . . . 203 
4.6.3 Cautions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 
4.7 Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 
4.8 Computer Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 
4.9 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 
CONTENTS iv 
5 Vector Autoregressive Models 215 
5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 
5.1.1 Properties of VAR Models . . . . . . . . . . . . . . . . . . . . . . . . 218 
5.1.2 Statistical Inferences . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 
5.2 Impulse-Response Function . . . . . . . . . . . . . . . . . . . . . . . . . . . 222 
5.3 Variance Decompositions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 
5.4 Granger Causality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 
5.5 Forecasting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 
5.6 Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 
5.7 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 
6 Cointegration 234 
6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234 
6.2 Cointegrating Regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235 
6.3 Testing for Cointegration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236 
6.4 Cointegrated VAR Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239 
6.5 Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 
6.6 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 
7 Nonparametric Density, Distribution & Quantile Estimation 244 
7.1 Mixing Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244 
7.2 Density Estimate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 
7.2.1 Asymptotic Properties . . . . . . . . . . . . . . . . . . . . . . . . . . 246 
7.2.2 Optimality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 
7.2.3 Boundary Correction . . . . . . . . . . . . . . . . . . . . . . . . . . . 251 
7.3 Distribution Estimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254 
7.3.1 Smoothed Distribution Estimation . . . . . . . . . . . . . . . . . . . 254 
7.3.2 Relative Efficiency and Deficiency . . . . . . . . . . . . . . . . . . . . 257 
7.4 Quantile Estimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 
7.4.1 Value at Risk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 
7.4.2 Nonparametric Quantile Estimation . . . . . . . . . . . . . . . . . . . 260 
7.5 Computer Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 
7.6 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264 
8 Nonparametric Regression Estimation 267 
8.1 Bandwidth Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267 
8.1.1 Simple Bandwidth Selectors . . . . . . . . . . . . . . . . . . . . . . . 267 
8.1.2 Cross-Validation Method . . . . . . . . . . . . . . . . . . . . . . . . . 268 
8.2 Multivariate Density Estimation . . . . . . . . . . . . . . . . . . . . . . . . . 270 
8.3 Regression Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271 
8.4 Kernel Estimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 
8.4.1 Asymptotic Properties . . . . . . . . . . . . . . . . . . . . . . . . . . 274 
8.4.2 Boundary Behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277 
8.5 Local Polynomial Estimate . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279 
8.5.1 Formulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279 
CONTENTS v 
8.5.2 Implementation in R . . . . . . . . . . . . . . . . . . . . . . . . . . . 280 
8.5.3 Complexity of Local Polynomial Estimator . . . . . . . . . . . . . . . 281 
8.5.4 Properties of Local Polynomial Estimator . . . . . . . . . . . . . . . 284 
8.5.5 Bandwidth Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 
8.6 Functional Coefficient Model . . . . . . . . . . . . . . . . . . . . . . . . . . . 292 
8.6.1 Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292 
8.6.2 Local Linear Estimation . . . . . . . . . . . . . . . . . . . . . . . . . 293 
8.6.3 Bandwidth Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . 294 
8.6.4 Smoothing Variable Selection . . . . . . . . . . . . . . . . . . . . . . 296 
8.6.5 Goodness-of-Fit Test . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 
8.6.6 Asymptotic Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299 
8.6.7 Conditions and Proofs . . . . . . . . . . . . . . . . . . . . . . . . . . 301 
8.6.8 Monte Carlo Simulations and Applications . . . . . . . . . . . . . . . 311 
8.7 Additive Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311 
8.7.1 Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311 
8.7.2 Backfitting Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . 315 
8.7.3 Projection Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317 
8.7.4 Two-Stage Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . 319 
8.7.5 Monte Carlo Simulations and Applications . . . . . . . . . . . . . . . 322 
8.8 Computer Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322 
8.9 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326 
   |