Antonio.Gasparrini | 20 Aug 04:03
Favicon

bug in lme4?

Dear all,

I found a problem with 'lme4'. Basically, once you load the package 'aod' (Analysis of Overdispersed
Data), the functions 'lmer' and 'glmer' don't work anymore:

library(lme4)
(fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy))
(gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
              family = binomial, data = cbpp))
install.packages("aod")
library(aod)
(fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy))
(gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
              family = binomial, data = cbpp))

Taking into account that this package is used to perform similar analyses, this could be a problem.

All the best

Antonio Gasparrini
Public and Environmental Health Research Unit (PEHRU)
London School of Hygiene & Tropical Medicine
Keppel Street, London WC1E 7HT, UK
Office: 0044 (0)20 79272406 - Mobile: 0044 (0)79 64925523
http://www.lshtm.ac.uk/people/gasparrini.antonio ( http://www.lshtm.ac.uk/pehru/ )
Peter Dalgaard | 20 Aug 09:23

Re: bug in lme4?

Antonio.Gasparrini <at> lshtm.ac.uk wrote:
> Dear all,
>  
> I found a problem with 'lme4'. Basically, once you load the package 'aod' (Analysis of Overdispersed
Data), the functions 'lmer' and 'glmer' don't work anymore:
>  
> library(lme4)
> (fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy))
> (gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
>               family = binomial, data = cbpp))
> install.packages("aod")
> library(aod)
> (fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy))
> (gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
>               family = binomial, data = cbpp))
>  
> Taking into account that this package is used to perform similar analyses, this could be a problem.
>  
> All the best
>  
> Antonio Gasparrini
> Public and Environmental Health Research Unit (PEHRU)
> London School of Hygiene & Tropical Medicine
> Keppel Street, London WC1E 7HT, UK
> Office: 0044 (0)20 79272406 - Mobile: 0044 (0)79 64925523
> http://www.lshtm.ac.uk/people/gasparrini.antonio ( http://www.lshtm.ac.uk/pehru/ )
>   
>
> ------------------------------------------------------------------------
>
(Continue reading)

Martin Maechler | 20 Aug 10:30
Favicon

Re: bug in lme4?

>>>>>   <Antonio.Gasparrini <at> lshtm.ac.uk>
>>>>>     on Wed, 20 Aug 2008 03:03:29 +0100 writes:

    > Dear all,
    > I found a problem with 'lme4'. Basically, once you load the package 'aod' (Analysis of Overdispersed
Data), the functions 'lmer' and 'glmer' don't work anymore:

    > library(lme4)
    > (fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy))
    > (gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
    > family = binomial, data = cbpp))
    > install.packages("aod")
    > library(aod)
    > (fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy))
    > (gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
    > family = binomial, data = cbpp))

    > Taking into account that this package is used to perform
    > similar analyses, this could be a problem.

It is a problem, and it *is* a bug;
thank you for reporting it, Antonio.

Since lme4 uses a NAMESPACE, it could and probably should make
sure to protect itself from incompatible function redefinitions 
such as the one the  'aod' package "provides" :

Arguably, the bug is really in package 'aod' rather than 'lme4':
'aod' redefines the AIC() method for 'logLik' objects in a not quite
backward-compatible way:
(Continue reading)

Renaud Lancelot | 20 Aug 10:47

Re: bug in lme4?

Dear all,

As the maintener of package aod, I thank you for bringing my attention on
this problem. I will try to alter the code in aod. However, I am not sure to
be able to do it right now.

Best regards,

Renaud

2008/8/20 Martin Maechler <maechler <at> stat.math.ethz.ch>

> >>>>>   <Antonio.Gasparrini <at> lshtm.ac.uk>
> >>>>>     on Wed, 20 Aug 2008 03:03:29 +0100 writes:
>
>    > Dear all,
>    > I found a problem with 'lme4'. Basically, once you load the package
> 'aod' (Analysis of Overdispersed Data), the functions 'lmer' and 'glmer'
> don't work anymore:
>
>    > library(lme4)
>    > (fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy))
>    > (gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 |
> herd),
>    > family = binomial, data = cbpp))
>    > install.packages("aod")
>    > library(aod)
>    > (fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy))
>    > (gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 |
> herd),
(Continue reading)

Peter Dalgaard | 20 Aug 11:59

Re: bug in lme4?

Renaud Lancelot wrote:
> Dear all,
>
> As the maintener of package aod, I thank you for bringing my attention on
> this problem. I will try to alter the code in aod. However, I am not sure to
> be able to do it right now.
>   
Looks like it should be fairly easy:

Get rid of
setMethod(f = "AIC", signature = "logLik", ...etc...

Instead, define a (local) function, say AIC1(), and use that inside

setMethod(f = "AIC", signature = "glimML", ....

Redefining methods from stats is just a bad idea. Packages might protect
themselves from it, but command-line behaviour of AIC(ll) is also affected.

> Best regards,
>
> Renaud
>
> 2008/8/20 Martin Maechler <maechler <at> stat.math.ethz.ch>
>
>   
>>>>>>>   <Antonio.Gasparrini <at> lshtm.ac.uk>
>>>>>>>     on Wed, 20 Aug 2008 03:03:29 +0100 writes:
>>>>>>>               
>>    > Dear all,
(Continue reading)

Renaud Lancelot | 20 Aug 14:41

Re: bug in lme4?

Thank you very much !

Renaud

2008/8/20 Peter Dalgaard <P.Dalgaard <at> biostat.ku.dk>

> Renaud Lancelot wrote:
> > Dear all,
> >
> > As the maintener of package aod, I thank you for bringing my attention on
> > this problem. I will try to alter the code in aod. However, I am not sure
> to
> > be able to do it right now.
> >
> Looks like it should be fairly easy:
>
> Get rid of
> setMethod(f = "AIC", signature = "logLik", ...etc...
>
> Instead, define a (local) function, say AIC1(), and use that inside
>
> setMethod(f = "AIC", signature = "glimML", ....
>
> Redefining methods from stats is just a bad idea. Packages might protect
> themselves from it, but command-line behaviour of AIC(ll) is also affected.
>
>
> > Best regards,
> >
> > Renaud
(Continue reading)


Gmane