# [R] anova interaction contrasts: crossing helmert and linear contrasts

Katie Surrence tiburona at gmail.com
Tue Oct 27 21:32:36 CET 2009

```I am new to statistics, R, and this list, so apologies in advance for
the errors etiquette I am certain to make (in spite of reading the
posting guide, help on
various commands, etc.).  Any help is greatly appreciated.

Here is my data:

fatigue = c(3,2,2,3,2,3,4,3,2,4,5,3,3,2,4,5,4,5,5,6,4,6,9,8,4,3,5,5,6,6,6,7,9,10,12,9)
n <- 3
train <- gl(3, 4*n, labels=c("6wks", "4wks", "2wks"))
dist <- rep(gl(4,n,labels=c("1mi","2mi","3mi","4mi")),3)

What I would like to do is test two interaction contrasts that cross linear
coefficients of the variable "dist" with the two sets of helmert contrasts of
the variable "train".

I have tried so many things I think are wrong I won't reproduce them all here.
Here is a representative example:

My code:

contrasts(dist) = c(-3, -1, 1, 3)
contrasts(train) = contr.helmert(3)
aov1 = aov(fatigue~dist*train)
summary(aov1, intercept = T, split=list(train=1:2), expand.split = T)

My output:

Df Sum Sq Mean Sq  F value    Pr(>F)
(Intercept)       1 890.03  890.03 801.0250 < 2.2e-16 ***
dist              3  85.19   28.40  25.5583 1.199e-07 ***
train             2  88.39   44.19  39.7750 2.403e-08 ***
train: C1       1  18.38   18.38  16.5375 0.0004452 ***
train: C2       1  70.01   70.01  63.0125 3.621e-08 ***
dist:train        6  18.72    3.12   2.8083 0.0325092 *
dist:train: C1  3   3.46    1.15   1.0375 0.3938042
dist:train: C2  3  15.26    5.09   4.5792 0.0113201 *
Residuals        24  26.67    1.11
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Among the reasons this seems wrong to me is that I want 1 df
interaction contrasts. "dist:train: C1" and "dist:train: C2" seem (to
my naive eye) to be testing respectively whether my first and second
helmert contrast of train differ significantly across levels of dist.
I want to test the significance of two contrasts of linear trend over
dist--the slope of linear trend at 6wks and  4wks against each other,
and the average of the slopes at 6wks and 4wks against the slope at
2wks.  I don't know how to do this.