# theta.md

From MASS v7.3-0
by Brian Ripley

##### Estimate theta of the Negative Binomial

Given the estimated mean vector, estimate `theta`

of the
Negative Binomial Distribution.

- Keywords
- models

##### Usage

`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)

##### Arguments

- y
- Vector of observed values from the Negative Binomial.
- mu
- Estimated mean vector.
- n
- Number of data points (defaults to the sum of
`weights`

) - dfr
- Residual degrees of freedom (assuming
`theta`

known). For a weighted fit this is the sum of the weights minus the number of fitted parameters. - 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?

##### Details

`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.

##### Value

- The required estimate of
`theta`

, as a scalar. For`theta.ml`

, the standard error is given as attribute`"SE"`

.

##### See Also

##### Examples

```
quine.nb <- glm.nb(Days ~ .^2, data = quine)
theta.md(quine$Days, fitted(quine.nb), dfr = df.residual(quine.nb))
theta.ml(quine$Days, fitted(quine.nb))
theta.mm(quine$Days, fitted(quine.nb), dfr = df.residual(quine.nb))
## 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)
attach(yeast)
mu <- fitted(fit)
theta.md(numbers, mu, dfr = 399, weights = fr)
theta.ml(numbers, mu, weights = fr)
theta.mm(numbers, mu, dfr = 399, weights = fr)
detach()
```

*Documentation reproduced from package MASS, version 7.3-0, License: GPL-2 | GPL-3*

### Community examples

Looks like there are no examples yet.