Calculate Moments of the Generalized Inverse Gaussian Distribution
Calculate Moments of the Generalized Inverse Gaussian Distribution
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.
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.
Theta: Numeric. The parameter vector specifying the GIG distribution. Of the form c(lambda, chi, psi) (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 Theta 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
ηkKλ+k(ω)/Kλ(ω)
where Klambda() 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
β−kΓ(α+k)/Γ(α)
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.
Returns
The moment specified. In the case of raw moments, Inf is returned if the moment is infinite.
References
Paolella, Marc S. (2007) Intermediate Probability: A Computational Approach, Chichester: Wiley
### Raw moments of the generalized inverse Gaussian distributionTheta <- c(-0.5,5,2.5)gigRawMom(1, Theta)momIntegrated("gig", order =1, param = Theta, about =0)gigRawMom(2, Theta)momIntegrated("gig", order =2, param = Theta, about =0)gigRawMom(10, Theta)momIntegrated("gig", order =10, param = Theta, about =0)gigRawMom(2.5, Theta)### Moments of the generalized inverse Gaussian distributionTheta <- c(-0.5,5,2.5)(m1 <- gigRawMom(1, Theta))gigMom(1, Theta)gigMom(2, Theta, m1)(m2 <- momIntegrated("gig", order =2, param = Theta, about = m1))gigMom(1, Theta, m1)gigMom(3, Theta, m1)momIntegrated("gig", order =3, param = Theta, about = m1)### Raw moments of the gamma distributionshape <-2rate <-3Theta <- c(shape, rate)gammaRawMom(1, shape, rate)momIntegrated("gamma", order =1, param = Theta, about =0)gammaRawMom(2, shape, rate)momIntegrated("gamma", order =2, param = Theta, about =0)gammaRawMom(10, shape, rate)momIntegrated("gamma", order =10, param = Theta, about =0)### Moments of the inverse gamma distributionTheta <- c(-0.5,5,0)gigRawMom(2, Theta)# InfgigRawMom(-2, Theta)momIntegrated("invgamma", order =-2, param = c(-Theta[1],Theta[2]/2), about =0)### An example where the moment is infinite: inverse gammaTheta <- c(-0.5,5,0)gigMom(1, Theta)gigMom(2, Theta)