[R] Nested ANOVA with covariate using Type III sums of squares

Joris Meys jorismeys at gmail.com
Fri Jun 4 01:25:20 CEST 2010


I see where my confusion comes from. I counted 4 levels of Phyto, but
you have 8, being 4 in every level of Diversity. There's your
aliasing.

> table(Diversity,Phyto)
         Phyto
Diversity M1 M2 M3 M4 P1 P2 P3 P4
        H  0  0  0  0  6  6  6  6
        L  6  6  6  6  0  0  0  0

There's no need to code them differently for every level of Diversity.
If you don't, all is fine :

> Phyto <- gsub("M","P",as.character(Phyto))
> Phyto <- as.factor(Phyto)
>
> test <- lm(C.Mean~  Mean.richness + Diversity + Zoop + Diversity/Phyto +
+ Zoop*Diversity/Phyto)
>
> Anova(test,type="III")
Anova Table (Type III tests)

Response: C.Mean
                        Sum Sq Df F value    Pr(>F)
(Intercept)           23935609  1 10.0121 0.0034729 **
Mean.richness         49790385  1 20.8269 7.471e-05 ***
Diversity             35807205  1 14.9779 0.0005234 ***
Zoop                  10794614  1  4.5153 0.0416688 *
Diversity:Phyto      118553464  6  8.2650 2.184e-05 ***
Diversity:Zoop          261789  1  0.1095 0.7429356
Diversity:Zoop:Phyto  61710162  6  4.3021 0.0028790 **
Residuals             74110938 31
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>

You can check with summary(test) that the model is fitted correctly.

On Fri, Jun 4, 2010 at 12:48 AM, Anita Narwani <anitanarwani at gmail.com> wrote:
>
> You have everything right except that there are only 2 zooplankton species (C & D, which stand for Ceriodaphnia and Daphnia).
>



More information about the R-help mailing list