[R-SIG-Finance] Antwort: Re: Generating Distributions with set skewness and kurtosis

Matthias.Koberstein at hsbctrinkaus.de Matthias.Koberstein at hsbctrinkaus.de
Wed Aug 27 08:51:26 CEST 2008


thank you very much for your help on this topic. It is really appreciated.
There have been some great replies and I guess it will take me some time to
go through all the implementation options given by you guys.
Thanks again


P.S.:       I was aware of the fact that the normal distribution has a
fixed skew and kurtosis (therefore I wrote "normal" ;))
      I just wanted to give an example what I am trying to do, I guess it
wasnt really descriptive :)

**** Ressourcen schonen, weniger drucken - Think before you print! ****

Diese E-Mail sowie eventuelle Anhänge enthalten vertrauliche und / oder
rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat
sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte
sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren
oder Speichern sowie die unbefugte Weitergabe dieser E-Mail sind nicht

This e-mail and any attachments may contain confidential and / or
privileged information. If you are not the intended recipient or have
received this e-mail in error, please notify the sender immediately and
destroy this e-mail . Any unauthorized copying, storing, disclosure or
distribution of the contents of this e-mail is strictly forbidden.

HSBC Trinkaus & Burkhardt AG
Sitz: Düsseldorf, Königsallee 21/23, 40212 Düsseldorf, Handelsregister:
Amtsgericht Düsseldorf HRB 54447
Mitglieder des Vorstands: Andreas Schmitz (Sprecher), Paul Hagen, Dr. Olaf
Huth, Carola Gräfin v. Schmettow
Vorsitzender des Aufsichtsrats: Dr. Sieghardt Rometsch

             "Matthew Clegg"                                               
             gmail.com>                                                 An 
             Fax-Deckblatt:              Matthias.Koberstein at hsbctrinkaus. 
             HSBCTuB                     de                                
             27.08.2008 02:50                                        Kopie 
                                         r-sig-finance at stat.math.ethz.ch   
                                         Re: [R-SIG-Finance] Generating    
                                         Distributions with set skewness   
                                         and kurtosis                      

The skewness and kurtosis of the normal distribution are fixed,
but there are many continuous univariate distributions defined
on the entire real line for which the skewness and kurtosis can be

One possible choice is the Pearson Type IV distribution.
This distribution has the nice feature that the skewness and
kurtosis can be easily formulated in terms of the distributional
parameters (and vice versa).  The Wikipedia entry of the Pearson
distributions is fairly informative:


Joel Heinrich has written up a nice implementation guide:


The translation into R is fairly straightforward.

There are many other options for distributions that allow for
arbitrary skewness and kurtosis, but relating the parameters of the
distribution to the skewness and kurtosis can be a challenge.
If you are willing to resort to numerical methods to determine
the skewness and kurtosis from the distributional parameters,
here are a few choices.

One easy option is the skewed-t distribution of Férnandez and Steel.
See the "skewt" package by Robert King and Emily Anderson.  The
Férnandez and Steel approach is elegant in that it provides a way to
transform any symmetric continuous distribution into a skewed distribution.
However, working out the exact skewness and kurtosis from the
parameter values can be a challenge.

As mentioned by John Frain, the stable distribution is a good
choice when the tails are especially heavy.  See John Nolan's
web site for a wealth of information:


For an R implementation, see Jim Lindsey's web page:


(Also, although the stable distributions are skewed and
heavy-tailed, the traditional definitions of skewness and kurtosis
can't be applied to them, because the 2nd and higher moments
are not defined.)

On the other hand, if you are interested in a distribution that
has thinner tails than the normal, you might want to consider
the skew GED distribution.  See Diethelm Wuertz's fGarch


This package also contains implementations of skew normal
and skew student-t distributions, again using Férnandez and
Steel's approach.

The normal inverse Gaussian, and its cousin the generalized
hyperbolic distribution, has received a fair amount of recent
attention.  I believe an implementation can be found in the
"ghyp" package of Wolfgang Breymann and David Luethi.

This does not by any means exhaust the space of possibilities,
but it should at least give you a start.

BTW, here are a few R functions that will help you to explore
the skewness and kurtosis of arbitrary distributions:

# Calculate mean of an arbitrary density
Mean <- function(f, ...) { integrate(function (x) { f(x, ...) * x },
-Inf, Inf)$value }
# Calculate k-th central moment of an arbitrary density
M <- function (f, ..., k=1, xm = Mean(f, ...)) { integrate(function(x)
{(x - xm)^k*f(x,...)}, -Inf, Inf)$value }
# Calculate skewness of an arbitrary density
SK <- function(f, ...) { M(f, ..., k=3) / (M(f, ..., k=2)^1.5) }
# Calculate excess kurtosis of an arbitrary density
KU <- function(f, ...) { M(f, ..., k=4) / (M(f, ..., k=2)^2) - 3}

> SK(dnorm)
[1] 0   # normal distribution has skewness of 0
> KU(dnorm)
[1] 1.625367e-13  # good enough for government work

# Test gamma distribution with shape=1
> Mean(dgamma, 1)
[1] 1  # good
> SK(dgamma, 1)
[1] 2  # good
> KU(dgamma, 1)
[1] 6  # good

> library(skewt)
> KU(dskt, 5, 1)
[1] 6   # Agrees with theory ... skewness of t with 5 d.f. should be 6
> SK(dskt, 5, 1.5)
[1] 1.516366
> SK(dskt, 5, 1/1.5)
[1] -1.516366

Matt Clegg
matthewcleggphd at gmail.com

More information about the R-SIG-Finance mailing list