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

From: Joris Meys <jorismeys_at_gmail.com>
Date: Thu, 03 Jun 2010 03:05:31 +0200

On Thu, Jun 3, 2010 at 3:00 AM, Joris Meys <jorismeys_at_gmail.com> wrote:

> That's what one would expect with type III sum of squares. You have Phyto
> twice in your model, but only as a nested factor. To compare the full model
> with a model without diversity of zoop, you have either the combination
> diversity/phyto, zoop/phyto or phyto twice in the formula. That's aliasing.
>
> Depending on how you stand on type III sum of squares, you could call that
> a "bug". Personally, I'd just not use them.
>
> https://stat.ethz.ch/pipermail/r-help/2001-October/015984.html
>
> Cheers
> Joris
>
>
> On Thu, Jun 3, 2010 at 2:13 AM, Anita Narwani <anitanarwani_at_gmail.com>wrote:
>
>> 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
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>
>
> --
> Joris Meys
> Statistical Consultant
>
> Ghent University
> Faculty of Bioscience Engineering
> Department of Applied mathematics, biometrics and process control
>
> B-9000 Gent
>
> tel : +32 9 264 59 87
> Joris.Meys_at_Ugent.be
> -------------------------------
> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
>

```--
Joris Meys
Statistical Consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

B-9000 Gent

tel : +32 9 264 59 87
Joris.Meys_at_Ugent.be
-------------------------------
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

[[alternative HTML version deleted]]

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help