Type: | Package |
Title: | Zero-Truncated Poisson Lognormal Distribution |
Version: | 0.1.2 |
Date: | 2021-10-09 |
Author: | Masatoshi Katabuchi |
Maintainer: | Masatoshi Katabuchi <mattocci27@gmail.com> |
Description: | Functions for obtaining the density, random variates and maximum likelihood estimates of the Zero-truncated Poisson lognormal distribution and their mixture distribution. |
License: | MIT + file LICENSE |
URL: | https://github.com/mattocci27/ztpln |
BugReports: | https://github.com/mattocci27/ztpln/issues |
Depends: | R (≥ 3.5) |
Imports: | DistributionUtils, Rcpp (≥ 0.12.0), mixtools, stats |
Suggests: | knitr, dplyr, ggplot2, rmarkdown, testthat, tidyr(≥ 1.0.0) |
LinkingTo: | Rcpp (≥ 0.12.0), RcppEigen (≥ 0.3.3.3.0), RcppNumerical (≥ 0.3-2) |
VignetteBuilder: | knitr |
Encoding: | UTF-8 |
RoxygenNote: | 7.1.2 |
NeedsCompilation: | yes |
Packaged: | 2021-10-09 14:14:15 UTC; mattocci |
Repository: | CRAN |
Date/Publication: | 2021-10-09 14:50:02 UTC |
The zero-truncated compund poisson-lognormal distributions and their mixtures
Description
Functions for obtaining the density, random deviates and maximum likelihood estimates of the zero-truncated Poisson lognormal distributions and their mixtures.
Author(s)
Masatoshi Katabuchi mattocci27@gmail.com
References
Bulmer, M. G. 1974. On Fitting the Poisson Lognormal Distribution to Species-Abundance Data. Biometrics 30:101-110.
Inouye, D., E. Yang, G. Allen, and P. Ravikumar. 2017. A Review of Multivariate Distributions for Count Data Derived from the Poisson Distribution. Wiley interdisciplinary reviews. Computational statistics 9.
Raqab, M. Z., D. Kundu, and F. A. Al-Awadhi. 2019. Compound zero-truncated Poisson normal distribution and its applications. Communications in Statistics - Theory and Methods:1–21.
See Also
Useful links:
The zero-truncated compund poisson-lognormal distributions
Description
Density function and random generation for Zero-Trauncated Poisson Lognormal
distribution with parameters mu
and sd sig
.
Usage
dztpln(x, mu, sig, log = FALSE, type1 = TRUE)
rztpln(n, mu, sig, type1 = TRUE)
Arguments
x |
vector of (non-negative integer) quantiles. |
mu |
mean of lognormal distribution. |
sig |
standard deviation of lognormal distribution. |
log |
logical; if TRUE, probabilities p are given as log(p). |
type1 |
logical; if TRUE, Use type 1 ztpln else use type 2. |
n |
number of random values to return. |
Details
A compound Poisson-lognormal distribution is a Poisson probability
distribution where its parameter \lambda
is a random variable with
lognormal distribution, that is to say log\lambda
are normally
distributed with mean \mu
and variance \sigma^2
(Bulmer 1974).
The zero-truncated Poisson-lognormal distribution can be derived from a
zero-truncated Poisson distribution.
Type 1 ZTPLN truncates zero based on Poisson-lognormal distribution and
type 2 ZTPLN truncates zero based on zero-truncated Poisson distribution.
For mathematical details, please see vignette("ztpln")
Value
dztpln gives the (log) density and rztpln generates random variates.
References
Bulmer, M. G. 1974. On Fitting the Poisson Lognormal Distribution to Species-Abundance Data. Biometrics 30:101-110.
See Also
Examples
rztpln(n = 10, mu = 0, sig = 1, type1 = TRUE)
rztpln(n = 10, mu = 6, sig = 4, type1 = TRUE)
dztpln(x = 1:5, mu = 1, sig = 2)
The zero-truncated compund poisson-lognormal distributions mixture
Description
Density function and random generation for Zero-Truncated
Poisson Lognormal distribution with parameters mu
, sig
, and theta
.
Usage
dztplnm(x, mu, sig, theta, log = FALSE, type1 = TRUE)
rztplnm(n, mu, sig, theta, type1 = TRUE)
Arguments
x |
vector of (non-negative integer) quantiles. |
mu |
vector of mean of lognormal distribution in sample. |
sig |
vector standard deviation of lognormal distribution in sample. |
theta |
vector of mixture weights |
log |
logical; if TRUE, probabilities p are given as log(p). |
type1 |
logical; if TRUE, Use type 1 ztpln else use type 2. |
n |
number of random values to return. |
Details
Type 1 ZTPLN truncates zero based on Poisson-lognormal distribution and
type 2 ZTPLN truncates zero based on zero-truncated Poisson distribution.
For mathematical details, please see vignette("ztpln")
Value
dztplnm gives the (log) density and rztplnm generates random variates. function, qpois gives the quantile function, and rpois generates random deviates.
See Also
Examples
rztplnm(n = 100, mu = c(0, 5), sig = c(1, 2), theta = c(0.2, 0.8))
dztplnm(x = 1:100, mu = c(0, 5), sig = c(1, 2), theta = c(0.2, 0.8))
dztplnm(x = 1:100, mu = c(0, 5), sig = c(1, 2), theta = c(0.2, 0.8), type1 = FALSE)
MLE for the Zero-truncated Poisson Lognormal distribution
Description
ztplnMLE
fits the Zero-truncated Poisson lognormal distribution to data and
estimates parameters mean mu
and standard deviation sig
in the lognormal
distribution
Usage
ztplnMLE(
n,
lower_mu = 0,
upper_mu = log(max(n)),
lower_sig = 0.001,
upper_sig = 10,
type1 = TRUE
)
Arguments
n |
a integer vector of counts |
lower_mu , upper_mu |
numeric values of lower and upper bounds for mean of the variables's natrual logarithm. |
lower_sig , upper_sig |
numeric values of lower and upper bounds for standard deviatoin of the variables's natrual logarithm |
type1 |
logical; if TRUE, Use type 1 ztpln else use type 2. |
Details
The function searches the maximum likelihood estimates of mean mu
and
standard deviation sig
using the optimization procedures in
nlminb
.
Value
convergence |
An integer code. 0 indicates successful convergence. |
iterations |
Number of iterations performed. |
message |
A character string giving any additional information returned by the optimizer, or NULL. For details, see PORT documentation. |
evaluation |
Number of objective function and gradient function evaluations |
mu |
Maximum likelihood estimates of mu |
sig |
Maximum likelihood estimates of sig |
loglik |
loglikelihood |
Examples
y <- rztpln(100, 3, 2)
ztplnMLE(y)
MLE for the Zero-truncated Poisson Lognormal mixture distribtuion
Description
ztplnmMLE
fits the Zero-truncated Poisson lognormal mixture distribution
to data and estimates parameters mean mu
, standard deviation sig
and
mixture weight theta
in the lognormal distribution.
Usage
ztplnmMLE(
n,
K = 2,
lower_mu = rep(0, K),
upper_mu = rep(log(max(n)), K),
lower_sig = rep(0.001, K),
upper_sig = rep(10, K),
lower_theta = rep(0.001, K),
upper_theta = rep(0.999, K),
type1 = TRUE,
message = FALSE
)
Arguments
n |
a vector of counts |
K |
number of components |
lower_mu , upper_mu |
numeric values of lower and upper bounds for mean of the variables's natural logarithm. |
lower_sig , upper_sig |
numeric values of lower and upper bounds for standard deviation of the variables's natural logarithm |
lower_theta , upper_theta |
numeric values of lower and upper bounds for mixture weights. |
type1 |
logical; if TRUE, Use type 1 ztpln else use type 2. |
message |
mean of lognormal distribution in sample 3. |
Details
The function searches the maximum likelihood estimators of mean vector mu
,
standard deviation vector sig
and mixture weight vector theta
using the
optimization procedures in nlminb
.
Value
convergence |
An integer code. 0 indicates successful convergence. |
iterations |
Number of iterations performed. |
message |
A character string giving any additional information returned by the optimizer, or NULL. For details, see PORT documentation. |
evaluation |
Number of objective function and gradient function evaluations |
mu |
Maximum likelihood estimates of mu |
sig |
Maximum likelihood estimates of sig |
theta |
Maximum likelihood estimates of theta |
loglik |
loglikelihood |
Examples
y <- rztplnm(100, c(1, 10), c(2, 1), c(0.2, 0.8))
ztplnmMLE(y)