我正在进行荟萃分析,需要分析多个主持人。我正在使用 rma.uni 函数,并且代码对于我正在测试的所有版主都将保持不变:
res <- rma.uni(method = "HS", measure = "SMD", m1i = EXPM, m2i = CONM, sd1i = EXPSD, sd2i = CONSD, n1i = EXPN, n2i = CONN, slab=paste(AUTHOR, YEAR, sep=", "), data = outcomeData)
我想添加参数“mods = ~ x”,其中 x 是我正在测试的版主(例如 YEAR 或 AUTHOR),然后执行版主组合列表的 for 循环。
我尝试了几种不同的方法,但无法解释错误消息。
mod.test <- c("AUTHOR", "YEAR")
for (i in mod.test){
res <- rma.uni(method = "HS", measure = "SMD", m1i = EXPM, m2i = CONM, sd1i = EXPSD, sd2i = CONSD, n1i = EXPN, n2i = CONN, slab=paste(AUTHOR, YEAR, sep=", "), mods = ~ i, data = outcomeData)
print(res)
}
和
mod.test <- c("AUTHOR", "YEAR")
for (x in mod.test){
i <- paste("mods = ~ ", x)
res <- rma.uni(method = "HS", measure = "SMD", m1i = EXPM, m2i = CONM, sd1i = EXPSD, sd2i = CONSD, n1i = EXPN, n2i = CONN, slab=paste(AUTHOR, YEAR, sep=", "), mods = ~ i, data = outcomeData)
print(res)
}
两者都给出错误:
Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :
contrasts can be applied only to factors with 2 or more levels
谢谢你的帮助。