theta.mle: MLE of Theta for Negative Binomial

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/theta.mle.R

Description

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

Usage

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

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

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.

Value

Returns estimated theta with attributes

SE

standard error estimate

iter

number of iterations

Author(s)

Nathaniel E. Helwig <helwig@umn.edu>

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# 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)

npreg documentation built on April 23, 2021, 9:07 a.m.

Related to theta.mle in npreg...