Learn R Programming

npreg (version 1.1.0)

theta.mle: MLE of Theta for Negative Binomial

Description

Computes the maximum likelihood estimate of the size (theta) parameter for the Negative Binomial distribution via a Newton-Raphson algorithm.

Usage

theta.mle(y, mu, theta, wt = 1, 
          maxit = 100, maxth = .Machine$double.xmax,
          tol = .Machine$double.eps^0.5)

Value

Returns estimated theta with attributes

SE

standard error estimate

iter

number of iterations

Arguments

y

response vector

mu

mean vector

theta

initial theta (optional)

wt

weight vector

maxit

max number of iterations

maxth

max possible value of theta

tol

convergence tolerance

Author

Nathaniel E. Helwig <helwig@umn.edu>

Details

Based on the glm.nb function in the MASS package. If theta is missing, the initial estimate of theta is given by

theta <- 1 / mean(wt * (y / mu - 1)^2)

which is motivated by the method of moments estimator for the dispersion parameter in a quasi-Poisson model.

References

Venables, W. N. and Ripley, B. D. (1999) Modern Applied Statistics with S-PLUS. Third Edition. Springer.

https://www.rdocumentation.org/packages/MASS/versions/7.3-51.6/topics/negative.binomial

https://www.rdocumentation.org/packages/MASS/versions/7.3-51.6/topics/glm.nb

See Also

NegBin for details on the Negative Binomial distribution

Examples

Run this code
# generate data
n <- 1000
x <- seq(0, 1, length.out = n)
fx <- 3 * x + sin(2 * pi * x) - 1.5
mu <- exp(fx)

# simulate negative binomial data
set.seed(1)
y <- rnbinom(n = n, size = 1/2, mu = mu)

# estimate theta
theta.mle(y, mu)

Run the code above in your browser using DataLab