theta.md.Rd
Given the estimated mean vector, estimate theta
of the
Negative Binomial Distribution.
theta.md(y, mu, dfr, weights, limit = 20, eps = .Machine$double.eps^0.25) theta.ml(y, mu, n, weights, limit = 10, eps = .Machine$double.eps^0.25, trace = FALSE) theta.mm(y, mu, dfr, weights, limit = 10, eps = .Machine$double.eps^0.25)
y | Vector of observed values from the Negative Binomial. |
---|---|
mu | Estimated mean vector. |
n | Number of data points (defaults to the sum of |
dfr | Residual degrees of freedom (assuming |
weights | Case weights. If missing, taken as 1. |
limit | Limit on the number of iterations. |
eps | Tolerance to determine convergence. |
trace | logical: should iteration progress be printed? |
theta.md
estimates by equating the deviance to the residual
degrees of freedom, an analogue of a moment estimator.
theta.ml
uses maximum likelihood.
theta.mm
calculates the moment estimator of theta
by
equating the Pearson chi-square
\(\sum (y-\mu)^2/(\mu+\mu^2/\theta)\)
to the residual degrees of freedom.
The required estimate of theta
, as a scalar.
For theta.ml
, the standard error is given as attribute "SE"
.
quine.nb <- glm.nb(Days ~ .^2, data = quine) theta.md(quine$Days, fitted(quine.nb), dfr = df.residual(quine.nb))#> [1] 1.135441#> [1] 1.603641 #> attr(,"SE") #> [1] 0.2138379#> [1] 1.562879## weighted example yeast <- data.frame(cbind(numbers = 0:5, fr = c(213, 128, 37, 18, 3, 1))) fit <- glm.nb(numbers ~ 1, weights = fr, data = yeast) summary(fit)#> #> Call: #> glm.nb(formula = numbers ~ 1, data = yeast, weights = fr, init.theta = 3.586087428, #> link = log) #> #> Deviance Residuals: #> 1 2 3 4 5 6 #> -16.314 3.682 6.923 7.555 4.033 2.813 #> #> Coefficients: #> Estimate Std. Error z value Pr(>|z|) #> (Intercept) -0.38199 0.06603 -5.785 7.25e-09 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> (Dispersion parameter for Negative Binomial(3.5861) family taken to be 1) #> #> Null deviance: 408.9 on 5 degrees of freedom #> Residual deviance: 408.9 on 5 degrees of freedom #> AIC: 897.06 #> #> Number of Fisher Scoring iterations: 1 #> #> #> Theta: 3.59 #> Std. Err.: 1.75 #> #> 2 x log-likelihood: -893.063#> [1] 3.027079theta.ml(yeast$numbers, mu, limit = 15, weights = yeast$fr)#> [1] 3.586087 #> attr(,"SE") #> [1] 1.749609theta.mm(yeast$numbers, mu, dfr = 399, weights = yeast$fr)#> [1] 3.549593