These Lecture series are relating the use R language software, its interface and functions required to evaluate financial risk models. Furthermore, R software applications relating financial market data, measuring risk, modern portfolio theory, risk modeling relating returns generalized hyperbolic and lambda distributions, Value at Risk (VaR) modelling, extreme value methods and models, the class of ARCH models, GARCH risk models and portfolio optimization approaches.
2. 2
TOPICS
In this lecture, we will cover the following topics:
6. Suitable Distributions for Returns
i. Preliminaries
ii. The generalized Hyperbolic Distribution
iii. The generalized Lambda Distribution
iv. Synopsis of R packages for GHD
a. The Package fBasics
b. The Package GeneralizedHyperbolic
c. The Package ghyp
d. The Package QRM
e. The Package SkewHyperbolic
f. The Package VarianceGamma
3. 3
TOPICS
v. Synopsis of R packages for GLD
i. The Package Davies
ii. The Package fBasics
iii. The Package gld
iv. The Package Imomco
vi. Applications of the GHD to Risk
Modelling
i. Fitting Stock Returns to the GHD
ii. Risk Assessment with the GHD
iii. Stylized facts revisited
vii. Applications of the GLD to Risk
Modelling and Data Analysis
i. VaR for a Single Stock
ii. Shape Triangle for FTSE 100 Constituents
4. 4
PRELIMINARIES
We have learned earlier that risk measures like
VaR and ES are quantile values located in the
left tail of a distribution.
Given the stylized facts of empirical return
series, it would therefore suffice to capture the
tail probabilities adequately.
5. 5
PRELIMINARIES
The need often arises to model not just the tail
behavior of the losses, but the entire return
distribution.
Therefore, the topic of this chapter is the
presentation of distribution classes that allow
returns to be modelled in their entirety, thereby
acknowledging the stylized facts.
Such a distribution should be capable of mirroring
not only heavy-tail behavior but also asymmetries.
6. 6
PRELIMINARIES
Therefore, the classes of the generalized hyperbolic
distribution (GHD) and its special cases, namely the
hyperbolic (HYP) and normal inverse Gaussian
(NIG) distributions, as well as the generalized
lambda distribution (GLD) will be introduced in this
lecture.
A synopsis of available R packages relating
applications of the GHD and GLD to financial
market data will be done accordingly using R
software.
7. 7
THE GENERALIZED HYPERBOLIC
DISTRIBUTION
The GHD was introduced into the literature by
Barndorff-Nielsen (1977).
The application of this distribution to the increments
of financial market price processes was probably
first proposed by Eberlein and Keller (1995).
Further contributions followed in which this
distribution class was applied to financial market
data (multiple authors worked on it).
11. 11
THE GENERALIZED HYPERBOLIC
DISTRIBUTION
It is possible to capture not only semi-strong tails
(i.e., with a kurtosis greater than 3), but also skewed
distributions.
From an intuitive point of view it should be
reasonable to expect that multiple distributions
could be derives from GHD applications using risk
management financial data.
19. 19
THE GENERALIZED LAMBDA DISTRIBUTION
Various estimation methods for finding optimal
values for the parameter vector 𝛌 have been
proposed in the literature. Among these are
1. The moment-matching approach
2. The percentile-based approach
3. The histogram-based approach
4. The goodness-of-fit approach
5. Maximum likelihood and maximum product
spacing.
20. 20
SYNOPSIS OF R PACKAGES
The package fBasics: The package fBasics is part of
the Rmetrics suite of packages (seeWürtz et al. 2014).
The primary purpose of this package is to provide basic
tools for the statistical analysis of financial market data.
Within the package S4 classes and methods are utilized.
The package is considered a core package in the CRAN
“Finance” Task View and is also listed in the
“Distributions” Task View.
21. 21
SYNOPSIS OF R PACKAGES
The package GeneralizedHyperbolic: This
package offers functions not only for the GHD, but
also for the derived distributions HYP, GIG, and
skew Laplace (see Scott 2015).
The package is written purely in R.
A NAMESPACE file is included in the package’s
source that contains the export directives for the
functions and S3 methods pertinent to the above-
mentioned distributions.
Some of the routines contained in this package have
been ported to fBasics.
22. 22
SYNOPSIS OF R PACKAGES
The package ghyp: In contrast to the previous
package, ghyp provides functions for fitting not
only the univariate HYP, but also the GHD, NIG,
VG, Student’s t, and Gaussian distributions for the
univariate and multivariate cases (see Luethi and
Breymann 2013).
The package
utilizes S4 classes and methods and is shipped with
a NAMESPACE file. It is contained in the CRAN
“Distributions” and “Finance” Task Views.
23. 23
SYNOPSIS OF R PACKAGES
The package QRM: Most of the examples
contained in McNeil et al. (2005) can be replicated
with the functions contained in the package QRM
(see Pfaff and McNeil 2016).
These were originally written in the S-PLUS
language by A. McNeil and distributed as package
QRMlib.
An initial R port was accomplished by S. Ulman
and is still available from the CRAN archive (see
McNeil and Ulman 2011).
The package QRM is based on this initial R port. It
has dependencies on the CRAN packages gsl,
mvtnorm, numDeriv, and timeSeries.
24. 24
SYNOPSIS OF R PACKAGES
The package SkewHyperbolic: The package
SkewHyperbolic is dedicated solely to the modelling
and fitting of the skew hyperbolic Student’s t
distribution (see Scott and Grimson 2015).
The package is written purely in R, and S3 classes and
methods are used.
It is shipped with a NAMESPACE file, and some
underlying utility functions are imported from the
packages GeneralizedHyperbolic and
DistributionUtils.
25. 25
SYNOPSIS OF R PACKAGES
The package VarianceGamma: The package
VarianceGamma can be considered as a twin
package to the SkewHyperbolic package discussed
in the previous subsection, but its focus is on the
variance gamma distribution (see Scott and Dong
2015).
As its twin, the package is contained in the CRAN
“Distributions” Task View.
26. 26
SYNOPSIS OF R PACKAGES
The package Davies: Even though the focus of the package
Davies is an implementation of the Davies quantile function
(see Hankin and Lee 2006), R routines that address the GLD
distribution are also included.
The package is listed in the CRAN “Distributions” Task
View.
The package is shipped with a NAMESPACE file, but neither
S3 nor S4 classes/ methods are employed.
Hence, in addition to two data sets, the package offers a
collection of functions for dealing with these two kinds of
distributions.
27. 27
SYNOPSIS OF R PACKAGES
The package gld: The package gld is, to the
author’s knowledge, the only one that implements
all three GLD specifications: RS, FMKL, and FM5
(see King et al. 2016).
The latter is an extension of the FMKL version in
which a fifth parameter is included in order to
explicitly capture the skewness of the data.
28. 28
SYNOPSIS OF R PACKAGES
The package lmomco: Estimation methods based on L-
moments for various distributions are implemented in
the package lmomco (see Asquith 2016).
Here we will concentrate on those tools
that directly address the GLD.
The package is considered to be a core package in the
CRAN “Distributions” Task View.
The package is quite huge, judged by the size of its
manual, which runs to more than 500 pages.
34. 34
RISK ASSESSMENT WITH THE GHD
The behavior of the VaR and ES risk measures according to
each of the models is investigated. In particular, the two risks
measures are derived from the fitted GHD, HYP, and NIG
distributions for the HWP returns from the previous
subsection.
These measures are calculated over a span from the 95.0% to
the 99.9% levels.
The resulting trajectories of the VaR and ES are then
compared to their empirical counterparts. For the ES the
mean of the lower quintile values is used.