Learn R Programming

IMIFA (version 2.2.0)

ltrgamma: 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)

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.

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.

Author

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

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.

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

Run this code
# 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)

Run the code above in your browser using DataLab