Zero-Truncated-NegBinomial {countreg}R Documentation

The Zero-Truncated Negative Binomial Distribution

Description

Density, distribution function, quantile function, random generation, 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

dztnbinom(x, mu, theta, size, log = FALSE)
pztnbinom(q, mu, theta, size, lower.tail = TRUE, log.p = FALSE)
qztnbinom(p, mu, theta, size, lower.tail = TRUE, log.p = FALSE)
rztnbinom(n, mu, theta, size)
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.

q

vector of quantiles.

p

vector of probabilities.

n

number of random values to return.

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.

log, log.p

logical. If TRUE, probabilities p are given as log(p).

lower.tail

logical. If TRUE (default), probabilities are P[X ≤ x], otherwise, P[X > x].

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 untruncted negative binomial distribution has density

Γ(x + θ)/(Γ(θ) x!) (μ^y θ^θ)/((μ + θ)^(y + θ)

for x = 0, 1, 2, …. The zero-truncted density is then simply obtained as

g(x) = f(x)/(1 - f(0))

for x = 1, 2, ….

Value

dztnbinom gives the (log) density, pztnbinom gives the (log) distribution function, qztnbinom gives the quantile function, rztnbinom generates random deviates, and 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

dnbinom, zerotrunc


[Package countreg version 0.2-1 Index]