ltrgamma: Left Truncated Gamma Distributions

ltrgammaR Documentation

Left Truncated Gamma Distributions

Description

Functions to draw pseudo-random numbers from, or calculate the expectation of, left-truncated gamma distributions (see Details below).

Usage

rltrgamma(n,
          shape,
          rate = 1,
          trunc = 1)

exp_ltrgamma(shape,
             rate = 1,
             trunc = 1,
             inverse = FALSE)

Arguments

n

Number of observations to generate.

shape

Shape parameter for the desired gamma distribution. Must be strictly positive

rate

Rate parameter for the desired gamma distribution. Must be strictly positive.

trunc

The point of left truncation (corresponding to \tau below). Defaults to 1. Must be non-negative. When inverse is TRUE, this becomes the point of right truncation.

inverse

A logical indicating whether to calculate the expectation for a right-truncated inverse gamma distribution instead of a left-truncated gamma distribution. Defaults to FALSE.

Details

The left-truncated gamma distribution has PDF:

f(x|\alpha, \beta) = \frac{\beta^\alpha}{(\Gamma(\alpha)-\Gamma(\alpha, \tau\beta))}x^{\alpha-1}e^{-x\beta}

for 0\le\tau\le x, and \min(\tau,\beta) > 0, where \alpha and \beta are the shape and rate parameters, respectively, \tau is the cutoff point at which truncation occurs, and \Gamma(\alpha, \tau\beta) is the upper incomplete gamma function.

Value

For rltrgamma, a vector of length n giving draws from the left-truncated gamma distribution with the specified shape and rate parameters, and truncation point trunc.

For exp_ltrgamma, the expected value of a left-truncated (inverse) gamma distribution.

Note

rltrgamma is invoked internally for the "IFA", "MIFA", "OMIFA", and "IMIFA" models to draw column shrinkage parameters for all but the first loadings column under the MGP prior when truncated=TRUE (which is not the default) is supplied to mgpControl, at the expense of slightly longer run times. exp_ltrgamma is used within MGP_check to check the validity of the MGP hyperparameters when truncated=TRUE (which is again, not the default). Both functions always assume trunc=1 for these internal usages.

Note also that no arguments are recycled, i.e. all arguments must be of length 1.

Author(s)

Keefe Murphy - <keefe.murphy@mu.ie>

References

Dagpunar, J. S. (1978) Sampling of variates from a truncated gamma distribution, Statistical Computation and Simulation, 8(1): 59-64.

See Also

mgpControl, MGP_check

Examples

# Generate left-truncated Ga(3.1, 2.1, 1) variates
rltrgamma(n=10, shape=3.1, rate=2.1)

# Calculate the expectation of a Ga(3.1, 2.1, 1) distribution
exp_ltrgamma(shape=3.1, rate=2.1)

# Calculate the expectation of an inverse gamma distribution right-truncated at 2
exp_ltrgamma(shape=3.1, rate=2.1, trunc=2, inverse=TRUE)

Keefe-Murphy/IMIFA documentation built on Jan. 31, 2024, 2:15 p.m.