kosukeimai / mediation

R package mediation
58 stars 29 forks source link

Error in if (xhat == 0) out <- 1 else { : #26

Open mg2485 opened 3 years ago

mg2485 commented 3 years ago

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

mg2485 commented 3 years ago

Trying #24 did not help me solving the issue.

yyang77 commented 3 years ago

I received the same error message. Does anyone know how to solve this problem?

minmin0110 commented 3 years ago

I also received the same error message. Could you help me with this issue?

b-staley commented 1 year ago

Did anyone figure out how to address this issue?

feifei1024-1024 commented 2 months ago

same error

Yinan-Jiang commented 1 month ago

same error 😭

feifei1024-1024 commented 1 month ago

你好,您发我的邮件已经收到。感谢您对我们工作的积极配合。谢谢