I'm running a lmer mixed effects model with a four-level factor (levels "0","10","100","1000") as the fixed effect.
lmer(free ~ reward.f + (1|S), longdata)
I know that by default, R uses treatment contrasts and the levels 10, 100, and 1000 are compared to level "0". I would instead like each level to be compared to the previous one, to test a monotonic decrease in "free" across levels of "reward.f"
I would do this:
contr.mat <- matrix(c(c(-1,1,0,0),c(0,-1,1,0),c(0,0,-1,1)),4)
colnames(contr.mat) <- c(10,100,1000)
contrasts(longdata$reward.f) <- contr.mat
contrasts(longdata$reward.f)
10 100 1000
0 -1 0 0
10 1 -1 0
100 0 1 -1
1000 0 0 1
Is this the correct contrast matrix for these comparisons?