# 安装包
if (!requireNamespace("data.table", quietly = TRUE)) {
install.packages("data.table")
}if (!requireNamespace("jsonlite", quietly = TRUE)) {
install.packages("jsonlite")
}if (!requireNamespace("metafor", quietly = TRUE)) {
install.packages("metafor")
}if (!requireNamespace("ggplotify", quietly = TRUE)) {
install.packages("ggplotify")
}
# 加载包
library(data.table)
library(jsonlite)
library(metafor)
library(ggplotify)
漏斗图 (metafor)
可以用于分析 Meta 分析结果中潜在偏倚因子。
环境配置
系统: Cross-platform (Linux/MacOS/Windows)
编程语言: R
依赖包:
data.table
;jsonlite
;metafor
;ggplotify
数据准备
# 加载数据
<- data.table::fread(jsonlite::read_json("https://hiplot.cn/ui/basic/funnel-plot-metafor/data.json")$exampleData$textarea[[1]])
data <- as.data.frame(data)
data
# 整理数据格式
<- escalc(ri=ri, ni=ni, data = data, measure="ZCOR")
data2 <- rma(yi, vi, data = data2)
res
# 查看数据
head(data)
authors year ni ri controls design a_measure
1 Axelsson et al. 2009 109 0.187 none cross-sectional self-report
2 Axelsson et al. 2011 749 0.162 none cross-sectional self-report
3 Bruce et al. 2010 55 0.340 none prospective other
4 Christensen et al. 1999 107 0.320 none cross-sectional self-report
5 Christensen & Smith 1995 72 0.270 none prospective other
6 Cohen et al. 2004 65 0.000 none prospective other
c_measure meanage quality
1 other 22.00 1
2 NEO 53.59 1
3 NEO 43.36 2
4 other 41.70 1
5 NEO 46.39 2
6 NEO 41.20 2
可视化
# 漏斗图
<- as.ggplot(function(){
p funnel(x = res, main = "Funnel Plot (metafor)",
level = c(90, 95, 99), shade = c("white","#a90e07","#d23e0b"), refline = 0)
})
p
