Re: [R] Negative Binomial Regression

From: Prof Brian Ripley <>
Date: Tue, 29 Jul 2008 15:57:17 +0100 (BST)

On Tue, 29 Jul 2008, Ben Bolker wrote:

> jcarmichael <jcarmichael314 <at>> writes:
>> Hello.
>> I am attempting to duplicate a negative binomial regression in R. SAS uses
>> generalized estimating equations for model fitting in the GENMOD procedure.
>> proc genmod data=mydata (where=(gender='F'));
>> by agegroup;
>> class id gender type;
>> model count = var1 var2 var3 /dist=NB link=log offset=lregtm;
>> repeated subject=id /type=exch;
>> run;
>> Since my dataset has several observations for each subject, I need the
>> REPEATED statement in order to indicate dependence among observations with
>> the same subject ID and independence amongst those with distinct subject
>> IDs. The TYPE statement goes on to specify the structure of the correlation
>> matrix to be used (exchangeable in this case).
> I would try glmmPQL in the MASS package. I don't think you
> can *quite* get negative binomial regression this way, but
> you can definitely get a quasipoisson model. I think exchangeable
> correlation corresponds to correlation=corCompSymm() in your
> glmmPQL command.

The problem here is that GLMM and GEE are not fitting the same model -- in one the coefficients are subject-specific and in the other population-average (see MASS4 or Diggle, Liang, Zeger +/- Heagarty).

There are several R packages for GEE, including gee, yags, geepack. The documentation of geeglm (geepack) claims it can be used with families as in glm(), so you could try it with MASS's negative.binomial family.

Brian D. Ripley,        
Professor of Applied Statistics,
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Tue 29 Jul 2008 - 15:02:31 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 29 Jul 2008 - 16:32:46 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive