Java Mailing List Archive

http://www.r-help.com/

Home » Home (12/2007) » R Help for Statistical Computing »

[R] Treatment-Contrast Interactions

Lorin Hochstein

2005-02-20

Replies:

Hello all,

(Apologies in advance if my terminology is incorrect, I'm relatively new
to R and statistics).

I have data from a factorial design with two treatments (CRF-23), and
I'm trying to compute treatment-contrast interactions through analysis
of variance. I can't figure out how to do contrasts properly, despite
reading the help for "C" and "contrasts" functions.

(I'm actually trying to solve an exercise in a textbook: "Experimental
Design" by Kirk, Ex. 9.7b).

Here's what my data looks like:

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)

I understand how to test for the effects of A, B, and AB:
summary(aov(score~A*B))

Let's say I want to compute some contrasts on B and see if there is an
interaction with A. I try to specify a matrix with the columns being the
different contrasts on B:

contrasts.B <- matrix(c(1,-1,0,1,0,-1,0,1,-1),nrow=3)

I know the following is wrong:
summary(aov(score~A*B,contrasts=contrasts.B))

I know I'm doing multiple things wrong here, because R can't possibly
know I want those contrasts to be for the "B" variable, and because
passing a contrast matrix never seems to change the result no matter
what I do, so clearly I misunderstand how contrasts work. Can anyone advise?

(I really want the result for each contrast separately, so should I be
passing one vector as an argument to contrasts?)

Lorin

______________________________________________
R-help@(protected)
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
©2008 r-help.com - Jax Systems, LLC, U.S.A.