library(pacman)
pacman::p_load(metafor,readxl,metaviz,MetaAnalyser,rio)
#library(readxl,metaviz,MetaAnalyser,rio)
#Effektstärke
Bor1 <- data.frame(read_excel("Borenstein_1.xls"))
Bor1 <- escalc(measure = "SMD", m1i=mw.t, m2i = mw.c, sd1i = sd.t, sd2i = sd.c, n1i= n.t, n2i= n.c, data= Bor1)
#Heterogenitätstests Fixed/Random-Effects / Test for heterogeneity
fe.mod <- rma(yi = yi, vi = vi, measure = "SMD", method = "FE", slab = Studie, data = Bor1)
forest(fe.mod, showweights = TRUE)
re.mod <- rma(yi = yi, vi = vi, measure = "SMD", method = "DL", slab = Studie, data = Bor1)
forest(re.mod, showweights = TRUE)
confint(re.mod)
predict(re.mod)
#Integration mit kategorialer Variable / Integration categorical variable
Bor2 <- read.delim2("Borenstein_2.txt")
fe.all <- rma(yi=d, vi=var.d, measure="SMD", method="FE", slab=study, data=Bor2)
fe.A <- rma(yi=d, vi=var.d, measure="SMD", method="FE", slab=study,
subset=group=="a", data=Bor2)
fe.B <- rma(yi=d, vi=var.d, measure="SMD", method="FE", slab=study,
subset=group=="b", data=Bor2)
#Im Modell mit Kovariable: / Model with categorical variable
fe.mod <- rma(yi=d, vi=var.d, mods= ~group, measure="SMD", method="FE",
slab=study, data=Bor2)
fe.mod
#Gruppe ‘a’ als Referenzgruppe: / Group a as reference
fe.mod <- rma(yi=d, vi=var.d, mods= **~relevel(group, ref="b")**, measure="SMD", method="FE",
slab=study, data=Bor2)
re.mod <- rma(yi=d, vi=var.d, mods= ~group, measure="SMD", method="DL",
slab=study, data=Bor2)
#Meta-Regression
bcg <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, digits=3, data=dat.bcg)
bcg[, -c(1,9)]
所以我应该用 R 写一个元分析,但以前从未使用过 R。我有点不知所措。上面的代码正在工作,除了组 a 下的 relevel 函数作为参考,我想在子组分析中更改参考组。所以我有 a 组和 b 组的研究,想改变参考组。对于 relevel 函数,我收到以下错误:
relevel.default(group, ref = "b") 中的错误:'relevel' 仅适用于(无序)因素
抱歉,如果我发布了不必要的代码。我不确定。提前致谢。