Title | The variance function in nbreg | |
Author | Roberto Gutierrez, StataCorp |
Stata’s nbreg model comes in two flavors: the default mean dispersion (or equivalently nbreg, dispersion(mean)) and the constant dispersion nbreg, dispersion(constant). In short,
. nbreg, dispersion(mean) (or just plain nbreg)
corresponds to Cameron and Trivedi’s NB2 variance function, while
. nbreg, dispersion(constant)
corresponds to NB1.
To see why, let’s do the variance calculations ourselves. The negative binomial model is the hierarchical model y_i | g_i, where g_i is gamma distributed and
y_i | g_i ~ Poisson(g_i)
That is, the conditional mean and variance of y_i given g_i is merely g_i.
For nbreg, dispersion(mean), with mu_i = exp(xb_i) (xb is the linear predictor),
g_i ~ Gamma(1/alpha, alpha*mu_i)
where I define the Gamma(a,b) distribution as that having mean ab and variance ab^2, and alpha is an ancillary parameter to be estimated from the data.
Naturally,
E(y_i) = E{E(y_i | g_i)} = E(g_i) = (1/alpha)*alpha*mu_i = mu_i
The variance of y_i is
Var(y_i) = E{Var(y_i | g_i)} + Var{E(y_i | g_i)} = E(g_i) + Var(g_i) = 1/alpha*(alpha*mu_i) + (1/alpha)*(alpha*mu_i)^2 = mu_i + alpha*mu_i^2 = mu_i * (1 + alpha*mu_i)
This corresponds to Cameron and Trivedi’s equation (3.13) and thus corresponds to the NB2 model in their terminology. The dispersion for this model is (1 + alpha*mu_i), which depends on mu_i, hence the moniker “mean dispersion”.
By comparison, nbreg, dispersion(constant) has the distribution of g_i as
g_i ~ Gamma(mu_i/delta, delta)
where delta is the ancillary parameter. I could have easily called this alpha and not delta, but nbreg uses delta to make the distinction between both models clearer.
Here E(y_i) = mu_i as well, and the variance of y_i is
Var(y_i) = E{Var(y_i | g_i)} + Var{E(y_i | g_i)} = E(g_i) + Var(g_i) = (mu_i/delta)*delta + (mu_i/delta)*delta^2 = mu_i + mu_i*delta = mu_i * (1 + delta)
which (except for calling it delta instead of alpha) corresponds to Cameron and Trivedi’s equation (3.11), and hence the NB1 model. For this model, the dispersion is (1 + delta) and thus is constant over all observations.
For both models, the dispersion is greater than one. This is why nbreg serves its purpose of modeling data that exhibit dispersion beyond that which can be handled using Poisson regression, which has dispersion set to 1.
Learn
Free webinars
NetCourses
Classroom and web training
Organizational training
Video tutorials
Third-party courses
Web resources
Teaching with Stata
© Copyright 1996–2024 StataCorp LLC. All rights reserved.
×
We use cookies to ensure that we give you the best experience on our website—to enhance site navigation, to analyze usage, and to assist in our marketing efforts. By continuing to use our site, you consent to the storing of cookies on your device and agree to delivery of content, including web fonts and JavaScript, from third party web services.
Cookie Settings
Last updated: 16 November 2022
StataCorp LLC (StataCorp) strives to provide our users with exceptional products and services. To do so, we must collect personal information from you. This information is necessary to conduct business with our existing and potential customers. We collect and use this information only where we may legally do so. This policy explains what personal information we collect, how we use it, and what rights you have to that information.
These cookies are essential for our website to function and do not store any personally identifiable information. These cookies cannot be disabled.
This website uses cookies to provide you with a better user experience. A cookie is a small piece of data our website stores on a site visitor's hard drive and accesses each time you visit so we can improve your access to our site, better understand how you use our site, and serve you content that may be of interest to you. For instance, we store a cookie when you log in to our shopping cart so that we can maintain your shopping cart should you not complete checkout. These cookies do not directly store your personal information, but they do support the ability to uniquely identify your internet browser and device.
Please note: Clearing your browser cookies at any time will undo preferences saved here. The option selected here will apply only to the device you are currently using.