Máxima verosimilitud for negative binomial in r
The negative binomial distribution is commonly used to model count data, where the variance is greater than the mean. The likelihood function for the negative binomial distribution is given by:
\[ L(\theta; y) = \prod_{i=1}^{n} \binom{y_i + r - 1}{y_i} p^{r} (1-p)^{y_i} \]
where:
- \( \theta = (r, p) \) are the parameters of the negative binomial distribution,
- \( y = (y_1, y_2, ..., y_n) \) are the observed counts,
- \( r \) is the shape parameter of the negative binomial distribution,
- \( p \) is the probability of success in each trial.
To find the maximum likelihood estimates for \( r \) and \( p \), you would typically take the logarithm of the likelihood function, differentiate it with respect to \( r \) and \( p \), set the derivatives equal to zero, and solve for the parameters.
However, the negative binomial distribution is not a simple distribution to work with due to the presence of the combinatorial term in the likelihood function. As a result, the maximum likelihood estimates for the negative binomial distribution are often found using numerical optimization techniques, such as the Newton-Raphson method or the method of moments.
If you have a specific dataset and want to find the maximum likelihood estimates for the negative binomial distribution in R, you can use the `glm.nb` function from the `MASS` package, which fits a negative binomial regression model using maximum likelihood estimation.