joseclaudio.faria
2004-May-26 19:58 UTC
[R] R: Help (two-way analysis of variance with contrasts)
Dears members of R list, It would like that a more experienced statician in R helped me to complete the analysis to follow: 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)))) 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') #I would like to get as resulted (efE_R) like this: # ANOVA - R effect (contrasts) in E levels: # Df Sum Sq Mean Sq F value Pr(>F) # e 1 19.082 # e:r (4) (156.622) # e:r: r/e1 (2) (87.122) # r1 vs (r2,r3)/e1 1 ? ? ? ? # r2 vs r3/e1 1 ? ? ? ? # e:r: r/e2 (2) (69.500) # r1 vs (r2,r3)/e1 1 ? ? ? ? # r2 vs r3/e2 1 ? ? ? ? # Residuals 18 23.090 1.283 #Through manual calculations I got: # ANOVA - R effect in E levels: # Df Sum Sq Mean Sq F value Pr(>F) # e 1 19.082 # e:r (4) (156.622) # e:r: r/e1 (2) (87.122) # r1 vs (r2,r3)/e 1 19.26 # r2 vs r3/e1 1 67.86 # e:r: r/e2 (2) (69.500) # r1 vs (r2,r3)/e 1 63.38 # r2 vs r3/e2 1 6.12 # Residuals 18 23.090 1.283 Best regards, Jos?? Cl??udio Faria UESC/DCET Brasil 73-634.2779 joseclaudio.faria at terra.com.br jc_faria at uol.com.br