Gaitdpois | R Documentation |
Density, distribution function, quantile function and random generation for the generally altered, inflated, truncated and deflated Poisson distribution. Both parametric and nonparametric variants are supported; these are based on finite mixtures of the parent with itself and the multinomial logit model (MLM) respectively.
dgaitdpois(x, lambda.p, a.mix = NULL, a.mlm = NULL, i.mix = NULL,
i.mlm = NULL, d.mix = NULL, d.mlm = NULL, truncate = NULL,
max.support = Inf, pobs.mix = 0, pobs.mlm = 0, pstr.mix = 0,
pstr.mlm = 0, pdip.mix = 0, pdip.mlm = 0, byrow.aid = FALSE,
lambda.a = lambda.p, lambda.i = lambda.p,
lambda.d = lambda.p, log = FALSE)
pgaitdpois(q, lambda.p, a.mix = NULL, a.mlm = NULL, i.mix = NULL,
i.mlm = NULL, d.mix = NULL, d.mlm = NULL, truncate = NULL,
max.support = Inf, pobs.mix = 0, pobs.mlm = 0, pstr.mix = 0,
pstr.mlm = 0, pdip.mix = 0, pdip.mlm = 0, byrow.aid = FALSE,
lambda.a = lambda.p, lambda.i = lambda.p,
lambda.d = lambda.p, lower.tail = TRUE, checkd = FALSE)
qgaitdpois(p, lambda.p, a.mix = NULL, a.mlm = NULL, i.mix = NULL,
i.mlm = NULL, d.mix = NULL, d.mlm = NULL, truncate = NULL,
max.support = Inf, pobs.mix = 0, pobs.mlm = 0, pstr.mix = 0,
pstr.mlm = 0, pdip.mix = 0, pdip.mlm = 0, byrow.aid = FALSE,
lambda.a = lambda.p, lambda.i = lambda.p, lambda.d = lambda.p)
rgaitdpois(n, lambda.p, a.mix = NULL, a.mlm = NULL, i.mix = NULL,
i.mlm = NULL, d.mix = NULL, d.mlm = NULL, truncate = NULL,
max.support = Inf, pobs.mix = 0, pobs.mlm = 0, pstr.mix = 0,
pstr.mlm = 0, pdip.mix = 0, pdip.mlm = 0, byrow.aid = FALSE,
lambda.a = lambda.p, lambda.i = lambda.p, lambda.d = lambda.p)
x , q , p , n |
Same meaning as in |
log , lower.tail |
Same meaning as in |
lambda.p , lambda.a , lambda.i , lambda.d |
Same meaning as in |
truncate , max.support |
numeric; these specify the set of truncated values.
The default value of |
a.mix , i.mix , d.mix |
Vectors of nonnegative integers;
the altered, inflated and deflated values for the
parametric variant.
Each argument must have unique values only.
Assigning argument |
a.mlm , i.mlm , d.mlm |
Similar to the above, but for the nonparametric (MLM) variant.
For example, assigning |
pobs.mlm , pstr.mlm , pdip.mlm , byrow.aid |
The first three arguments are coerced into a matrix of
probabilities
using |
pobs.mix , pstr.mix , pdip.mix |
Vectors of probabilities that are recycled if necessary to
length |
checkd |
Logical.
If |
These functions allow any combination of 4 operator types:
truncation, alteration, inflation and deflation.
The precedence is
truncation, then alteration and lastly inflation and deflation.
Informally, deflation can be thought of as the
opposite of inflation.
This order minimizes the potential interference among the operators.
Loosely, a set of probabilities is set to 0 by truncation
and the remaining probabilities are scaled up.
Then a different set of probabilities are set to some
values pobs.mix
and/or pobs.mlm
and the remaining probabilities are rescaled up.
Then another different set of probabilities is inflated by
an amount pstr.mlm
and/or proportional
to pstr.mix
so that individual elements in this set have two sources.
Then another different set of probabilities is deflated by
an amount pdip.mlm
and/or proportional
to pdip.mix
.
Then all the probabilities are
rescaled so that they sum to unity.
Both parametric and nonparametric variants are implemented.
They usually have arguments with suffix
.mix
and .mlm
respectively.
The MLM is a loose coupling that effectively separates
the parent (or base) distribution from
the altered values.
Values inflated nonparametrically effectively have
their spikes shaved off.
The .mix
variant has associated with it
lambda.a
and lambda.i
and lambda.d
because it is mixture of 4 Poisson distributions with
partitioned or nested support.
Any value of the support of the distribution that is
altered, inflated, truncated or deflated
is called a special value.
A special value that is altered may mean that its probability
increases or decreases relative to the parent distribution.
An inflated special value means that its probability has
increased, provided alteration elsewhere has not made it decrease
in the first case.
There are seven types of special values and they are
represented by
a.mix
,
a.mlm
,
i.mix
,
i.mlm
,
d.mix
,
d.mlm
,
truncate
.
Terminology-wise, special values
are altered or inflated or truncated or deflated, and
the remaining support points that correspond directly to
the parent distribution are nonspecial or ordinary.
These functions do what
Zapois
,
Zipois
,
Pospois
collectively did plus much more.
In the notation of Yee and Ma (2023)
these functions allow for the special cases:
(i) GAIT–Pois(lambda.p
)–Pois(lambda.a
,
a.mix
, pobs.mix
)–Pois(lambda.i
,
i.mix
, pstr.mix
);
(ii) GAIT–Pois(lambda.p
)–MLM(a.mlm
,
pobs.mlm
)–MLM(i.mlm
, pstr.mlm
).
Model (i) is totally parametric while model (ii) is the most
nonparametric possible.
dgaitdpois
gives the density,
pgaitdpois
gives the distribution function,
qgaitdpois
gives the quantile function, and
rgaitdpois
generates random deviates.
The default values of the arguments correspond to ordinary
dpois
,
ppois
,
qpois
,
rpois
respectively.
It is possible that the GAITD PMF is invalid because
of too much inflation and/or deflation.
This would result in some probabilities exceeding
unity or being negative.
Hence x
should ideally contain these types
of special values so that this can be detected.
If so then a NaN
is returned and
a warning is issued, e.g.,
same as dnorm(0, 0, sd = -1)
.
To help checking,
pgaitdpois(q, ...)
calls
dgaitdpois(floor(q), ...)
if checkd
is TRUE
.
That is, given the parameters, it is impractical to determine whether the PMF is valid. To do this, one would have to compute the PMF at all values of its support and check that they are nonnegative and sum to unity. Hence one must be careful to input values from the parameter space, especially for inflation and deflation. See Example 2 below.
Functions Pospois
and those similar
have been moved to VGAMdata.
It is better to use
dgaitdpois(x, lambda, truncate = 0)
instead of
dposbinom(x, lambda)
, etc.
T. W. Yee.
Yee, T. W. and Ma, C. (2024). Generally altered, inflated, truncated and deflated regression. Statistical Science, 39 (in press).
gaitdpoisson
,
multinomial
,
specials
,
spikeplot
,
dgaitdplot
,
Zapois
,
Zipois
,
Pospois
Poisson
;
Gaitdbinom
,
Gaitdnbinom
,
Gaitdlog
,
Gaitdzeta
.
# Example 1
ivec <- c(6, 14); avec <- c(8, 11); lambda <- 10; xgrid <- 0:25
tvec <- 15; max.support <- 20; pobs.mix <- 0.05; pstr.i <- 0.25
dvec <- 13; pdip.mlm <- 0.05; pobs.mlm <- 0.05
(ddd <- dgaitdpois(xgrid, lambda, lambda.a = lambda + 5,
truncate = tvec, max.support = max.support, pobs.mix = pobs.mix,
pobs.mlm = pobs.mlm, a.mlm = avec,
pdip.mlm = pdip.mlm, d.mlm = dvec,
pstr.mix = pstr.i, i.mix = ivec))
## Not run: dgaitdplot(lambda, ylab = "Probability", xlab = "x",
truncate = tvec, max.support = max.support, pobs.mix = pobs.mix,
pobs.mlm = pobs.mlm, a.mlm = avec, all.lwd = 3,
pdip.mlm = pdip.mlm, d.mlm = dvec,
pstr.mix = pstr.i, i.mix = ivec, deflation = TRUE,
main = "GAITD Combo PMF---Poisson Parent")
## End(Not run)
# Example 2: detection of an invalid PMF
xgrid <- 1:3 # Does not cover the special values purposely
(ddd <- dgaitdpois(xgrid, 1, pdip.mlm = 0.1, d.mlm = 5,
pstr.mix = 0.95, i.mix = 0)) # Undetected
xgrid <- 0:13 # Wider range so this detects the problem
(ddd <- dgaitdpois(xgrid, 1, pdip.mlm = 0.1, d.mlm = 5,
pstr.mix = 0.95, i.mix = 0)) # Detected
sum(ddd, na.rm = TRUE) # Something gone awry
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.