Helmert coding for mixed models in R I am using R to analyse data from an experiment with six conditions. Condition has two dimensions: for cognitive load, I have two levels (load and no load) and for language structure I have three levels (structured, partially structured and unstructured). These are then fully crossed giving the six conditions. They are all between-subjects.
I want to run a mixed effects model with the two condition dimensions and the interaction between them as predictors, and a numeric accuracy dependent variable.
My supervisor mentioned that I could use Helmert coding for the structure conditions but I can find very little information about how this works and any resources I have found don't explain how the contrasts are generated in enough detail for me to know what the R code is doing. From what I can understand it does seem like the right coding scheme, as what I basically want to know is whether there's a difference between structured languages and the rest, and whether there's a difference between partially structured and unstructured languages - I think this is what "comparing the mean of each level to subsequent levels" is doing? But I'm really stuck on how to create these contrasts and then how to use them in a mixed model. Any help would be much appreciated - even if it's just to point me to any more detailed resources on Helmert coding.

Here is an example of using Helmert contrasts with lme4. First we smulate some data:
set.seed(1)
n_group <- 10
dt <- expand.grid(X = LETTERS[1:3], G = LETTERS[1:n_group], reps = 1:2)
X <- model.matrix(~ X, dt)

dt$Y <- 1
myFormula <- "Y ~ X + (1 | G)"

foo <- lFormula(eval(myFormula), dt)
Z <- t(as.matrix(foo$reTrms$Zt))

betas <- c(1, 0.5, 2) # Fixed effects parameters

u <- rnorm(n_group, 0, 2) # standard deviation of random intercepts

e <- rnorm(nrow(dt), 0, 1)   # residual error

dt$Y <- X %*% betas + Z %*% u + e   

Now we set the contrast matrix and specify it when we call lmer
ch <- contr.helmert(3)   # Because X has 3 levels

lmer(myFormula, dt, contrasts = list(X = ch))
```

