Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: using constraints with nbreg

From   Wendy Regoeczi <>
Subject   Re: st: using constraints with nbreg
Date   Sun, 22 Oct 2006 12:03:05 -0400

Maarten, this is very helpful, thank you.

At 08:46 AM 10/21/2006 +0100, you wrote:
--- Wendy Regoeczi <> wrote:
> I am trying analyze negative binomial regression models. I have read
> that if you add the natural logarithm of the population at risk to
> the regression model and give it a fixed coefficient of one, the
> model becomes an analysis of rates rather than counts, which is what
> I want. But I am having trouble figuring out how to use the
> "constraint" option in nbreg to accomplish this. Can anyone tell me
> what the correct syntax is?

This is such a common thing to do that there are special options for
that; see: -help nbreg-. You can add the variable population_at_risk to
the exposure option, or the variable ln_population_at_risk to the
offset option. The variable names in your dataset will of course
probably differ. An example of the three methods, a constraint, the
exposure option, and the offset option, is shown below. Just copy the
text between *---begin example--- and *----end example--- into do
do-file editor and press the do button.

*---------------- begin example -------------
sysuse census, clear
gen lnpop65p = ln(pop65p)
constraint 1 lnpop65p = 1
xi: nbreg death popurban i.region lnpop65p, constraint(1)
xi: nbreg death popurban i.region, exposure(pop65p)
xi: nbreg death popurban i.region, offset(lnpop65p)
*----------------- end example ---------------

Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting adress:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

Send instant messages to your online friends
*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2021 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index