ztnbinom: Extension of the Zero-Truncated Negative Binomial...

ztnbinom-extensionsR Documentation

Extension of the Zero-Truncated Negative Binomial Distribution

Description

Score function, hessian, mean, and variance for the zero-truncated negative binomial distribution with parameters mu (= mean of the untruncated distribution) and dispersion parameter theta (or equivalently size).

Usage

sztnbinom(x, mu, theta, size, parameter = c("mu", "theta", "size"), drop = TRUE)
hztnbinom(x, mu, theta, size, parameter = c("mu", "theta"), drop = TRUE)
mean_ztnbinom(mu, theta, size, drop = TRUE)
var_ztnbinom(mu, theta, size, drop = TRUE)

Arguments

x

vector of (positive integer) quantiles.

mu

vector of non-negative means of the untruncated negative binomial distribution.

theta, size

vector of strictly positive dispersion parameters (shape parameter of the gamma mixing distribution). Only one of theta or size must be specified.

parameter

character. Should the derivative with respect to "mu" and/or "theta"/"size" be computed?

drop

logical. Should the result be a matrix (drop = FALSE) or should the dimension be dropped (drop = TRUE, the default)?

Details

The untruncated negative binomial distribution has density

f(x) = \frac{\Gamma(x + \theta)}{\Gamma(\theta) x!} \cdot \frac{\mu^y \theta^\theta}{(\mu + \theta)^{y + \theta}}

for x = 0, 1, 2, \ldots. The zero-truncated density is then simply obtained as

g(x) = \frac{f(x)}{1 - f(0)}

for x = 1, 2, \ldots.

Value

sztnbinom gives the score function (= derivative of the log-density with respect to mu and/or theta). hztnbinom gives the hessian (= 2nd derivative of the log-density with respect to mu and/or theta). mean_ztnbinom and var_ztnbinom give the mean and the variance, respectively.

See Also

dztnbinom, dnbinom, zerotrunc


countreg documentation built on Dec. 4, 2023, 3:09 a.m.