theta.mle | R Documentation |
Computes the maximum likelihood estimate of the size (theta) parameter for the Negative Binomial distribution via a Newton-Raphson algorithm.
theta.mle(y, mu, theta, wt = 1,
maxit = 100, maxth = .Machine$double.xmax,
tol = .Machine$double.eps^0.5)
y |
response vector |
mu |
mean vector |
theta |
initial theta (optional) |
wt |
weight vector |
maxit |
max number of iterations |
maxth |
max possible value of |
tol |
convergence tolerance |
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.
Returns estimated theta with attributes
SE |
standard error estimate |
iter |
number of iterations |
Nathaniel E. Helwig <helwig@umn.edu>
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
NegBin
for details on the Negative Binomial distribution
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.