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

From: Anita Narwani <anitanarwani_at_gmail.com>
Date: Wed, 02 Jun 2010 17:13:36 -0700

Hello,

I have been trying to get an ANOVA table for a linear model containing a single nested factor, two fixed factors and a covariate:

carbonmean<-lm(C.Mean~ Mean.richness + Diversity + Zoop + Diversity/Phyto + Zoop*Diversity/Phyto)

where, *Mean.richness* is a covariate*, Zoop* is a categorical variable (the species), *Diversity* is a categorical variable (Low or High), and *Phyto*(community composition) is also categorical but is nested within the level
of *Diversity*. Quinn & Keough's statistics text recommends using Type III SS for a nested ANOVA with a covariate.

I get the following output using the Type I SS ANOVA:

Analysis of Variance Table
Response: C.Mean

```                                                Df        Sum Sq           Mean
Sq          F value            Pr(>F)
Mean.richness                        1          56385326        56385326
23.5855           3.239e-05 ***
Diversity                                 1          14476593        14476593
6.0554             0.019634 *
Zoop                                        1          13002135
13002135
5.4387             0.026365 *
Diversity:Phyto                      6          126089387      21014898
8.7904             1.257e-05 ***
Diversity:Zoop                       1          263036
263036
0.1100              0.742347
Diversity:Zoop:Phyto             6          61710145        10285024
4.3021
0.002879 **
Residuals                                31        74110911
```
2390675

I have tried using both the drop1() command and the Anova() command in the car package.

When I use the Anova command I get the following error message:

>Anova(carbonmean,type="III")

“Error in linear.hypothesis.lm(mod, hyp.matrix, summary.model = sumry,: One or more terms aliased in model.”

I am not sure why this is aliased. There are no missing cells, and the cells are balanced (aside from for the covariate). Each Phyto by Zoop cross is replicated 3 times, and there are four Phyto levels within each level of Diversity. When I remove the nested factor (Phyto), I am able to get the Type III SS output.

Then when I use drop1(carbonmean,.~.,Test=”F”) I get the following output:

> drop1(carbonmean,.~.,Test="F")

Single term deletions

Model:

C.Mean ~ Mean.richness + Diversity + Zoop + Diversity/Phyto + Zoop * Diversity/Phyto

```                                                Df        Sum of Sq

<none>                                                74110911       718

Mean.richness                        1          49790403        123901314
```
741
```Diversity                                 0         0
74110911        718

Zoop                                        0         0
74110911        718

Diversity:Phyto                      6          118553466      192664376
```
752
```Diversity:Zoop                       0          -1.49e-08        74110911
```
718

Diversity:Zoop:Phyto 6 61710145 135821055 735

There are zero degrees of freedom for Diversity, Zoop and their interaction, and zero sums of sq for Diversity and Zoop. This cannot be correct, however when I do the model simplification by dropping terms from the models manually and comparing them using anova(), I get virtually the same results.

I would appreciate any suggestions for things to try or pointers as to what I may be doing incorrectly.

Thank you.

Anita Narwani.

[[alternative HTML version deleted]]

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 03 Jun 2010 - 00:16:45 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 04 Jun 2010 - 00:00:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.