Contrast for hypothesis test in R (lmer) 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?
 A: You are looking for sliding differences aka. repeated contrasts, i.e., $0\ vs. 10$, $10\ vs. 100$, and $100\ vs. 1000$. But your contrast matrix is not appropriate for these tests.
     10 100 1000
0    -1   0    0
10    1  -1    0
100   0   1   -1
1000  0   0    1

Actually, these contrasts test (1) the mean of the first level ($0$) against the mean of levels two, three, and four ($10$, $100$, and $1000$), (2) the mean of the first two levels against the mean of the last two levels, and (3) the mean of the first three levels against the mean of the last level.
The correct contrast matrix for sliding differences (given a categorical variable with four levels) is:
        10  100  1000
0    -0.75 -0.5 -0.25
10    0.25 -0.5 -0.25
100   0.25  0.5 -0.25
1000  0.25  0.5  0.75

For more details, have a look at this answer: How to interpret these custom contrasts?
A: Yes [Actually no, you have to take the transpose of the generalized inverse of this matrix and set that as the contrast matrix, as Sven points out] - in the first contrast (column), '10' is compared with '0'; in the second, '100' with '10'; in the third '1000' with '100'.  Note that these are not orthogonal: if it's not strictly monotonicity you're concerned with you may want to consider [reverse] Helmert contrasts, which compare each level with the mean of subsequent [preceding] levels; or polynomial contrasts, which will split the factor effect into linear, quadratic, & cubic effects.
PS The column names you've given are a bit confusing, as they're the same as the level names.
