The Generalised Hyperbolic distribution is a normal variance-mean mixture distribution where the mixing density is the generalised inverse Gaussian distribution. This distribution contains a skewness and a tail parameter, and it has been employed in financial applications and for modelling particle sizes. The shape parameters (skewness and kurtosis) of this distribution, being a member of the family of the generalysed hyperbolic family, tend to be difficult to estimate. One way to alleviate this problem consists of fixing the skewness parameter to zero, and to alternatively induce asymmetry by using the two-piece construction, since the skewness parameter in this family is easy to estimate. The implementation of the two-piece Generalised Hyperbolic distribution is simple by combining the R packages ‘twopiece’ and ‘ghyp’. The extension to the Double two-piece Generalised Hyperbolic distribution is also simple using the ‘DTP’ R package, as shown in the R code below.
References.
Inference in Two-Piece Location-Scale Models with Jeffreys Priors.
Bayesian modelling of skewness and kurtosis with Two-Piece Scale and shape distributions.
Exponentially decreasing distributions for the logarithm of particle size.
See also: Two-piece Variance Gamma distribution.
rm(list=ls())
# Required packages
library(ghyp)
## Loading required package: numDeriv
## Loading required package: gplots
##
## Attaching package: 'gplots'
## The following object is masked from 'package:stats':
##
## lowess
library(twopiece)
## Loading required package: flexclust
## Loading required package: grid
## Loading required package: lattice
## Loading required package: modeltools
## Loading required package: stats4
## Loading required package: mvtnorm
## Loading required package: label.switching
library(DTP)
############################################################################################################
# Symmetric Generalised Hyperbolic distribution with location zero and scale 1 and kurtosis parameter delta
############################################################################################################
# Define the kurtosis parameter to be controlled (lambda,chi,psi). The rest are fixed at the default values
# specified in ghyp()
# default value of the kurtosis parameter
delta0 <- 0.5
uni.ghyp <- ghyp()
dghyp1 = function(x,delta=delta0,log=FALSE){
uni.ghyp@lambda = delta # specify accordingly (lambda,chi,psi).
logPDF <- dghyp(x, object=uni.ghyp, logvalue = TRUE)
ifelse(is.numeric(logPDF), ifelse(log, return(logPDF), return(exp(logPDF))),
logPDF)
}
# Plot of this density for delta = 0.5, 1.25.
tempf1 = Vectorize(function(x) dghyp1(x,0.5))
tempf2 = Vectorize(function(x) dghyp1(x,1.25))
curve(tempf1,-5,5,n=1000,ylim=c(0,0.6),lwd=2,lty=1)
curve(tempf2,-5,5,n=1000,add=T,lwd=2,lty=2)
###################################################################################################
# Two-piece Generalised Hyperbolic distribution with the epsilon-skew parameterisation
###################################################################################################
# Example 1
skewness = 0.5
kurtosis = 0.5
dtpvg= Vectorize(function(x) dtp4(x,0,1,skewness,kurtosis,FUN=dghyp1,param="eps"))
curve(dtpvg,-5,5,n=1000,lwd=2)
# Example 2
skewness = 0.5
kurtosis = 1.25
dtpvg= Vectorize(function(x) dtp4(x,0,1,skewness,kurtosis,FUN=dghyp1,param="eps"))
curve(dtpvg,-5,5,n=1000,lwd=2)
###################################################################################################
# Double two-piece Generalised Hyperbolic distribution with the epsilon-skew parameterisation
###################################################################################################
# Example 1
skewness = 0.5
kurtosis1 = 0.5
kurtosis2 = 1.25
dtp2vg= Vectorize(function(x) ddtp(x,0,1,skewness,kurtosis1,kurtosis2,f=dghyp1,param="eps"))
curve(dtp2vg,-5,5,n=1000,lwd=2)
# Example 2
skewness = 0.5
kurtosis1 = 1.25
kurtosis2 = 0.5
dtp2vg= Vectorize(function(x) ddtp(x,0,1,skewness,kurtosis1,kurtosis2,f=dghyp1,param="eps"))
curve(dtp2vg,-5,5,n=1000,lwd=2)