Skip to content
Prev 355905 / 398500 Next

Nested ANOVA yields surprising results

That would depend on which hypothesis you test in which model. If a reference tells you that you "should" do something without specifying the model, then you "should" look at a different reference.

In general, having anything other than the residual MS in the denominator indicates that you think it represents an additional source of random variation. I don't think that is invariably the case in nested designs (and, by the way, notice that "nested" is used differently by different books and software).

If you don't say otherwise, R assumes that there is only one source of random variation the model - a single error term if you like - and that all other terms represent systematic variations. In this mode of thinking, an A:B term represents an effect of B within A (additive and interaction effects combined), and you can test for its presence by comparing MS_A:B to MS_res. In its absence, you might choose to reduce the model and next look for an effect of A; purists would do this by comparing MS_A to the new MS_res obtained by pooling MS_A:B and MS_res, but lazy statisticians/programmers have found it more convenient to stick with the original MS_res denominator throughout (to get the pooling done, just fit the reduced model). 

If you want A:B to be a random term, then you need to say so, e.g. using
Error: A:B
            Df Sum Sq Mean Sq F value Pr(>F)
A            2 0.4735  0.2367   0.403    0.7
Residuals    3 1.7635  0.5878               

Error: Within
          Df Sum Sq Mean Sq F value Pr(>F)
Residuals  6  4.993  0.8322               

(the -1 in the Error() term prevents an error message, which as far as I can tell is spurious).

Notice that you need aov() for this; lm() doesn't do Error() terms. This _only_ works in balanced designs.

-pd