[R] Treatment-Contrast Interactions

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Feb 22 09:09:26 CET 2005


se.contrast computes standard errors of contrasts.  It does not compute 
the contrast itself, which is fairly simple to do directly.

> c1 <- c(1,-1)[A]*c(1,-1,0)[B]
> sum(c1*score)
[1] -18
> se.contrast(fit, as.matrix(c1))
Contrast 1
   14.24547
> (18/14.24547)^2
[1] 1.596583

so the contrast has value -18, standard error 14.24547, and the squared 
t-ratio is the F statistic 1.5966 you were asking for.  (That's a piece of 
the theory of linear models.)


On Mon, 21 Feb 2005, Lorin Hochstein wrote:

> Peter Dalgaard wrote:
>
>> Lorin Hochstein <lorin at cs.umd.edu> writes:
>> 
>> 
>>> I'd like to understand this approach as well, but I can't reproduce my
>>> results using se.contrast. In particular, I get the same standard
>>> error even though I tried to use different contrasts:
>>> 
>>> > c1 <- c(1,-1)[A]*c(1,-1,0)[B]
>>> > c2 <- c(1,-1)[A]*c(1,0,-1)[B]
>>> > c3 <- c(1,-1)[A]*c(0,1,-1)[B]
>>> > se.contrast(fit, as.matrix(c1))
>>> Contrast 1
>>>  14.24547
>>> > se.contrast(fit,as.matrix(c2))
>>> Contrast 1
>>>  14.24547
>>> > se.contrast(fit,as.matrix(c3))
>>> Contrast 1
>>>  14.24547
>>> 
>> 
>> They could well _be_ the same if the design is balanced...
>> 
>> 
> Hmmm... One of my problems is that I don't know how to interpret the output 
> of se.contrast.
>
> Here's my example again.
>> score <- c(12, 8,10, 6, 8, 4,
>      10,12, 8, 6,10,14,
>       9, 7, 9, 5,11,12,
>       7,13, 9, 9, 5,11,
>       8, 7, 3, 8,12,10,
>      13,14,19, 9,16,14)
>> n <- 6
>> A <- gl(2,3*n,labels=c("a1","a2"))
>> B <- rep(gl(3,n,labels=c("b1","b2","b3")),2)
>> contrasts(B) <- c(1,-1,0)
>> fit <- aov(score~A*B)
>> summary(fit, split=list(B=1:2), expand.split = T)
>           Df  Sum Sq Mean Sq F value   Pr(>F)  A            1  18.778 
> 18.778  2.2208 0.146606  B            2  62.000  31.000  3.6662 0.037629 *
> B: C1      1   1.500   1.500  0.1774 0.676621   B: C2      1  60.500  60.500 
> 7.1551 0.011986 *
> A:B          2  81.556  40.778  4.8226 0.015274 *
> A:B: C1    1  13.500  13.500  1.5966 0.216119     # <---
> A:B: C2    1  68.056  68.056  8.0486 0.008085 **
> Residuals   30 253.667   8.456 
> What I'm really looking for is that F value that's labelled A:B: C1, 1.5966 
> in this case. (I'm not sure what to call this term, AB interaction?)
>
> I thought that it might be possible to use se.contrast to compute this (or at 
> least, to get the numerator so that I could compute the F value once I had 
> the mean square error of the residuals), but I'm not sure how to specify the 
> contrast, and I don't know the relationship between the "standard error" 
> output by se.contrast and the "mean square error" which is the fourth column 
> of the output above.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list