[R] ANOVA and contrasts

joseclaudio.faria joseclaudio.faria at terra.com.br
Thu May 27 23:40:14 CEST 2004


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




More information about the R-help mailing list