| Title: | Zero-Modified Complex 'Tri-Parametric' Pearson Distribution for Overdispersed Count Data |
|---|---|
| Description: | Implements zero-modified versions of the Complex 'Tri-Parametric' Pearson distribution for overdispersed count data. The package addresses limitations of existing implementations when the parameter b approaches zero. It provides distribution functions, maximum likelihood estimation, and diagnostic tools for modeling count data with excess zeros. The methodology is based on 'Rodriguez-Avi' and coauthors (2003) <doi:10.1007/s00362-002-0134-7>. |
| Authors: | Rasheedat Oladoja [aut, cre] (ORCID: <https://orcid.org/0009-0001-5883-8039>) |
| Maintainer: | Rasheedat Oladoja <[email protected]> |
| License: | GPL-3 |
| Version: | 0.1.0 |
| Built: | 2026-06-03 09:33:08 UTC |
| Source: | https://github.com/cran/zmctp |
The zmctp package extends the Complex Triparametric Pearson (CTP) distribution with zero-modified versions for handling overdispersed count data, particularly when the parameter b approaches zero.
Main functions:
dzictp, pzictp, qzictp,
rzictp - Zero-Modified CTP distribution functions
ctp.fit - Fit CTP model
zictp.fit - Fit Zero-Modified CTP model
Maintainer: Rasheedat Oladoja [email protected] (ORCID)
Useful links:
Fits the Complex Triparametric Pearson (CTP) distribution to count data using maximum likelihood estimation.
ctp.fit( x, a_start = NULL, b_start = NULL, gama_start = NULL, method = "L-BFGS-B", penalty = 1e+10 )ctp.fit( x, a_start = NULL, b_start = NULL, gama_start = NULL, method = "L-BFGS-B", penalty = 1e+10 )
x |
Numeric vector of nonnegative counts. |
a_start |
Optional starting value for parameter a. |
b_start |
Optional starting value for parameter b. |
gama_start |
Optional starting value for parameter gamma. |
method |
Optimization method (default: "L-BFGS-B"). |
penalty |
numeric penalty added for numerical stability when b → 0 |
An object of class "ctpfit" containing:
estimates |
Named vector of MLEs |
se |
Standard errors |
vcov |
Variance-covariance matrix |
logLik |
Log-likelihood |
AIC |
Akaike Information Criterion |
BIC |
Bayesian Information Criterion |
pearson_chisq |
Pearson's chi-squared statistic |
wald_chisq |
Wald's chi-squared statistic |
fitted_freq |
Data frame of observed vs expected frequencies |
data |
Original data |
converged |
Convergence status |
set.seed(123) x <- rctp(30, a = 1, b = 0.5, gama = 5) fit <- ctp.fit(x) print(fit) plot(fit)set.seed(123) x <- rctp(30, a = 1, b = 0.5, gama = 5) fit <- ctp.fit(x) print(fit) plot(fit)
Evaluates the probability mass function of the Complex TriParametric Pearson (CTP) distribution for nonnegative integer values.
The pmf is
and satisfies the recurrence
dctp(x, a, b, gama, log = FALSE)dctp(x, a, b, gama, log = FALSE)
x |
Vector of nonnegative integers. |
a |
Parameter a. |
b |
Parameter b (must satisfy b >= 0). |
gama |
Parameter gamma. |
log |
Logical; if TRUE, returns log-probabilities. |
A numeric vector of probabilities.
dctp(0:5, a = 1, b = 0.5, gama = 6)dctp(0:5, a = 1, b = 0.5, gama = 6)
The Zero-Modified CTP (ZM-CTP) distribution modifies the zero probability of the baseline CTP distribution.
dzictp(x, a, b, gama, omega, log = FALSE)dzictp(x, a, b, gama, omega, log = FALSE)
x |
Vector of nonnegative integers. |
a |
Parameter a. |
b |
Parameter b. |
gama |
Parameter gamma. |
omega |
Zero-modification parameter, with 0 < omega < 1. |
log |
Logical; if TRUE, returns log-probabilities. |
Numeric vector of probabilities.
dzictp(0:5, a = 1, b = 0.5, gama = 6, omega = 0.3)dzictp(0:5, a = 1, b = 0.5, gama = 6, omega = 0.3)
Cumulative Distribution Function of the CTP Distribution
pctp(q, a, b, gama, lower.tail = TRUE, log.p = FALSE)pctp(q, a, b, gama, lower.tail = TRUE, log.p = FALSE)
q |
Vector of quantiles. |
a |
Parameter a. |
b |
Parameter b. |
gama |
Parameter gamma. |
lower.tail |
Logical; if TRUE, probabilities are P(X <= q), otherwise P(X > q). |
log.p |
Logical; if TRUE, probabilities are given on the log scale. |
Numeric vector of cumulative probabilities.
pctp(0:5, a = 1, b = 0.5, gama = 6)pctp(0:5, a = 1, b = 0.5, gama = 6)
Plot method for ctpfit objects
## S3 method for class 'ctpfit' plot(x, type = c("frequency", "cdf", "qq"), ...)## S3 method for class 'ctpfit' plot(x, type = c("frequency", "cdf", "qq"), ...)
x |
A ctpfit object |
type |
Type of plot: "frequency", "cdf", or "qq" |
... |
Additional graphical parameters |
No return value. Called for its side effect of producing a plot.
Creates diagnostic plots for Zero-Modified CTP distribution fits, including frequency comparisons, CDF plots, and Q-Q plots.
## S3 method for class 'zictpfit' plot(x, type = c("frequency", "cdf", "qq"), ...)## S3 method for class 'zictpfit' plot(x, type = c("frequency", "cdf", "qq"), ...)
x |
A zictpfit object from zictp.fit() |
type |
Type of plot: "frequency", "cdf", or "qq" |
... |
Additional graphical parameters |
No return value. Called for its side effect of producing a plot.
Print method for ctpfit objects
## S3 method for class 'ctpfit' print(x, ...)## S3 method for class 'ctpfit' print(x, ...)
x |
A ctpfit object |
... |
Additional arguments (ignored) |
Invisibly returns the original fitted model object. The function is called for its side effect of printing a model summary.
Print method for zictpfit objects
## S3 method for class 'zictpfit' print(x, ...)## S3 method for class 'zictpfit' print(x, ...)
x |
A zictpfit object |
... |
Additional arguments (ignored) |
Invisibly returns the original fitted model object. The function is called for its side effect of printing a model summary.
Cumulative Distribution Function of the ZM-CTP Distribution
pzictp(q, a, b, gama, omega, lower.tail = TRUE, log.p = FALSE)pzictp(q, a, b, gama, omega, lower.tail = TRUE, log.p = FALSE)
q |
Vector of quantiles. |
a |
Parameter a. |
b |
Parameter b. |
gama |
Parameter gamma. |
omega |
Zero-modification parameter. |
lower.tail |
Logical. |
log.p |
Logical. |
Numeric vector of cumulative probabilities.
pzictp(0:5, a = 1, b = 0.5, gama = 6, omega = 0.3)pzictp(0:5, a = 1, b = 0.5, gama = 6, omega = 0.3)
Quantile Function of the CTP Distribution
qctp(p, a, b, gama, lower.tail = TRUE, log.p = FALSE, max_q = 1000)qctp(p, a, b, gama, lower.tail = TRUE, log.p = FALSE, max_q = 1000)
p |
Vector of probabilities. |
a |
Parameter a. |
b |
Parameter b. |
gama |
Parameter gamma. |
lower.tail |
Logical. |
log.p |
Logical. |
max_q |
Maximum x to search. |
Numeric vector of quantiles.
qctp(c(0.25, 0.5, 0.75), a = 1, b = 0.5, gama = 6)qctp(c(0.25, 0.5, 0.75), a = 1, b = 0.5, gama = 6)
Quantile Function of the ZM-CTP Distribution
qzictp(p, a, b, gama, omega, lower.tail = TRUE, log.p = FALSE, max_q = 1000)qzictp(p, a, b, gama, omega, lower.tail = TRUE, log.p = FALSE, max_q = 1000)
p |
Vector of probabilities. |
a |
Parameter a. |
b |
Parameter b. |
gama |
Parameter gamma. |
omega |
Zero-modification parameter. |
lower.tail |
Logical. |
log.p |
Logical. |
max_q |
Maximum x to search. |
Numeric vector of quantiles.
qzictp(c(0.25, 0.5, 0.75), a = 1, b = 0.5, gama = 6, omega = 0.3)qzictp(c(0.25, 0.5, 0.75), a = 1, b = 0.5, gama = 6, omega = 0.3)
Random Generation from the CTP Distribution
rctp(n, a, b, gama)rctp(n, a, b, gama)
n |
Number of observations. |
a |
Parameter a. |
b |
Parameter b. |
gama |
Parameter gamma. |
Integer vector of random draws.
set.seed(123) rctp(10, a = 1, b = 0.5, gama = 6)set.seed(123) rctp(10, a = 1, b = 0.5, gama = 6)
Random Generation from the ZM-CTP Distribution
rzictp(n, a, b, gama, omega)rzictp(n, a, b, gama, omega)
n |
Number of observations. |
a |
Parameter a. |
b |
Parameter b. |
gama |
Parameter gamma. |
omega |
Zero-modification parameter. |
Integer vector of random draws.
set.seed(123) rzictp(10, a = 1, b = 0.5, gama = 6, omega = 0.3)set.seed(123) rzictp(10, a = 1, b = 0.5, gama = 6, omega = 0.3)
Summary method for ctpfit objects
## S3 method for class 'ctpfit' summary(object, ...)## S3 method for class 'ctpfit' summary(object, ...)
object |
A ctpfit object |
... |
Additional arguments (ignored) |
Invisibly returns the original fitted model object. The function is called for its side effects, producing a formatted summary of parameter estimates, moments, and goodness-of-fit diagnostics.
Summary method for zictpfit objects
## S3 method for class 'zictpfit' summary(object, ...)## S3 method for class 'zictpfit' summary(object, ...)
object |
A zictpfit object |
... |
Additional arguments (ignored) |
Invisibly returns the original fitted model object. The function is called for its side effects, producing a formatted summary of parameter estimates, moments, and goodness-of-fit diagnostics.
Fits the Zero-Modified Complex TriParametric Pearson (ZM-CTP) distribution to count data using maximum likelihood estimation.
A logit reparameterization is used for omega to ensure 0 < omega < 1, and a log reparameterization is used for gamma so that gama = 2*a + 2 + exp(eta), which guarantees variance existence throughout optimization.
zictp.fit( x, a_start = NULL, b_start = NULL, gama_start = NULL, omega_start = NULL, method = "BFGS" )zictp.fit( x, a_start = NULL, b_start = NULL, gama_start = NULL, omega_start = NULL, method = "BFGS" )
x |
Numeric vector of nonnegative counts. |
a_start |
Optional starting value for parameter a. |
b_start |
Optional starting value for parameter b. |
gama_start |
Optional starting value for parameter gamma. |
omega_start |
Optional starting value for omega (0 < omega < 1). |
method |
Optimization method (default: "BFGS"). |
An object of class '"zictpfit"'.
set.seed(123) x <- rzictp(30, a = 1, b = 0.5, gama = 5, omega = 0.3) fit <- zictp.fit(x) fit$estimatesset.seed(123) x <- rzictp(30, a = 1, b = 0.5, gama = 5, omega = 0.3) fit <- zictp.fit(x) fit$estimates