# An Introduction to Analysis of Financial Data with R

## Books

A complete set of statistical tools for beginning financial analysts from a leading authority

Written by one of the leading experts on the topic, An Introduction to Analysis of Financial Data with R explores basic concepts of visualization of financial data. Through a fundamental balance between theory and applications, the book supplies readers with an accessible approach to financial econometric models and their applications to real-world empirical research.

The author supplies a hands-on introduction to the analysis of financial data using the freely available R software package and case studies to illustrate actual implementations of the discussed methods. The book begins with the basics of financial data, discussing their summary statistics and related visualization methods. Subsequent chapters explore basic time series analysis and simple econometric models for business, finance, and economics as well as related topics including:

• Linear time series analysis, with coverage of exponential smoothing for forecasting and methods for model comparison
• Different approaches to calculating asset volatility and various volatility models
• High-frequency financial data and simple models for price changes, trading intensity, and realized volatility
• Quantitative methods for risk management, including value at risk and conditional value at risk
• Econometric and statistical methods for risk assessment based on extreme value theory and quantile regression

Throughout the book, the visual nature of the topic is showcased through graphical representations in R, and two detailed case studies demonstrate the relevance of statistics in finance. A related website features additional data sets and R scripts so readers can create their own simulations and test their comprehension of the presented techniques.

An Introduction to Analysis of Financial Data with R is an excellent book for introductory courses on time series and business statistics at the upper-undergraduate and graduate level. The book is also an excellent resource for researchers and practitioners in the fields of business, finance, and economics who would like to enhance their understanding of financial data and today's financial markets.

Preface xiii

1 FINANCIAL DATA AND THEIR PROPERTIES 1

1.1 Asset Returns 2

1.2 Bond Yields and Prices 7

1.3 Implied Volatility 10

1.4 R Packages and Demonstrations 12

1.4.1 Installation of R Packages 12

1.4.2 The Quantmod Package 12

1.4.3 Some Basic R Commands 16

1.5 Examples of Financial Data 17

1.6 Distributional Properties of Returns 20

1.6.1 Review of Statistical Distributions and Their Moments 20

1.7 Visualization of Financial Data 27

1.8 Some Statistical Distributions 32

1.8.1 Normal Distribution 32

1.8.2 Lognormal Distribution 32

1.8.3 Stable Distribution 33

1.8.4 Scale Mixture of Normal Distributions 33

1.8.5 Multivariate Returns 34

Exercises 36

References 37

2 LINEAR MODELS FOR FINANCIAL TIME SERIES 39

2.1 Stationarity 40

2.2 Correlation and Autocorrelation Function 43

2.3 White Noise and Linear Time Series 50

2.4 Simple Autoregressive Models 51

2.4.1 Properties of AR Models 52

2.4.2 Identifying AR Models in Practice 60

2.4.3 Goodness of Fit 67

2.4.4 Forecasting 67

2.5 Simple Moving Average Models 69

2.5.1 Properties of MA Models 72

2.5.2 Identifying MA Order 73

2.5.3 Estimation 74

2.5.4 Forecasting Using MA Models 75

2.6 Simple ARMA Models 78

2.6.1 Properties of ARMA(1,1) Models 79

2.6.2 General ARMA Models 80

2.6.3 Identifying ARMA Models 81

2.6.4 Forecasting Using an ARMA Model 84

2.6.5 Three Model Representations for an ARMA Model 84

2.7 Unit-Root Nonstationarity 86

2.7.1 Random Walk 86

2.7.2 Random Walk with Drift 88

2.7.3 Trend-Stationary Time Series 90

2.7.4 General Unit-Root Nonstationary Models 91

2.7.5 Unit-Root Test 91

2.8 Exponential Smoothing 96

2.9 Seasonal Models 98

2.9.1 Seasonal Differencing 99

2.9.2 Multiplicative Seasonal Models 101

2.9.3 Seasonal Dummy Variable 107

2.10 Regression Models with Time Series Errors 110

2.11 Long-Memory Models 117

2.12 Model Comparison and Averaging 120

2.12.1 In-sample Comparison 120

2.12.2 Out-of-sample Comparison 121

2.12.3 Model Averaging 125

Exercises 125

References 127

3 CASE STUDIES OF LINEAR TIME SERIES 128

3.1 Weekly Regular Gasoline Price 129

3.1.1 Pure Time Series Model 130

