Hi,

I have been using the mediation package in R to test for mediation in
multilevel data.
My data is as follows:
X: continuous, M: binary, and Y: binary  (Y:outcome, M: mediator)
I'm testing a 1-1-1 mediation.

I get different results when I use random slopes in the equations and when
I don't. My code is as follows:

> med.fit <- glmer(M ~ X + (1+X | Subject), family = binomial(link =
"logit"), data = data1, control=glmerControl(optimizer="bobyqa",
check.conv.sing="warning"))

> out.fit <- glmer(Y ~ M+ X + (1 + M + X | Subject), family = binomial(link
= "logit"), data = data1, control=glmerControl(optimizer="bobyqa",
check.conv.sing="warning"))

> med.out <- mediate(med.fit, out.fit, treat = "X", mediator = "M", sims =
1000)
> summary(med.out)

With one part of my data I get a singular fit error for the out.fit
command. When I only use (1|Subject) instead of (1+M+X|Subject), then I
don't get this error, but I get totatlly different results in terms of
mediation.

Could you please help me? Should I use random slopes or not?
Is the singular fit error a serious error? (Correlations within data are
not very high, around .10-.15).

Thank you.

	[[alternative HTML version deleted]]


