# tgamma: The right truncated gamma distribution In heavy: Robust Estimation Using Heavy-Tailed Distributions

## Description

Density, distribution function, quantile function and random generation for the right truncated gamma distribution with shape (`shape`), scale (`scale`) parameters and right truncation point (`truncation`).

## Usage

 ```1 2 3 4``` ``` dtgamma(x, shape, scale = 1, truncation = 1, log = FALSE) ptgamma(q, shape, scale = 1, truncation = 1, lower.tail = TRUE) qtgamma(p, shape, scale = 1, truncation = 1, lower.tail = TRUE) rtgamma(n, shape, scale = 1, truncation = 1) ```

## Arguments

 `x, q` vector of quantiles. `shape, scale` shape and scale parameters, must be positive. `truncation` right truncation point, must be positive. `log` logical; if TRUE, the log-density is returned. `lower.tail` logical; if TRUE (default), probabilities are P[X ≤ x], otherwise, P[X > x]. `p` vector of probabilities. `n` number of observations. If `length(n) > 1`, the length is taken to be the number of required deviates.

## Details

If `scale` or `truncation` are not specified, they assume the default values.

The right truncated gamma distribution with shape a, scale b and right truncation point t > 0 has density

f(x) = b^a/gamma(a,bt) exp(-bx)x^(a-1)

con x < t and γ(a,b) denotes the incomplete gamma function (see Abramowitz and Stegun, 1970, pp. 260).

## Value

`dtgamma`, `ptgamma`, and `qtgamma` are respectively the density, distribution function and quantile function of the right truncated gamma distribution. `rtgamma` generates random deviates from the right truncated gamma distribution.

The length of the result is determined by `n` for `rtgamma`, and is the maximum of the lengths of the numerical parameters for the other functions.

## References

Abramowitz, M., and Stegun, I.A. (1970). Handbook of Mathematical Functions. Dover, New York.

Phillippe, A. (1997). Simulation of right and left truncated gamma distribution by mixtures. Statistics and Computing 7, 173-181.

Distributions for other standard distributions.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11``` ```x <- seq(0, 2, by = 0.1) y <- dtgamma(x, shape = 1, truncation = 1) z <- dgamma(x, shape = 1) # standard gamma pdf plot(x, z, type = "l", xlab = "x", ylab = "density", ylim = range(y, z), lty = 2) lines(x, y) x <- rtgamma(1000, shape = 1) ## Q-Q plot for the right truncated gamma data against true theoretical distribution: qqplot(qtgamma(ppoints(1000), shape = 1), x, main = "Truncated Gamma Q-Q plot", xlab = "Theoretical quantiles", ylab = "Sample quantiles", font.main = 1) abline(c(0,1), col = "red", lwd = 2) ```

### Example output

```
```

heavy documentation built on Oct. 30, 2019, 9:48 a.m.