3.1.2 Use of Crude Oil Prices 133

3.1.3 Use of Lagged Crude Oil Prices 134

3.1.4 Out-of-Sample Predictions 135

3.2 Global Temperature Anomalies 140

3.2.1 Unit-Root Stationarity 141

3.2.2 Trend-Nonstationarity 145

3.2.3 Model Comparison 148

3.2.4 Long-Term Prediction 150

3.2.5 Discussion 153

3.3 US Monthly Unemployment Rates 157

3.3.1 Univariate Time Series Models 157

3.3.2 An Alternative Model 161

3.3.3 Model Comparison 165

3.3.4 Use of Initial Jobless Claims 165

3.3.5 Comparison 173

Exercises 174

References 175

4 ASSET VOLATILITY AND VOLATILITY MODELS 176

4.1 Characteristics of Volatility 177

4.2 Structure of a Model 178

4.3 Model Building 181

4.4 Testing for ARCH Effect 182

4.5 The ARCH Model 185

4.5.1 Properties of ARCH Models 186

4.5.2 Advantages and Weaknesses of ARCH Models 187

4.5.3 Building an ARCH Model 188

4.5.4 Some Examples 193

4.6 The GARCH Model 199

4.6.1 An Illustrative Example 201

4.6.2 Forecasting Evaluation 210

4.6.3 A Two-Pass Estimation Method 210

4.7 The Integrated GARCH Model 211

4.8 The GARCH-M Model 213

4.9 The Exponential Garch Model 215

4.9.1 An Illustrative Example 217

4.9.2 An Alternative Model Form 218

4.9.3 Second Example 218

4.9.4 Forecasting Using an EGARCH Model 220

4.10 The Threshold Garch Model 222

4.11 Asymmetric Power ARCH Models 224

4.12 Nonsymmetric GARCH Model 226

4.13 The Stochastic Volatility Model 228

4.14 Long-Memory Stochastic Volatility Models 230

4.15 Alternative Approaches 232

4.15.1 Use of High Frequency Data 232

4.15.2 Use of Daily Open, High, Low, and Close Prices 235

Exercises 239

References 241

5 APPLICATIONS OF VOLATILITY MODELS 243

5.1 Garch Volatility Term Structure 244

5.1.1 Term Structure 246

5.2 Option Pricing and Hedging 248

5.3 Time-Varying Correlations and Betas 251

5.3.1 Time-Varying Betas 256

5.4 Minimum Variance Portfolios 259

5.5 Prediction 263

Exercises 271

References 272

6 HIGH FREQUENCY FINANCIAL DATA 274

6.1 Nonsynchronous Trading 275

6.3 Empirical Characteristics of Trading Data 282

6.4 Models for Price Changes 285

6.4.1 Ordered Probit Model 288

6.4.2 A Decomposition Model 293

6.5 Duration Models 298

6.5.1 Diurnal Component 299

6.5.2 The ACD Model 301

6.5.3 Estimation 303

6.6 Realized Volatility 308

6.6.1 Handling Microstructure Noises 313

6.6.2 Discussion 317

Appendix A: Some Probability Distributions 320

Appendix B: Hazard Function 323

Exercises 324

References 325

7 VALUE AT RISK 327

7.1 Risk Measure and Coherence 328

7.1.1 Value at Risk (VaR) 329

7.1.2 Expected Shortfall 334

7.2 Remarks on Calculating Risk Measures 336

7.3 Riskmetrics 337

7.3.1 Discussion 342

7.3.2 Multiple Positions 343

7.4 An Econometric Approach 345

7.4.1 Multiple Periods 348

7.5 Quantile Estimation 352

7.5.1 Quantile and Order Statistics 353

7.5.2 Quantile Regression 354

7.6 Extreme Value Theory 358

7.6.1 Review of Extreme Value Theory 358

7.6.2 Empirical Estimation 361

7.6.3 Application to Stock Returns 363

7.7 An Extreme Value Approach to Var 368

7.7.1 Discussion 370

7.7.2 Multiperiod VaR 371

7.7.3 Return Level 371

7.8 Peaks Over Thresholds 372

7.8.1 Statistical Theory 373

7.8.2 Mean Excess Function 374

7.8.3 Estimation 376

7.8.4 An Alternative Parameterization 378

7.9 The Stationary Loss Processes 381

Exercises 383

References 384

Index 387

View all

View all