Learn R Programming

VGAM (version 1.1-2)

Gaitpois.mix: Generally-Altered, -Inflated and -Truncated Poisson Distribution (GAIT--Pois--Pois--Pois mixture)

Description

Density, distribution function, quantile function and random generation for the generally-altered, -inflated and -truncated Poisson distribution, based on mixtures of Poisson distributions having different support. This distribution is sometimes abbreviated as GAIT--Pois--Pois--Pois.

Usage

dgaitpois.mix(x, lambda.p, alter = NULL, inflate = NULL,
    truncate = NULL, max.support = Inf, pobs.a = 0, pstr.i = 0,
    lambda.a = lambda.p, lambda.i = lambda.p, log.arg = FALSE)
pgaitpois.mix(q, lambda.p, alter = NULL, inflate = NULL,
    truncate = NULL, max.support = Inf, pobs.a = 0, pstr.i = 0,
    lambda.a = lambda.p, lambda.i = lambda.p)
qgaitpois.mix(p, lambda.p, alter = NULL, inflate = NULL,
    truncate = NULL, max.support = Inf, pobs.a = 0, pstr.i = 0,
    lambda.a = lambda.p, lambda.i = lambda.p)
rgaitpois.mix(n, lambda.p, alter = NULL, inflate = NULL,
    truncate = NULL, max.support = Inf, pobs.a = 0, pstr.i = 0,
    lambda.a = lambda.p, lambda.i = lambda.p)

Arguments

x, p, q, n, log.arg

Same meaning as in Poisson.

lambda.p, lambda.a, lambda.i

Same meaning as in rpois, i.e., for an ordinary Poisson distribution. The first is for the main parent (inner) distribution, and the outer distribution(s) (usually spikes) concern the altered and/or inflated values. Short vectors are recycled.

alter, inflate, truncate

See Gaitpois.mix. The order of precedence is the same, viz. truncation first, then altering, and finally inflation. If alter and pobs.a are both of unit length then the default probability mass function (PMF) evaluated at alter is pobs.a.

pobs.a, pstr.i

Numeric, probabilities of an observed altered value or a structural inflated value. See Gaitpois.mlm, however these are ordinary vectors of the usual length rather than matrices. The probability of obtaining a value equal to an element of alter is pobs.a, while the probability of obtaining a value equal to an element of inflate structurally is pstr.i. Actually, the probability of obtaining inflate[i] comes from a scaled Poisson distribution: pstr.i * dpois(inflate[i], lambda.p) / sum(dpois(inflate, lambda.p)) so that it isn't really a structural probability unless length(inflate) == 1.

These two arguments are used only if alter and inflate are assigned values, respectively.

max.support

Same as Gaitpois.mlm.

Value

dgaitpois.mix gives the density (PMF), pgaitpois.mix gives the distribution function, qgaitpois.mix gives the quantile function, and rgaitpois.mix generates random deviates.

Details

These functions are an alternative to Gaitpois.mlm. The latter have an outer distribution that is based on the multinomial logit model (MLM) which allows the special values to be modelled nonparametrically in an unstructured manner. These functions here use the same parent distribution to model the special values, hence the special values are modelled in a more structured way; one could say they are more parametric than the MLM variant.

Jargonwise, the outer distribution concerns those special values which appear in alter or inflate, and the inner distribution concerns the remaining support points. General truncation is allowed throughout; the parent distribution has PMF that is merely scaled up to exclude those points (truncate and values beyond max.support). In particular, the GAT inner distribution has a parent that is truncated at c(alter, truncated) and any values beyond max.support. Similarly, the GIT inner distribution has a parent that is truncated at truncated and any values beyond max.support.

In the notation of Yee and Ma (2019) these functions concern the GAIT-Pois-Pois-Pois distribution. For the GAIT-Pois-MLM-MLM distribution see Gaitpois.mlm.

References

Yee, T. W. and Ma, C. C. (2019) Generally-altered, -inflated and -truncated count regression, with application to heaped and seeped data. In preparation.

See Also

gatpoisson.mix, Gaitpois.mlm for the GAIT-Pois-MLM-MLM distribution.

Examples

Run this code
# NOT RUN {
ivec <- c(15, 10, 5); avec <- ivec; lambda <- 10
max.support <- 20; pobs.a <- 0.35; xvec <- 0:max.support
(pmf.a <- dgaitpois.mix(xvec, lambda,  # lambda.a = lambda,
     max.support = max.support, pobs.a = pobs.a, alter = avec))
sum(pmf.a)  # Should be 1
# }
# NOT RUN {
ind4 <- match(xvec, avec, nomatch = 0) > 0  # xvec %in% avec
plot(xvec[ ind4], pmf.a[ ind4], type = "h", col = "orange", lwd = 1.1,
   las = 1, xlim = range(xvec), main = "GAT-Poisson-Poisson",
   ylim = c(0, max(pmf.a)), xlab = "y", ylab = "Probability")  # Spikes
lines(xvec[!ind4], pmf.a[!ind4], type = "h", col = "blue") 
# }
# NOT RUN {
# GIT-Poisson-Poisson mixture
pstr.i <- 0.20
(pmf.i <- dgaitpois.mix(xvec, lambda,  # lambda.a = lambda,
   max.support = max.support, pstr.i = pstr.i, inflate = ivec))
sum(pmf.i)  # Should be 1
# }
# NOT RUN {
  # Plot the components of pmf.i
spikes <- dpois(ivec, lambda) * pstr.i / sum(dpois(ivec, lambda))
start.pt <- dpois(ivec, lambda) * (1 - pstr.i) / ppois(max.support, lambda)
plot(xvec, (1 - pstr.i) * dpois(xvec, lambda), type = "h",
     col = "blue", las = 1, xlim = range(xvec),
     main = "GIT-Poisson-Poisson",  # The inner distribution
     ylim = c(0, max(pmf.i)), xlab = "y", ylab = "Probability")
segments(ivec, start.pt,  # The outer distribution
         ivec, start.pt + spikes, col = "orange", lwd = 1.1) 
# }

Run the code above in your browser using DataLab