Skip to content
Prev 59919 / 398502 Next

help with glmmPQL

HI, DOUG & JOSE: 

      Is there some reason that "anova.lme" should NOT accept an object 
of class "glmmPQL" in the example below?  If you don't see one either, 
then I suggest you consider modifying the code as described below. 

HI, ANDREW: 

      I couldn't find your data "learning" in my Windows installation of 
R 2.0.0pat, which meant that I had to take the time to find another 
example before I could get the error message you described.  I got it 
from modifying the example in the documentation for "glmmPQL" as follows: 

fit1 <- glmmPQL(y ~ trt, random = ~ 1 | ID,
                     family = binomial, data = bacteria)
fit2 <- glmmPQL(y ~ trt + I(week > 2), random = ~ 1 | ID,
                     family = binomial, data = bacteria)
anova(fit1, fit2)
    Error in anova.lme(fit1, fit2) : Objects must inherit from classes 
"gls", "gnls" "lm","lmList", "lme","nlme","nlsList", or "nls"

      I then checked the class of fit1 and fit2: 
 > class(fit1)
[1] "glmmPQL" "lme"   
 > class(fit2)
[1] "glmmPQL" "lme"   

      As an experiment, I changed the class of fit1 and fit2: 
 > class(fit1) <- "lme"
 > class(fit2) <- "lme"
 > anova(fit1, fit2)
     Model df      AIC      BIC    logLik   Test  L.Ratio p-value
fit1     1  5 1054.623 1071.592 -522.3117                       
fit2     2  6 1113.622 1133.984 -550.8111 1 vs 2 56.99884  <.0001

      Unless someone like Doug or Jose tells us, "Don't do that", I 
would use these answers. 

      I looked briefly at the code for "anova.lme", and it looks to me 
like "glmmPQL" could be added to the list of allowed options in the 
following test roughly half way through the code: 

       if (!all(match(termsClass, c("gls", "gnls", "lm", "lmList",
            "lme", "nlme", "nlsList", "nls"), 0))) {
            stop(paste("Objects must inherit from classes \"gls\", 
\"gnls\"",
                "\"lm\",\"lmList\", \"lme\",\"nlme\",\"nlsList\", or 
\"nls\""))
        }

      hope this helps. 
      spencer graves
A.J. Rossini wrote: