R: Generally-Altered, -Inflated and -Truncated Negative Binomial...

Gaitnbinom.mix {VGAM} | R Documentation

## Generally–Altered, –Inflated and –Truncated Negative Binomial Distribution (GAIT–NB–NB–NB mixture)

### Description

Density, distribution function, quantile function and random generation for the generally–altered, –inflated and –truncated negative binomial (NB) distribution, based on mixtures of NB distributions having different and/or nested support. This distribution is sometimes abbreviated as GAIT–NB–NB–NB.

### Usage

    dgaitnbinom.mix(x, size.p, prob.p = NULL, munb.p = NULL,
       alter = NULL, inflate = NULL, truncate = NULL, max.support = Inf,
       pobs.a = 0, pstr.i = 0, size.a = size.p, size.i = size.p,
       prob.a = prob.p, prob.i = prob.p,
       munb.a = munb.p, munb.i = munb.p, log.arg = FALSE)
    pgaitnbinom.mix(q, size.p, prob.p = NULL, munb.p = NULL,
       alter = NULL, inflate = NULL, truncate = NULL, max.support = Inf,
       pobs.a = 0, pstr.i = 0, size.a = size.p, size.i = size.p,
       prob.a = prob.p, prob.i = prob.p,
       munb.a = munb.p, munb.i = munb.p)
    qgaitnbinom.mix(p, size.p, prob.p = NULL, munb.p = NULL,
       alter = NULL, inflate = NULL, truncate = NULL, max.support = Inf,
       pobs.a = 0, pstr.i = 0, size.a = size.p, size.i = size.p,
       prob.a = prob.p, prob.i = prob.p,
       munb.a = munb.p, munb.i = munb.p)
    rgaitnbinom.mix(n, size.p, prob.p = NULL, munb.p = NULL,
       alter = NULL, inflate = NULL, truncate = NULL, max.support = Inf,
       pobs.a = 0, pstr.i = 0, size.a = size.p, size.i = size.p,
       prob.a = prob.p, prob.i = prob.p,
       munb.a = munb.p, munb.i = munb.p)

### Arguments

`x, p, q, n, log.arg` | Same meaning as in `NegBinomial`.
`size.p, size.a, size.i` | Same meaning as `size` in `NegBinomial`, i.e., for an ordinary NB 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.
`prob.p, prob.a, prob.i` | Same meaning as `prob` in `NegBinomial`.
`munb.p, munb.a, munb.i` | Same meaning as `mu` in `NegBinomial`. Only one of the `prob`-type and `munb`-type arguments should be specified. Short vectors are recycled.
`alter, inflate, truncate` | See `Gaitnbinom.mlm`. 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` | See `Gaitpois`.
`max.support` | Same as `Gaitnbinom.mlm`.

### Details

These functions will be combined soon. See `Gaitpois` for parallel information. This distribution may be suitable for heaped data whose parent distribution is overdispersed with respect to the Poisson.

In the notation of Yee and Ma (2020) these functions concern the GAIT–NB–NB–NB distribution. For information on the GAIT–NB–MLM–MLM distribution see `Gaitnbinom.mlm`.

### Value

`dgaitnbinom.mix` gives the density (PMF), `pgaitnbinom.mix` gives the distribution function, `qgaitnbinom.mix` gives the quantile function, and `rgaitnbinom.mix` generates random deviates.

### Note

It is intended that the minimal defaults of these functions are equivalent to `NegBinomial`, e.g., `dgaitnbinom.mix(x, size, munb.p = munb)` and `dnbinom(x, size, mu = munb)` should be identical, and ditto for the other 3 functions.

### Author(s)

T. W. Yee.

### See Also

`Gaitnbinom.mlm` for the GAIT–NB–MLM–MLM distribution, `NegBinomial`.

### Examples

    ivec <- c(5, 15, 10); avec <- ivec; size = 10; munb <- 10
    max.support <- 20; pobs.a <- 0.35; xvec <- 0:max.support
    # GAT-NB-NB mixture
    (pmf.a <- dgaitnbinom.mix(xvec, size.p = size, munb.p = munb,
         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-NB-NB",
       ylim = c(0, max(pmf.a)), xlab = "y", ylab = "Probability")  # Spikes
    lines(xvec[!ind4], pmf.a[!ind4], type = "h", col = "blue")
    ## End(Not run)

    # GIT-NB-NB mixture
    pstr.i <- 0.15
    (pmf.i <- dgaitnbinom.mix(xvec, size.p = size, munb.p = munb,
       max.support = max.support, pstr.i = pstr.i, inflate = ivec))
    sum(pmf.i)  # Should be 1
    ## Not run:   # Plot the components of pmf.i
    plot(xvec, (1 - pstr.i) * dnbinom(xvec, size, mu  = munb), type = "h",
         col = "blue", las = 1, xlim = range(xvec),
         main = "GIT-NB-NB",  # The inner distribution
         ylim = c(0, max(pmf.i)), xlab = "y", ylab = "Probability")
    spikes <- dnbinom(ivec, size, mu = munb) * pstr.i / sum(
              dnbinom(ivec, size, mu = munb))
    start.pt <- dnbinom(ivec, size, mu = munb) *
                (1 - pstr.i) / pnbinom(max.support, size, mu = munb)
    segments(ivec, start.pt,  # The outer distribution
             ivec, start.pt + spikes, col = "orange", lwd = 1.1)
    ## End(Not run)

[Package VGAM version 1.1-3 Index]