Learn R Programming

dexus (version 1.12.0)

getSizeNB: Maximum-likelihood and maximum-a-posteriori estimators for the negative binomial distribution.

Description

Estimates the size parameter of a a negative binomial distribution from given data.

Usage

getSizeNB(x, maxCyc = 1000, eta = 0, rmax = Inf,
    method = "bisection")

Arguments

x
The input data. Must be a numeric vector.
maxCyc
The maximum number of cycles of the numeric procedure to find the estimator. (Default = 1000).
eta
The weight of the exponential prior. The higher eta, the lower the estimate for the size parameter. Setting eta = 0 means that the prior is not used and, therefore, the maximum-likelihood estimator is calculated. (Default = 0).
rmax
Upper bound on the size parameter. This corresponds to a truncated exponential prior. If not used there is a non-zero probability that the estimator for the size parameter is $\infty$. (Default = Inf).
method
The procedure used to solve the equation

$$\sum_{k=1} ^N \psi (x_i+r) - N\psi(r)+N \log \left(\frac{r}{r+ 1/N \sum_{i=1}^N x_i} \right) - \eta =0$$

for $r$.

This can either be "bisection" or "regula falsi". (Default="bisection").

Value

  • "numeric" An estimate of the size parameter of the negative binomial distribution. The overdispersion parameter is the inverse of the size parameter of a negative binomial distribution

Details

Depending on the parameters you can either obtain the Maximum-likelihood estimator or the maximum-a-posteriori estimator using an exponential prior.

lc{ maximum-likelihood estimator eta = 0 maximum-a-posteriori estimator eta > 0 }

By setting the variable rmax to a positive value one can enforce an upper bound on the parameter.

The inverse of the size parameter is the overdispersion parameter.

Examples

Run this code
x <- rnbinom(mu=50, size=5, n=10)
getSizeNB(x)

Run the code above in your browser using DataLab