[R] linear contrasts for trends in an anova

Colm Connolly colm.connolly at tcd.ie
Fri Dec 18 16:13:18 CET 2009


Hi everybody,

I'm trying to construct contrasts for an ANOVA to determine if there is a significant trend in the means of my groups.

In the following example, based on the type of 2x3 ANOVA I'm trying to perform, does the linear polynomial contrast generated by contr.poly allow me to test for a linear trend across groups?

doi=data.frame(
  Group=c(
    rep(1, 5),  rep(2, 5),  rep(3, 5), rep(1, 5),  rep(2, 5),  rep(3, 5)),
  Mean_1=c(
    rnorm(5, mean=3, sd=1), rnorm(5, mean=5.7, sd=1.2), rnorm(5, mean=7, sd=1.3),
    rnorm(5, mean=3.5, sd=1), rnorm(5, mean=3, sd=1.2), rnorm(5, mean=4.2, sd=1.7)),
  eventType=c( rep("errors", 15), rep("stops", 15)))
doi$Group=factor(doi$Group, labels=c("Control", "Short", "Long"), ordered=T)

## construct contrasts
contrasts(doi$Group)=contr.poly(levels(doi$Group))

model1=aov(Mean_1 ~ Group*eventType, data=doi)
model1.summary=summary(model1)
print(model1.summary)
print(summary.lm(model1))

Thanks in advance,

Regards,
--
Dr Colm G. Connolly
Institute of Neuroscience
The Lloyd Building
University of Dublin
Trinity College, Dublin 2, Éire
Fax: +353-1-671-3183

Please note that electronic mail to, from or within the Trinity College Dublin, may be the
subject of a request under the Freedom of Information Act.





More information about the R-help mailing list