mediation::mediate does not support more than two levels per model When I fit a mediation model using mediation::mediate, like this:
library(mediation)

set.seed(30)

df <- data.frame(x = runif(100), 
                 x2 = runif(100),
                 y = runif(100), m = runif(100), 
                 p_id = sample(1:5, 100, replace = TRUE), 
                 item = sample(LETTERS, 100, replace = TRUE))

fit.totaleffect <- lmer(y ~ (1|item) + (1|p_id) + x + x2, data = df)

fit.mediator <- lmer(m ~ (1|item) + (1|p_id) + x + x2, data = df)

fit.dv <- lmer(y ~ (1|item) + (1|p_id) + x  + x2 + m, data = df)

results <- mediation::mediate(fit.mediator, fit.dv, treat=c('x1', 'x2'), mediator='m')

I get the error, "mediate does not support more than two levels per model".
In another answer, someone says:

"The mediate function in the mediation package takes only a binary
mediator or a numeric mediator. In your case, it seems that your
mediator is categorical but contains more than 2 levels. You can
either convert it to numeric or dummy code it."

However, this does not apply to my data. My data seems to be suitable (the mediator is numeric), based on this.
So what is wrong?
(NB. my actual data doesn't raise the boundary (singular) warning, but otherwise has the same qualities as the dummy data above).

The two levels refers to the two random effects in your model (i.e., two levels in a multilevel model). mediate() doesn't support that. Nothing to do with your treatment variable.
