mediation
mediation copied to clipboard
Error in if (xhat == 0) out <- 1 else { :
Using the mediate function (please see my code below), I receive the following error message. I would like to estimate a multilevel mediation for the following 2x5 mixed design. While the IV is manipulated between-subjects, the DV is a repeated measure (binary). In particular, each participant made 5 binary choices for 5 different choice sets (within-subject). The mediator (i.e., perceived expertise) is a repeatedly measured continuous variable, which was measured after each choice.
Do you have any idea what could be wrong with my code?
Error in if (xhat == 0) out <- 1 else { : missing value where TRUE/FALSE needed
med.fit <- lmer(Expertise ~ Condition + (1|SubjectID), data = data) out.fit <- glmer(Choice ~ Expertise + Condition + (1 + Expertise|SubjectID), family = binomial(link = "logit"), data = data)
med.out <- mediate(med.fit, out.fit, treat = "Condition", mediator = "Expertise", sims = 5000)
summary(med.out)
The data looks like the following: SubjectID I ChoiceSet I Condition I Expertise I Choice 1 I 1 I 0 I 5 I 1 1 I 2 I 0 I 4 I 1 1 I 3 I 0 I 4 I 0 1 I 4 I 0 I 4 I 0 1 I 5 I 0 I 3 I 0 2 I 1 I 1 I 3 I 1 2 I 2 I 1 I 3 I 1 2 I 3 I 1 I 4 I 1 2 I 4 I 1 I 4 I 1 2 I 5 I 1 I 5 I 0
Trying #24 did not help me solving the issue.
I received the same error message. Does anyone know how to solve this problem?
I also received the same error message. Could you help me with this issue?
Did anyone figure out how to address this issue?
same error
same error 😭
你好,您发我的邮件已经收到。感谢您对我们工作的积极配合。谢谢