在R中运行HLM中介

时间:2018-09-23 14:02:19

标签: r

我尝试使用“中介”包运行HLM中介:

med.fit <- glmer(M ~ treat + control  + (1|subject_id) ,family = binomial(link = "logit"), data = R1_data)

out.fit <- glmer(Y ~ M+ treat + control+ (1 + M|subject_id),family = binomial(link = "logit"), data = R1_data)

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

我收到此错误消息:

  

[.data.frame(y.data,int.term.name [p])中的错误:未定义的列已选中

如何解决这个问题? 这是原始数据和代码:

名称(R1_data)

[1]“ subject_id”
 [3]“ Presented_is_solvable”
 [5]“ JOS”
[17]“ Answer_JOS”
[23]“ Matrix_Z_score”

图书馆(中介)

med.fit <-glmer(JOS〜Matrix_Z_score + Presented_is_solvable +(1 | subject_id),家庭=二项式(link =“ logit”),数据= R1_data)

out.fit <-glmer(答案_JOS〜JOS + Matrix_Z_score + Presented_is_solvable +(1 + JOS | subject_id),家庭=二项式(link =“ logit”),数据= R1_data)

med.out <-中介(med.fit,out.fit,对待=“ Matrix_Z_score”,中介=“ JOS”,sims = 1000)

0 个答案:

没有答案