ltrgamma {IMIFA} | R 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 |
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 |
Details
The left-truncated gamma distribution has PDF:
for , and
, where
and
are the
shape
and rate
parameters, respectively, is the cutoff point at which
trunc
ation occurs, and 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
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)