[R] Cannot get contrasts to work with aov.

ThatDeadDude t3rdperson at hotmail.com
Sun Sep 16 01:52:38 CEST 2007


I have been trying for hours now to perform an orthogonal contrast through an
ANOVA in R.   

I have done a two-factor factorial experiment, each factor having three
levels.  I converted this dataset to a dataframe with one factor with nine
treatments, as I couldn't work out what else to do.   
I have set up a matrix with the eight orthogonal contrasts that I wish to
perform, but despite having searched this mailing list's archives
thoroughly, I cannot get it to work. 

I am looking to get output along the lines of 
            Df  Sum Sq Mean Sq F value    Pr(>F)     
trt1         1    X         X              X           X 
trt2         1    X         X              X           X 
 ............... 
trt9         1    X         X              X           X 
Residuals   27   495.1   18.3 

However, for everything I've tried, I've simply gotten 

            Df  Sum Sq Mean Sq F value    Pr(>F)     
trt          8 17919.7  2240.0  122.16 < 2.2e-16 *** 
Residuals   27   495.1    18.3         

I have done 
trt <- as.factor(trt) 
contrasts(trt) <- cntrs 
when I then type contrasts(trt), it returns what I expect. 

However, whether I try 
test <- aov(time2 ~ trt) 
test <- aov(time2 ~ trt, contrasts=contrasts(trt)) 
test <- aov(time2 ~ C(trt, cntrs, how.many=8)) 
or anything else I can think of, I only get what I posted above.  I'm
assuming I'm doing something fundamentally wrong, but for the life of me I
can't work out what, and it's killing me at present. 

Any responses would be greatly appreciated 
Marc Burgess
-- 
View this message in context: http://www.nabble.com/Cannot-get-contrasts-to-work-with-aov.-tf4449485.html#a12695182
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list