Learn R Programming

GeneralizedHyperbolic (version 0.8-6)

gigMom: Calculate Moments of the Generalized Inverse Gaussian Distribution

Description

Functions to calculate raw moments and moments about a given location for the generalized inverse Gaussian (GIG) distribution, including the gamma and inverse gamma distributions as special cases.

Usage

gigRawMom(order, chi = 1, psi = 1, lambda = 1,
          param = c(chi, psi, lambda))
gigMom(order, chi = 1, psi = 1, lambda = 1,
       param = c(chi, psi, lambda), about = 0)
gammaRawMom(order, shape = 1, rate = 1, scale = 1/rate)

Value

The moment specified. In the case of raw moments, Inf is returned if the moment is infinite.

Arguments

order

Numeric. The order of the moment to be calculated. Not permitted to be a vector. Must be a positive whole number except for moments about zero.

chi

A shape parameter that by default holds a value of 1.

psi

Another shape parameter that is set to 1 by default.

lambda

Shape parameter of the GIG distribution. Common to all forms of parameterization. By default this is set to 1.

param

Numeric. The parameter vector specifying the GIG distribution. Of the form c(chi, psi, lambda) (see dgig).

about

Numeric. The point around which the moment is to be calculated.

shape

Numeric. The shape parameter, must be non-negative, not permitted to be a vector.

scale

Numeric. The scale parameter, must be positive, not permitted to be a vector.

rate

Numeric. The rate parameter, an alternative way to specify the scale.

Author

David Scott d.scott@auckland.ac.nz

Details

The vector param of parameters is examined using gigCheckPars to see if the parameters are valid for the GIG distribution and if they correspond to the special cases which are the gamma and inverse gamma distributions. Checking of special cases and valid parameter vector values is carried out using the function gigCheckPars. Checking whether order is a whole number is carried out using the function is.wholenumber.

Raw moments (moments about zero) are calculated using the functions gigRawMom or gammaRawMom. For moments not about zero, the function momChangeAbout is used to derive moments about another point from raw moments. Note that raw moments of the inverse gamma distribution can be obtained from the raw moments of the gamma distribution because of the relationship between the two distributions. An alternative implementation of raw moments of the gamma and inverse gamma distributions may be found in the package actuar and these may be faster since they are written in C.

To calculate the raw moments of the GIG distribution it is convenient to use the alternative parameterization of the GIG in terms of \(\omega\) and \(\eta\), given as parameterization 3 in gigChangePars. Then the raw moment of the GIG distribution of order \(k\) is given by $$\eta^k K_{\lambda+k}(\omega)/K_{\lambda}(\omega)$$

where \(K_\lambda()\) is the modified Bessel function of the third kind of order \(\lambda\).

The raw moment of the gamma distribution of order \(k\) with shape parameter \(\alpha\) and rate parameter \(\beta\) is given by $$\beta^{-k}\Gamma(\alpha+k)/\Gamma(\alpha)$$

The raw moment of order \(k\) of the inverse gamma distribution with shape parameter \(\alpha\) and rate parameter \(\beta\) is the raw moment of order \(-k\) of the gamma distribution with shape parameter \(\alpha\) and rate parameter \(1/\beta\).

References

Paolella, Marc S. (2007) Intermediate Probability: A Computational Approach, Chichester: Wiley

See Also

gigCheckPars, gigChangePars and from package DistributionUtils: is.wholenumber, momChangeAbout, momIntegrated

Further, gigMean, gigVar, gigSkew, gigKurt.

Examples

Run this code
## Computations, using momIntegrated from pkg 'DistributionUtils':
momIntegrated <- DistributionUtils :: momIntegrated

### Raw moments of the generalized inverse Gaussian distribution
param <- c(5, 2.5, -0.5)
gigRawMom(1, param = param)
momIntegrated("gig", order = 1, param = param, about = 0)
gigRawMom(2, param = param)
momIntegrated("gig", order = 2, param = param, about = 0)
gigRawMom(10, param = param)
momIntegrated("gig", order = 10, param = param, about = 0)
gigRawMom(2.5, param = param)

### Moments of the generalized inverse Gaussian distribution
param <- c(5, 2.5, -0.5)
(m1 <- gigRawMom(1, param = param))
gigMom(1, param = param)
gigMom(2, param = param, about = m1)
(m2 <- momIntegrated("gig", order = 2, param = param, about = m1))
gigMom(1, param = param, about = m1)
gigMom(3, param = param, about = m1)
momIntegrated("gig", order = 3, param = param, about = m1)

### Raw moments of the gamma distribution
shape <- 2
rate <- 3
param <- c(shape, rate)
gammaRawMom(1, shape, rate)
momIntegrated("gamma", order = 1, shape = shape, rate = rate, about = 0)
gammaRawMom(2, shape, rate)
momIntegrated("gamma", order = 2, shape = shape, rate = rate, about = 0)
gammaRawMom(10, shape, rate)
momIntegrated("gamma", order = 10, shape = shape, rate = rate, about = 0)

### Moments of the inverse gamma distribution
param <- c(5, 0, -0.5)
gigRawMom(2, param = param)             # Inf
gigRawMom(-2, param = param)
momIntegrated("invgamma", order = -2, shape = -param[3],
              rate = param[1]/2, about = 0)

### An example where the moment is infinite: inverse gamma
param <- c(5, 0, -0.5)
gigMom(1, param = param)
gigMom(2, param = param)

Run the code above in your browser using DataLab