[R] Asymmetrical ANOVA / contrasts

Greg Snow Greg.Snow at intermountainmail.org
Thu Dec 14 18:35:07 CET 2006


You need to specify the how.many argument to C (otherwise it tries to be helpful by creating an additional orthogonal contrast), like this:

 > aov(X~C(loc,c(2,-1,-1),how.many=1))

One of the ways to see what is going on is to do:

> fit1 <- aov(X~C(loc,c(2,-1,-1)), x=TRUE)
> fit2 <- aov(X~C(loc,c(2,-1,-1),how.many=1), x=TRUE)
> fit1$x
> fit2$x

This shows you exactly the x matrix being used, in your case it also shows that you are comparing C1 to the average of C2 and P1 (factor orders the levels alphabetically by default).

You may also want to look at the 'split' argument in the summary.aov function.

Hope this helps,


-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at intermountainmail.org
(801) 408-8111
 

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Joachim Claudet
Sent: Thursday, December 14, 2006 9:35 AM
To: r-help at stat.math.ethz.ch
Subject: [R] Asymmetrical ANOVA / contrasts

Dear all,

I have problems to code contrasts for performing an asymmetrical anova with aov(). I am using aov() because I want to get the Mean Squares for further analyses. I didn't find any solution to my problem in the help files of functions aov(), contrasts(), C(), etc.
Let's say I have three locations, one with treatment P, and two with treatment C:
 > loc=factor(c(P1,P1,P1,P1,P1,C1,C1,C1,C1,C1,C2,C2,C2,C2,C2))
And here is my variable:
 > X=c(21,23,34,32,23,9,4,5,6,8,3,2,8,7,6)
I want to test the effect of location P versus location C Here is what I have done:
 > contrasts(loc)=contr.treatment(3)
 > aov(X~C(loc,c(2,-1,-1)))
This gives me exactly the same result as if I was doing simply
aov(X~loc) without first coding for the contrasts.
I have also tried:
 > aov(X~loc,contrasts=contrasts(loc))

Could somebody tell me how to do?
Any help would be greatly appreciated.
Thanks,
Joachim Claudet.

--
<º)))><  <º)))><  <º)))><  <º)))><  <º)))><  <º)))><  <º)))><  <º)))><

Joachim Claudet

PhD

EPHE - CNRS FRE 2935
52, avenue Paul Alduy
66860 Perpignan cedex
Tel : 33 4 68662055
Fax : 33 4 68503686


<º)))><  <º)))><  <º)))><  <º)))><  <º)))><  <º)))><  <º)))><  <º)))><

______________________________________________
R-help at stat.math.ethz.ch 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.



More information about the R-help mailing list