Skip to content

Confusion about contrasts

2 messages · Marius, Reinhold Kliegl

#
Your solution is ok. Basically, for the set of prime contrasts you
want to use you need to take the generalized inverse  (see, e.g.,
Venables & Ripley, 2002, MASS, section 6.2, p. 144-150). That's what
make.contrasts() does. Alternatively, you can use:

################
library(MASS) # for ginv() and fractions()

# target contrast
contrasts(trimmedwords$target) <- contr.sdif(2)  # avoid treatment
contrast for target factor

# prime contrasts
(primeconts<-cbind(c(-1,0,1,0), c(0,-1,1,0), c(0,0,-1,1)))
(cmat1 <- fractions(ginv(t(primeconts))))
contrasts(trimmedwords$prime) <- cmat1
priming.model<-lmer(react~target*prime+(1|subject)+(1|item),data=trimmedwords)

# alternative contrasts
(altconts <- cbind(c(-1,0,1,0), c(0,-1,1,0), c(-1,1,0,0)))
(cmat2 <- fractions(ginv(t(altconts))))
contrasts(trimmedwords$prime) <- cmat2
priming.model<-lmer(react~target*prime+(1|subject)+(1|item),data=trimmedwords)

#################

Obviously, you don't need to do this if cmat == ginv(t(cmat))--as is
the case for treatment and a few other types of contrasts. Also, this
is nothing special about lmer(), but applies to all linear models
using a model matrix in R.

Reinhold Kliegl
On Mon, Jul 18, 2011 at 1:41 AM, Marius <marius.mather at gmail.com> wrote: