[R] ANOVA and contrasts

F Z gerifalte28 at hotmail.com
Fri May 28 00:34:30 CEST 2004


Oi Claudio

Check ?contrasts ?C or to create your custom contrasts to then be used in 
your model

i.e.

>MyContrast<-matrix(c(1,1,0,1,0,0),ncol=2)
>MyContrast
     [,1] [,2]
[1,]    1    1
[2,]    1    0
[3,]    0    0
>data(iris)
>attach(iris)
>contrasts(Species)
           versicolor virginica
setosa              0         0
versicolor          1         0
virginica           0         1
>contrasts(Species)<-MyContrast
>contrasts(Species)
           [,1] [,2]
setosa        1    1
versicolor    1    0
virginica     0    0

I hope that this helps

Francisco



>From: "joseclaudio.faria" <joseclaudio.faria at terra.com.br>
>To: R - Grupo de discussão R <r-help at stat.math.ethz.ch>
>Subject: [R] ANOVA and contrasts
>Date: Thu, 27 May 2004 18:40:14 -0300
>
>Dears members of R list,
>
>I would like that a more experienced R user help me to complete
>this analysis:
>
>r = gl(3, 8, label = c('r1', 'r2', 'r3'))
>e = rep(gl(2, 4, label = c('e1', 'e2')), 3)
>y = c(26.2, 26.0, 25.0, 25.4, 24.8, 24.6, 26.7, 25.2, 25.7, 26.3, 25.1, 
>26.4,
>          19.6, 21.1, 19.0, 18.6, 22.8, 19.4, 18.8, 19.2, 19.8, 21.4, 22.8, 
>21.3)
>
>df = data.frame(r, e, y)
>attach(df)
>   par(mfrow=c(2,1))
>   interaction.plot(r, e, y, col = 'blue', ylab = 'y', xlab = 'r')
>
>   interaction.plot(e, r, y, col = 'blue', ylab = 'y', xlab = 'r')
>   av1 = aov(y ~ r*e)
>
>   av2 = aov(y ~ r/e)
>   efR_E = summary(av2, split = list('r:e' = list('e1 vs e2/r1' = 1, 'e1 vs
>e2/r2' = 2, 'e1 vs e2/r3' = 3)))
>
>   av3  = aov(y ~ e/r)
>   efE_R = summary(av3, split = list('e:r' = list('r/e1' = c(1,3), 'r/e2' =
>c(2,4))))
>
># ------------------------------Begin the problem-------------------------
>#
># I woud like to compare r/e1 (SS = 87.122 with 2 GL) like this:
># r1 vs (r2,r3 ) / e1
># r2 vs r3 / e1
>
>
># And compare r/e2 (SS = 69.500 with 2 GL) like this:
># r1 vs (r2,r3 ) / e2
># r2 vs r3 / r1 / e2
>
>#
># ------------------------------End the problem----------------------------
>
>   mds = model.tables(av1, ty = 'means')
>detach(df)
>
>cat('\nData:'); cat('\n')
>print(df)
>
>cat('\nMeans:'); cat('\n')
>print(mds)
>
>cat('\nANOVA:'); cat('\n')
>print(summary(av1)); cat('\n')
>
>cat('\nANOVA - E effect in R levels:'); cat('\n')
>print(efR_E); cat('\n')
>
>cat('\nANOVA - R effect in E levels:'); cat('\n')
>print(efE_R); cat('\n')
>
>Best regards,
>
>Saudações,
>
>José Cláudio Faria
>UESC/DCET
>Brasil
>73-634.2779
>joseclaudio.faria at terra.com.br
>jc_faria at uol.com.br
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! 
>http://www.R-project.org/posting-guide.html

_________________________________________________________________

http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/




More information about the R-help mailing list