# NormalLaplace

I was fortunate to undertake a summer studentship with the University of Auckland’s Department of Statistics over the summer of 2010–2011. My project was entitled “Software for the Normal Laplace Distribution”. The purpose of this project was to improve upon the functionality present in the NormalLaplace package that was available via the Rmetrics group on R-Forge. What was present prior to my involvement were functions that calculated theoretical means, variance, skewness and kurtosis in a Normal Laplace (NL) distribution. The standard “dpqr” functions were also present, these are the density, cumulative distribution, quantile and random number generating functions respectively.

A parameter checking function was created in order to validate NL parameters, along with a fitting function that included appropriate S3 methods on the fitted object (e.g. `plot`

, `coef`

, `summary`

).

The NormalLaplace package was then extended to include functions for the Generalised Normal Laplace (GNL) distribution. The same functionality that was implemented for the NL distribution was also implemented for the GNL distribution. The GNL distribution adds an additional parameter, rho, on top of the existing NL parameters and acts as a scaling parameter. Complications arose when implementing the density and cumulative distribution functions for the GNL distribution as they required inversion of the GNL characteristic function and numerical evalution of integrals. This was necessary due to the lack of closed form expressions for these functions. A consequence of this is that calculation is both slow and somewhat inaccurate. On top of this, the characteristic function returns complex numbers and R’s `integrate`

function only works over one dimension. This means that the characteristic function required modification for both the density and cumulative distribution functions in order to return real numbers and allow numerical evalution using the `integrate`

function.

Definitions of the density, cumulative distribution function and random number generating functions are provided below.

$r(s)$ and $\theta(s)$ are defined as the modulus and argument of the complex number returned from the characteristic function.

Generation of random observations from the GNL distribution is based upon the composition of three random variables, $Z$, $G_1$ and $G_2$. These are independent with $Z \sim N(0, 1)$ and $G_1$, $G_2$ being gamma random variables with a scale of 1 and a shape of $\rho$.

A GNL random variable, $X \sim \textrm{GNL}(\mu, \sigma, \alpha, \beta, \rho)$ can be represented as:

Mean, variance, skewness and kurtosis functions were implemented for the GNL distribution and are defined below: