Learn R Programming

ghyp (version 1.6.5)

ghyp-package: A package on the generalized hyperbolic distribution and its special cases

Description

This package provides detailed functionality for working with the univariate and multivariate Generalized Hyperbolic distribution and its special cases (Hyperbolic (hyp), Normal Inverse Gaussian (NIG), Variance Gamma (VG), skewed Student-t and Gaussian distribution). Especially, it contains fitting procedures, an AIC-based model selection routine, and functions for the computation of density, quantile, probability, random variates, expected shortfall and some portfolio optimization and plotting routines as well as the likelihood ratio test. In addition, it contains the Generalized Inverse Gaussian distribution.

Arguments

Existing solutions

There are packages like GeneralizedHyperbolic, HyperbolicDist, SkewHyperbolic, VarianceGamma and fBasics which cover the univariate generalized hyperbolic distribution and/or some of its special cases. However, the univariate case is contained in this package as well because we aim to provide a uniform interface to deal with generalized hyperbolic distribution. Recently an R port of the S-Plus library QRMlib was released. The package QRMlib contains fitting procedures for the multivariate NIG, hyp and skewed Student-t distribution but not for the generalized hyperbolic case. The package fMultivar implements a fitting routine for multivariate skewed Student-t distributions as well.

Object orientation

We follow an object-oriented programming approach in this package and introduce distribution objects. There are mainly four reasons for that:

  • Unlike most distributions the GH distribution has quite a few parameters which have to fulfill some consistency requirements. Consistency checks can be performed uniquely when an object is initialized.

  • Once initialized the common functions belonging to a distribution can be called conveniently by passing the distribution object. A repeated input of the parameters is avoided.

  • Distributions returned from fitting procedures can be directly passed to, e.g., the density function since fitted distribution objects add information to the distribution object and consequently inherit from the class of the distribution object.

  • Generic method dispatching can be used to provide a uniform interface to, e.g., plot the probability density of a specific distribution like plot(distribution.object). Additionally, one can take advantage of generic programming since R provides virtual classes and some forms of polymorphism.

Acknowledgement

This package has been partially developed in the framework of the COST-P10 “Physics of Risk” project. Financial support by the Swiss State Secretariat for Education and Research (SBF) is gratefully acknowledged.

Author

David Luethi, Wolfgang Breymann

Institute of Data Analyses and Process Design (https://www.zhaw.ch/en/engineering/institutes-centres/idp/groups/data-analysis-and-statistics/)

Maintainer: Marc Weibel <marc.weibel@quantsulting.ch>

Details

Initialize:

ghypInitialize a generalized hyperbolic distribution.
hypInitialize a hyperbolic distribution.
NIGInitialize a normal inverse gaussian distribution.
VGInitialize a variance gamma distribution.
student.tInitialize a Student-t distribution.
gaussInitialize a Gaussian distribution.

Density, distribution function, quantile function and random generation:

dghypDensity of a generalized hyperbolic distribution.
pghypDistribution function of a generalized hyperbolic distribution.
qghypQuantile of a univariate generalized hyperbolic distribution.
rghypRandom generation of a generalized hyperbolic distribution.

Fit to data:

fit.ghypuvFit a generalized hyperbolic distribution to univariate data.
fit.hypuvFit a hyperbolic distribution to univariate data.
fit.NIGuvFit a normal inverse gaussian distribution to univariate data.
fit.VGuvFit a variance gamma distribution to univariate data.
fit.tuvFit a skewed Student-t distribution to univariate data.
fit.gaussuvFit a Gaussian distribution to univariate data.
fit.ghypmvFit a generalized hyperbolic distribution to multivariate data.
fit.hypmvFit a hyperbolic distribution to multivariate data.
fit.NIGmvFit a normal inverse gaussian distribution to multivariate data.
fit.VGmvFit a variance gamma distribution to multivariate data.
fit.tmvFit a skewed Student-t distribution to multivariate data.
fit.gaussmvFit a Gaussian distribution to multivariate data.
stepAIC.ghypPerform a model selection based on the AIC.

Risk, performance and portfolio optimization:

ESghypExpected shortfall of a univariate generalized hyperbolic distribution.
ghyp.omegaPerformance measure Omega based on a univariate ghyp distribution.
portfolio.optimizeCalculate optimal portfolios with respect to alternative risk measures.

Utilities:

meanReturns the expected value.
vcovReturns the variance(-covariance).
ghyp.skewnessSkewness of a univariate ghyp distribution.
ghyp.kurtosisKurtosis of a univariate ghyp distribution.
logLikReturns Log-Likelihood of fitted ghyp objects.
AICReturns the Akaike's Information Criterion of fitted ghyp objects.
lik.ratio.testPerforms a likelihood-ratio test on fitted ghyp distributions.
[Extract certain dimensions of a multivariate ghyp distribution.
scaleScale ghyp distribution objects to zero expectation and/or unit variance.
transformTransform a multivariate generalized hyperbolic distribution.
ghyp.momentMoments of the univariate ghyp distribution.
coefParameters of a generalized hyperbolic distribution.
ghyp.dataData of a (fitted) generalized hyperbolic distribution.
ghyp.fit.infoInformation about the fitting procedure, log-likelihood and AIC value.
ghyp.nameReturns the name of the ghyp distribution or a subclass of it.
ghyp.dimReturns the dimension of a ghyp object.
summarySummary of a fitted generalized hyperbolic distribution.

Plot functions:

qqghypPerform a quantile-quantile plot of a (fitted) univariate ghyp distribution.
histPlot a histogram of a (fitted) univariate generalized hyperbolic distribution.
pairsProduce a matrix of scatterplots with quantile-quantile plots on the diagonal.
plotPlot the density of a univariate ghyp distribution.
linesAdd the density of a univariate ghyp distribution to a graphics device.

Generalized inverse gaussian distribution:

dgigDensity of a generalized inverse gaussian distribution
pgigDistribution function of a generalized inverse gaussian distribution
qgigQuantile of a generalized inverse gaussian distribution
ESgigExpected shortfall of a generalized inverse gaussian distribution
rgigRandom generation of a generalized inverse gaussian distribution

Package vignette:
A document about generalized hyperbolic distributions can be found in the doc folder of this package or on https://cran.r-project.org/package=ghyp.

References

Quantitative Risk Management: Concepts, Techniques and Tools by Alexander J. McNeil, Ruediger Frey and Paul Embrechts
Princeton Press, 2005

Intermediate probability: A computational approach by Marc Paolella
Wiley, 2007

S-Plus and R Library for Quantitative Risk Management QRMlib by Alexander J. McNeil (2005) and Scott Ulman (R-port) (2007)