[R] interaction contrasts

Kay Cichini Kay.Cichini at uibk.ac.at
Fri Oct 15 15:09:24 CEST 2010


..by some (extensive) trial and error reordering the contrast matrix and the
reference level 
i figured it out myself -
for anyone who might find this helpful searching for a similar contrast in
the future: 
this should be the right one:

c2<-rbind("fac2-effect in A"=c(0,1,0,0,0,0,0,0),
          "fac2-effect in B"=c(0,1,0,0,0,1,0,0),
          "fac2-effect in C"=c(0,1,0,0,0,0,1,0),
          "fac2-effect in D"=c(0,1,0,0,0,0,0,1),
	    "fac2-effect, A*B"=c(0,0,0,0,0,1,0,0),
          "fac2-effect, A*C"=c(0,0,0,0,0,0,1,0),
          "fac2-effect, A*D"=c(0,0,0,0,0,0,0,1),
	    "fac2-effect, B*C"=c(0,0,0,0,0,-1,1,0),
	    "fac2-effect, B*D"=c(0,0,0,0,0,-1,0,1),
	    "fac2-effect, C*D"=c(0,0,0,0,0,0,-1,1))

summary(glht(mod,c2))


Kay Cichini wrote:
> 
> hello,
> 
> i was shortly asking the list for help with some interaction contrasts
> (see below) for which
> i had to change the reference level of the model "on the fly" (i read a
> post that this is possible in 
> multcomp).
> 
> if someone has a clue how this is coded in multcomp; glht() - please point
> me there.
> 
> yours,
> kay
> 
> 
> Kay Cichini wrote:
>> 
>> hello list,
>> 
>> i'd very much appreciate help with setting up the 
>> contrast for a 2-factorial crossed design.
>> 
>> here is a toy example:
>> 
>> library(multcomp)
>> 
>> dat<-data.frame(fac1=gl(4,8,labels=LETTERS[1:4]),
>>                 fac2=rep(c("I","II"),16),y=rnorm(32,1,1))
>> 
>> mod<-lm(y~fac1*fac2,data=dat)
>> 
>> ## the contrasts i'm interressted in:
>> 
>> c1<-rbind("fac2-effect in A"=c(0,1,0,0,0,0,0,0),
>>           "fac2-effect in B"=c(0,1,0,0,0,1,0,0),
>>           "fac2-effect in C"=c(0,1,0,0,0,0,1,0),
>>           "fac2-effect in D"=c(0,1,0,0,0,0,0,1),
>> 	    "fac2-effect, A*B"=c(0,0,0,0,0,1,0,0),
>>           "fac2-effect, A*C"=c(0,0,0,0,0,0,1,0),
>>           "fac2-effect, A*D"=c(0,0,0,0,0,0,0,1))
>> 
>> summary(glht(mod,c1))
>> 
>> ## now i want to add the remaining combinations 
>> ## "fac2, B*C"
>> ## "fac2, B*D"
>> ## "fac2, C*D"
>> ## to the simultanous tests to see whether the effects 
>> ## of fac2 within the levels of fac1 differ between  
>> ## each combination of the levels of fac1, or not ??
>> 
>> thanks for any advise!
>> 
>> yours,
>> kay
>> 
>> 
>> 
> 
> 


-----
------------------------
Kay Cichini
Postgraduate student
Institute of Botany
Univ. of Innsbruck
------------------------

-- 
View this message in context: http://r.789695.n4.nabble.com/interaction-contrasts-tp2993845p2996987.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list