3
$\begingroup$

My question is:

Is there a way to either force Anova() to somehow analyze gls objects (which internally are almost identical to lme objects), or force Anova() to honor the test.statistics='F' argument, or at least do a valid type-II sum of squares by hand on an lme and a gls object?

Why:

I'm trying to get Anova output in the same format for an lm or aov or gls object and an lme object that uses the same fixed effects formula but in addition has random effects. If I use Anova() from the car package, I get F-statistics for aov and lm objects but Chi-square statistics for lme objects, and it doesn't work at all for gls objects [1].

If I use anova.gls() and anova.lme() then they do both return F-statistics, but they use type-III or type-I sum of squares and I'm trying to use type-II.

[1]: Gives error Error in eval(expr, envir, enclos) : object 'y' not found where y is the response variable... this can be traced to the attribute for model.matrix() for gls objects failing to have an assign attribute.

$\endgroup$
1

1 Answer 1

2
$\begingroup$

As it turns out, I shouldn't even be concerned about the type of sum of squares if all I'm trying to do is compare a gls and a mixed-effect model with the same fixed effects. The only contrast in this comparison is between those two models. When invoked on more than one object, R's anova() function is just a likelihood ratio test. If I include more than two objects, the contrast is always going to be backward difference coding (i.e. each model minus its predecessor).

If fm2 is an lme fit, the following does work:

gfm2<-gls(model=eval(fm2$call$fixed),data=eval(fm2$call$data));
anova(gfm2,fm2);

The problem with Anova() not working with gls fits I think is a bug, and as of car 2.0.15 still has not been fixed.

$\endgroup$
1
  • 1
    $\begingroup$ I didn't understand you wanted to test a submodel. It would have been more clear with a piece of code :) $\endgroup$ Mar 21, 2013 at 22:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.