Title: | Zero-Truncated Poisson Lognormal Distribution |
---|---|
Description: | Functions for obtaining the density, random variates and maximum likelihood estimates of the Zero-truncated Poisson lognormal distribution and their mixture distribution. |
Authors: | Masatoshi Katabuchi |
Maintainer: | Masatoshi Katabuchi <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.2.9000 |
Built: | 2025-03-03 04:19:11 UTC |
Source: | https://github.com/mattocci27/ztpln |
Density function and random generation for Zero-Trauncated Poisson Lognormal
distribution with parameters mu
and sd sig
.
dztpln(x, mu, sig, log = FALSE, type1 = TRUE) rztpln(n, mu, sig, type1 = TRUE)
dztpln(x, mu, sig, log = FALSE, type1 = TRUE) rztpln(n, mu, sig, type1 = TRUE)
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. |
A compound Poisson-lognormal distribution is a Poisson probability
distribution where its parameter is a random variable with
lognormal distribution, that is to say
are normally
distributed with mean
and variance
(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")
dztpln gives the (log) density and rztpln generates random variates.
Bulmer, M. G. 1974. On Fitting the Poisson Lognormal Distribution to Species-Abundance Data. Biometrics 30:101-110.
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)
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)
Density function and random generation for Zero-Truncated
Poisson Lognormal distribution with parameters mu
, sig
, and theta
.
dztplnm(x, mu, sig, theta, log = FALSE, type1 = TRUE) rztplnm(n, mu, sig, theta, type1 = TRUE)
dztplnm(x, mu, sig, theta, log = FALSE, type1 = TRUE) rztplnm(n, mu, sig, theta, type1 = TRUE)
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. |
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")
dztplnm gives the (log) density and rztplnm generates random variates. function, qpois gives the quantile function, and rpois generates random deviates.
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)
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)
ztplnMLE
fits the Zero-truncated Poisson lognormal distribution to data and
estimates parameters mean mu
and standard deviation sig
in the lognormal
distribution
ztplnMLE( n, lower_mu = 0, upper_mu = log(max(n)), lower_sig = 0.001, upper_sig = 10, type1 = TRUE )
ztplnMLE( n, lower_mu = 0, upper_mu = log(max(n)), lower_sig = 0.001, upper_sig = 10, type1 = TRUE )
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. |
The function searches the maximum likelihood estimates of mean mu
and
standard deviation sig
using the optimization procedures in
nlminb
.
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 |
y <- rztpln(100, 3, 2) ztplnMLE(y)
y <- rztpln(100, 3, 2) ztplnMLE(y)
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.
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 )
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 )
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. |
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
.
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 |
y <- rztplnm(100, c(1, 10), c(2, 1), c(0.2, 0.8)) ztplnmMLE(y)
y <- rztplnm(100, c(1, 10), c(2, 1), c(0.2, 0.8)) ztplnmMLE(y)