gigMom: Calculate Moments of the Generalized Inverse Gaussian...

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/gigMom.R

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

1
2
3
4
5
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)

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.

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.

Value

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

Author(s)

David Scott [email protected]

References

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

See Also

gigCheckPars, gigChangePars, is.wholenumber, momChangeAbout, momIntegrated, gigMean, gigVar, gigSkew, gigKurt.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
### 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, param = param, about = 0)
gammaRawMom(2, shape, rate)
momIntegrated("gamma", order = 2, param = param, about = 0)
gammaRawMom(10, shape, rate)
momIntegrated("gamma", order = 10, param = param, 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,
              param = c(-param[3], 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)

sjp/GeneralizedHyperbolic documentation built on May 26, 2017, 10:13 a.m.