[R] linear contrasts for trends in an anova
ONKELINX, Thierry
Thierry.ONKELINX at inbo.be
Fri Dec 18 17:05:28 CET 2009
Dear Colm,
Use lm() instead of aov() and your problem is solved. The parameter of Group.L is the linear trend along your groups. Group.Q the quandratic trend.
HTH,
Thierry
summary(lm(Mean_1 ~ Group*eventType, data=doi))
Call:
lm(formula = Mean_1 ~ Group * eventType, data = doi)
Residuals:
Min 1Q Median 3Q Max
-2.88504 -0.74862 -0.01771 0.92154 2.62031
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 5.1360 0.3610 14.229 3.41e-13 ***
Group.L 2.7761 0.6252 4.440 0.000172 ***
Group.Q -0.6375 0.6252 -1.020 0.318091
eventTypestops -2.0464 0.5105 -4.009 0.000515 ***
Group.L:eventTypestops -2.3123 0.8842 -2.615 0.015175 *
Group.Q:eventTypestops 1.9637 0.8842 2.221 0.036049 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 1.398 on 24 degrees of freedom
Multiple R-squared: 0.6357, Adjusted R-squared: 0.5598
F-statistic: 8.375 on 5 and 24 DF, p-value: 0.0001073
----------------------------------------------------------------------------
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium
Research Institute for Nature and Forest
team Biometrics & Quality Assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
Thierry.Onkelinx at inbo.be
www.inbo.be
To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of.
~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data.
~ Roger Brinner
The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey
-----Oorspronkelijk bericht-----
Van: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Namens Colm Connolly
Verzonden: vrijdag 18 december 2009 16:13
Aan: r-help at stat.math.ethz.ch
Onderwerp: [R] linear contrasts for trends in an anova
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.
Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.
Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in this message
and any annex are purely those of the writer and may not be regarded as stating
an official position of INBO, as long as the message is not confirmed by a duly
signed document.
More information about the R-help
mailing list