Skip to content

problem using geeglm: R keeps crashing

5 messages · Ben Bolker, Chris Howden

#
On 10-11-28 07:17 PM, Chris Howden wrote:
It has showed up (I think three times including this one): you can
always check the archive at
<https://stat.ethz.ch/pipermail/r-sig-mixed-models/> to see if your
messages get through).
In general if a package crashes R, that by definition constitutes a
bug in the package and should be reported to the maintainers -- but see
below ...
Based on my reading of ?geeglm, and this note under the "id" argument
description: "Data are assumed to be sorted so that observations on a
cluster are contiguous rows for all entities in the formula."  Thus I
would not be surprised if the example you give above failed, because it
violates the rules laid out in the documentation (on the other hand,
this is pretty easy to check and it would be wise for the package
authors to make their code a bit more "fool-resistant" by checking for
this condition and throwing an error if the elements aren't properly
sorted).
  You can easily sort your observations by id to make them conform to
the rules, or, if you want to fit each contiguous block separately, you
can use something like

factor(c(0,cumsum(diff(as.numeric(id))!=0)))

to generate a new id variable that identifies contiguous blocks.
 Given all this it seems really surprising that geeglm works with
permuted data.  Does it work consistently (say 10 or 20 times in a row)
and give the same answers for different permutations ... ? Maybe you
just got lucky.

  (It would also seem pretty dicey to me to run a random effects model
with only 4 levels (animals), although if you do want to use 'bout'
(contiguous block) as the id variable you will have a lot more levels ...)
#
Thanks for the reply Ben,

(And sorry for sending the same email 3 times everyone. I'm on other R
lists where I receive a copy of my sent posts. And I also logged onto the
r-sig-models admin site to confirm my settings are set so I receive copies
of emails I send to the list. So not sure why I didn't receive them.)

Sorting the id's doesn't help, R still crashes.

What's interesting is that permutating the data actually makes geeglm()
fit a model, while it is incapable of doing so on the correct id sorted
data. (As U suggested I have run it again a number of times and get
similar results each time. The model estimates are also quite similar to a
standard GLM)

Looking at the summary() results for the permutated data model has given
me a clue as to why a model can be fit to the permutated data, but not the
'correct' data. The permutated model has fit 68987 clusters, which is
incorrect since there should only be 4 (1 for each dog)

I suspect the problem here is that geeglm cannot fit an "exchangeable"
correlation structure to such large blocks of data (the smallest of which
has 24000 rows).

PS: I was wondering why u think it is dicey to run a random effects model
with only 4 levels. If I only have 4 individuals then I only have 4
levels.

Chris Howden
Founding Partner
Tricky Solutions
Tricky Solutions 4 Tricky Problems
Evidence Based Strategic Development, IP Commercialisation and Innovation,
Data Analysis, Modelling, and Training
(mobile) 0410 689 945
(fax / office) (+618) 8952 7878
chris at trickysolutions.com.au

-----Original Message-----
From: Ben Bolker [mailto:bbolker at gmail.com]
Sent: Monday, 29 November 2010 10:36 AM
To: r-sig-mixed-models at r-project.org; Chris Howden
Subject: Re: [R-sig-ME] problem using geeglm: R keeps crashing
On 10-11-28 07:17 PM, Chris Howden wrote:
haven't
It has showed up (I think three times including this one): you can
always check the archive at
<https://stat.ethz.ch/pipermail/r-sig-mixed-models/> to see if your
messages get through).
the
case
unusual
"

  In general if a package crashes R, that by definition constitutes a
bug in the package and should be reported to the maintainers -- but see
below ...
I
<-geeglm(resp~rubbish,data=sample,id=dogname,family=binomial,corstr="excha
ngeable")
for
I
correlation
id2,
set of
id1's?
Based on my reading of ?geeglm, and this note under the "id" argument
description: "Data are assumed to be sorted so that observations on a
cluster are contiguous rows for all entities in the formula."  Thus I
would not be surprised if the example you give above failed, because it
violates the rules laid out in the documentation (on the other hand,
this is pretty easy to check and it would be wise for the package
authors to make their code a bit more "fool-resistant" by checking for
this condition and throwing an error if the elements aren't properly
sorted).
  You can easily sort your observations by id to make them conform to
the rules, or, if you want to fit each contiguous block separately, you
can use something like

factor(c(0,cumsum(diff(as.numeric(id))!=0)))

to generate a new id variable that identifies contiguous blocks.
 Given all this it seems really surprising that geeglm works with
permuted data.  Does it work consistently (say 10 or 20 times in a row)
and give the same answers for different permutations ... ? Maybe you
just got lucky.

  (It would also seem pretty dicey to me to run a random effects model
with only 4 levels (animals), although if you do want to use 'bout'
(contiguous block) as the id variable you will have a lot more levels ...)
can
want
units
from
The
1/6
resource
#
If the model with only 4 clusters is the one you wanted (i.e. data
sorted in id order, contiguous blocks), then I would definitely contact
the maintainers to see why it's crashing.  That is, you seem to be
following the rules laid out in the documentation, so it shouldn't crash.

  The reason it's dicey to run a RE model with only 4 levels is that you
are in effect trying to estimate a variance from 4 observations, which
tends to be very inaccurate/unstable.  Since you apparently have very
large quantities of data per individual, I would expect you to get
approximately the same answers if you just treated individuals as a
fixed effect (although admittedly the model is philosophically different).

  Ben Bolker
On 11/28/2010 11:57 PM, Chris Howden wrote:
#
Thanks Ben,

I've contacted the administrators and we're looking into it.

And your absolutely right, a GLMM with random intercept is giving me
pretty much the same answer as a GLM.

Although I'm hoping the GEE model with it's robust SE's will account for
the obvious autocorrelation in my dataset.

Chris Howden
Founding Partner
Tricky Solutions
Tricky Solutions 4 Tricky Problems
Evidence Based Strategic Development, IP Commercialisation and Innovation,
Data Analysis, Modelling, and Training
(mobile) 0410 689 945
(fax / office) (+618) 8952 7878
chris at trickysolutions.com.au


-----Original Message-----
From: Ben Bolker [mailto:bbolker at gmail.com]
Sent: Tuesday, 30 November 2010 4:33 AM
To: Chris Howden
Cc: r-sig-mixed-models at r-project.org
Subject: Re: [R-sig-ME] problem using geeglm: R keeps crashing

  If the model with only 4 clusters is the one you wanted (i.e. data
sorted in id order, contiguous blocks), then I would definitely contact
the maintainers to see why it's crashing.  That is, you seem to be
following the rules laid out in the documentation, so it shouldn't crash.

  The reason it's dicey to run a RE model with only 4 levels is that you
are in effect trying to estimate a variance from 4 observations, which
tends to be very inaccurate/unstable.  Since you apparently have very
large quantities of data per individual, I would expect you to get
approximately the same answers if you just treated individuals as a
fixed effect (although admittedly the model is philosophically different).

  Ben Bolker
On 11/28/2010 11:57 PM, Chris Howden wrote:
the
copies
a
the
which
model
Innovation,
the
available
<-geeglm(resp~rubbish,data=sample,id=dogname,family=binomial,corstr="excha
...)