[R] Error in anova(): objects must inherit from classes
Austin, Matt
maustin at amgen.com
Thu Nov 25 04:34:05 CET 2004
The lme method for anova() checks the inheritance of the object when a
single object is supplied, which is why there is no error when you use one
object at a time. When two objects are supplied, the method uses the class
of the object by invoking the data.class function (which does not list
glmmPQL class). If you replace the check of the class with a check of
inheritance it should work.
Following is a check from the example listed in MASS (Venables and Ripley)
> library(MASS)
> library(nlme)
> x1 <- glmmPQL(y ~ I(week > 2), random = ~ 1 | ID,
+ family = binomial, data = bacteria)
iteration 1
iteration 2
iteration 3
iteration 4
iteration 5
iteration 6
> x2 <- glmmPQL(y ~ trt + I(week > 2), random = ~ 1 | ID,
+ family = binomial, data = bacteria)
iteration 1
iteration 2
iteration 3
iteration 4
iteration 5
iteration 6
> anova(x1)
numDF denDF F-value p-value
(Intercept) 1 169 35 <.0001
I(week > 2) 1 169 21 <.0001
> anova(x2)
numDF denDF F-value p-value
(Intercept) 1 169 35 <.0001
trt 2 47 2 0.22
I(week > 2) 1 169 20 <.0001
> anova(x1, x2)
Error in anova.lme(x1, x2) : Objects must inherit from classes "gls", "gnls"
"lm","lmList", "lme","nlme","nlsList", or "nls"
After replacement:
> anovaLME(x1, x2)
Model df AIC BIC logLik Test L.Ratio p-value
x1 1 4 1107 1121 -550
x2 2 6 1114 1134 -551 1 vs 2 2.6 0.28
Matt Austin
Statistician
Amgen
One Amgen Center Drive
M/S 24-2-C
Thousand Oaks CA 93021
(805) 447 - 7431
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of Andrew Criswell
> Sent: Wednesday, November 24, 2004 18:47 PM
> To: R-help
> Subject: [R] Error in anova(): objects must inherit from classes
>
>
> Hello:
>
> Let me rephrase my question to attract interest in the
> problem I'm having. When I appply anova() to two equations
> estimated using glmmPQL, I get a complaint,
>
> > anova(fm1, fm2)
> Error in anova.lme(fm1, fm2) : Objects must inherit from
> classes "gls",
> "gnls" "lm","lmList", "lme","nlme","nlsList", or "nls"
> >
>
> The two equations I estimated are these:
>
> > fm1 <- glmmPQL(choice ~ day + stereotypy,
> + random = ~ 1 | bear, data = learning, family
> = binomial)
> > fm2 <- glmmPQL(choice ~ day + envir + stereotypy,
> + random = ~ 1 | bear, data = learning, family
> = binomial)
>
> Individually, I get results from anova():
>
> > anova(fm1)
> numDF denDF F-value p-value
> (Intercept) 1 2032 7.95709 0.0048
> day 1 2032 213.98391 <.0001
> stereotypy 1 2032 0.42810 0.5130
> >
> > anova(fm2)
> numDF denDF F-value p-value
> (Intercept) 1 2031 5.70343 0.0170
> day 1 2031 213.21673 <.0001
> envir 1 2031 12.50388 0.0004
> stereotypy 1 2031 0.27256 0.6017
> >
>
> I did look through the archives but didn't finding anything
> relevant to my problem.
>
> Hope someone can help.
>
> ANDREW
> ____________________________
> _
> platform i586-mandrake-linux-gnu
> arch i586
> os linux-gnu
> system i586, linux-gnu
> status
> major 2
> minor 0.0
> year 2004
> month 10
> day 04
> language R
>
>
>
> --
> Andrew R. Criswell, Ph.D.
> Graduate School, Bangkok University
>
> mailto:andrew.c at bu.ac.th
> <http://email.bu.ac.th/src/compose.php?send_to=andrew.c%40bu.ac.th>
> mailto:andrew at arcriswell.com
> <http://email.bu.ac.th/src/compose.php?send_to=andrew%40arcris
well.com>
______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
More information about the R-help
mailing list