R Notes for QRM
Preface
1
An introduction to R programming
1.1
An introduction to R programming
1.1.1
Simple manipulations; numbers and vectors
1.1.2
Arrays and matrices
1.1.3
Lists (including data frames)
1.1.4
Statistical functionality
1.1.5
Random number generation
1.1.6
Control statements
1.1.7
Working with additional packages
1.1.8
Writing functions
1.1.9
Misc
1.2
Evaluating
\(e^x-1\)
1.2.1
Setup
1.2.2
Investigating
exp(x)-1
vs
expm1(x)
1.2.3
Illustrating how
expm1(x)
works
2
Basic Concepts in Risk Management
2.1
Review
2.1.1
Notations
2.1.2
Value-at-Risk (VaR)
2.1.3
Expected Shortfall (ES)
2.2
VaR and ES tail comparison for normal and
\(t\)
loss distriubion
2.2.1
Setup
2.2.2
Auxiliary computations
2.2.3
Plot
2.2.4
Results
2.3
Nonparametric VaR and ES estimators
2.3.1
Setup
2.3.2
Auxiliary functions
2.3.3
Simulate losses and nonparametrically estimate VaR and ES
2.3.4
Bootstrapping confidence intervals for
\(\text{VaR}_\alpha\)
,
\(\text{ES}_\alpha\)
2.3.5
Plots
2.3.6
Results
2.4
Exercises
3
Empirical Properties of Financial Data
3.1
Exploring financial time series
3.1.1
Stock prices
3.1.2
Stock indexes
3.1.3
Exchange rates
3.1.4
Zero-coupon bond yields
3.2
Ljung-Box test of serial independence
3.2.1
Constituent data
3.2.2
Ljung-Box tests of serial independence of stationary data
3.2.3
Reproduce Ljung-Box tests from the QRM book
3.3
Univariate stylized facts
3.3.1
Index data
3.3.2
(U1) and (U2)
3.3.3
(U3) and (U4)
3.3.4
(U5)
3.3.5
(U6)
3.4
Testing univariate normality
3.4.1
Generate data
3.4.2
Testing for
\(\mathcal{N}(\mu, \sigma^2)\)
3.4.3
Data application
3.4.4
Simulation
3.5
Multivariate stylized facts
3.5.1
Index data
3.5.2
(M1) and (M2)
3.5.3
(M3)
3.5.4
(M4)
4
Financial Time Series
4.1
Review
4.1.1
Models for the conditional mean
4.1.2
ARCH (autoregressive conditionally heteroscedastic) process
4.1.3
GARCH (generalized ARCH) process
4.2
GARCH simulation
4.2.1
Specify the
\(\text{GARCH}(1,1)\)
model
4.2.2
Generate paths from a specified model
4.2.3
Plotting
uGARCHpath
objects
4.2.4
Does the simulated series conform to our univariate stylized facts?
4.3
GARCH estimation
4.3.1
S&P 500 data
4.3.2
Fit an
\(\text{AR}(1)\text{-}\text{GARCH}(1,1)\)
model with normal innovations
4.3.3
Fit an
\(\text{AR}(1)\text{-}\text{GARCH}(1,1)\)
model with Student
\(t\)
innovations
4.3.4
Likelihood-ratio test for comparing the two models
4.3.5
Using Akaike’s information criterion to compare the two models
4.3.6
Exploring the structure of the fitted model object
4.3.7
Forecasting/predicting from the fitted model
4.4
Simulate fit predict VaR under ARMA GARCH
4.4.1
Simulation
4.4.2
Fitting and checks
4.4.3
VaR estimates, checks and backtest
4.4.4
Backtest VaR estimates
4.4.5
Predict (
\(X_t\)
) and
\(\text{VaR}_\alpha\)
4.4.6
Simulate
\(B\)
paths from the fitted model
4.4.7
Plot
4.5
Exercises
5
Extreme Value Theory
6
Multivariate Models
6.1
Constructing and sampling multivariate distributions
6.1.1
Basic ‘ingredients’
6.1.2
Sampling from the multivariate normal distribution
6.1.3
Sampling from the multiv.
\(t\)
distribution (and other normal variance mixtures)
6.2
Fitting a multivariate normal and
\(t\)
6.3
Testing multivariate normality
6.3.1
Generate data
6.3.2
Testing for
\(\mathcal{N}(\boldsymbol{\mu}, \Sigma)\)
6.3.3
For
\(\mathcal{N}(\boldsymbol{\mu}, \Sigma)\)
data
6.3.4
For
\(t_d(\nu, \boldsymbol{\mu}, \Sigma)\)
data
6.3.5
For
\(t_d(\nu, 0, P)\)
dependence but
\(\mathcal{N}(0, 1)\)
margins
7
Copulas and Dependence
8
Aggregate Risk
9
Market Risk
9.1
Standard methods for market risk
9.1.1
Working with the (BMW, Siemens) data
9.2
Implement (and document) some auxiliary functions
9.3
Graphical analysis
9.4
Backtesting
9.4.1
Backtesting Section
10
Multivariate Time Series
Published with bookdown
R Notes for QRM
Chapter 7
Copulas and Dependence