我正在通过W1_cesd查看AUDITCEN-> INTERN的中介。
AUDITCEN和INTERN之间的关系是二次方的,但是AUDITCEN和W1_cesd之间的关系是线性的。我认为这导致了我的问题....
我正在跑步:
dyad_id <- c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
INTERN <- c(4, 3, 4, 2, 2, 6, 8, 6, 9, 9)
AUDITCEN <- c(5.9, -6.1, -9.1, -5.1, -7.1, -6.1, 0.9, -2.1, -7.1, 1.9)
W1_cesd <- c(25, 8, 5, 0, 5, 17, 10, 5, 5, 7)
GENDERKID<- c(0, 0, 1, 1, 0, 1, 1, 0, 1, 0)
C_AGE_DI <- c(0, 0, 1, 1, 0, 0, 0, 0, 0, 1)
RACE_W <- c(0, 1, 1, 1, 1, 1, 1, 1, 1, 1)
RACE_O <- c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
cesd <- data.frame(dyad_id, INTERN, AUDITCEN, W1_cesd, GENDERKID, C_AGE_DI, RACE_W, RACE_O)
library(mediation)
med.fit <-glm(W1_cesd ~ AUDITCEN + GENDERKID + C_AGE_DI + RACE_W + RACE_O, data=cesd )
out.fit <-glm(INTERN ~ W1_cesd+ poly(AUDITCEN, 2) + GENDERKID + C_AGE_DI + RACE_W + RACE_O, data=cesd )
results <-mediate(med.fit, out.fit, sims = 1000, boot = TRUE, treat = "AUDITCEN", control.value=-10, treat.value=0, mediator = "W1_cesd")
“结果”产生以下错误:
Error in `[.data.frame`(y.data, , treat) : undefined columns selected
我的治疗变量确实存在,并且两个模型看起来不错。怎么了?当我为支出关系指定二次关联时,我做错什么了吗?