【发布时间】:2016-09-06 21:06:09
【问题描述】:
这是我第一次在这里发布问题,如果我的问题不清楚或不完整,请原谅我。
我的场景:我有一个包含 21 个元分析分布 (Distribution1-Distribution21) 的数据框。对于每个分布,我对各自的元分析平均效应大小 (ES1-ES10) 有 10 个估计值。实际上,我通过各种敏感性分析(即异常值和发表偏倚分析)获得了元分析平均效应大小和其他九个该平均值的估计值。
使用修改后的代码(如果需要,可以提供链接;我无法发布多个链接,因为我是新用户),我能够绘制每个分布的平均估计值的三个估计值。为了让您了解我在说什么,想象一个显示平均估计值及其置信区间的数字。
这是数据框和修改后的代码:
x | ES1 | ES2 | ES3 | ES4 | ES5 | ES6 | ES7 | ES8 | ES9 | ES10
Distribution1 | -0.07 | -0.07 | -0.06 | -0.07 | -0.02 | -0.03 | -0.09 | -0.07 | 0.00 | 0.01
Distribution2 | -0.06 | -0.06 | -0.04 | -0.05 | -0.04 | -0.05 | -0.07 | -0.06 | -0.03 | 0.01
Distribution3 | -0.08 | -0.09 | -0.07 | -0.08 | -0.01 | -0.08 | -0.10 | -0.08 | -0.01 | 0.01
Distribution4 | -0.10 | -0.11 | -0.10 | -0.09 | -0.05 | -0.07 | -0.11 | -0.10 | -0.06 | 0.010
Distribution5 | -0.08 | -0.08 | -0.06 | -0.08 | -0.02 | -0.03 | -0.10 | -0.08 | 0.00 | 0.02
Distribution6 | -0.09 | -0.10 | -0.08 | -0.09 | -0.03 | -0.08 | -0.11 | -0.09 | -0.03 | 0.02
Distribution7 | -0.11 | -0.13 | -0.10 | -0.11 | -0.04 | -0.04 | -0.12 | -0.11 | -0.08 | 0.01
Distribution8 | -0.10 | -0.14 | -0.06 | -0.10 | -0.01 | -0.08 | -0.13 | -0.10 | -0.06 | 0.04
Distribution9 | -0.04 | -0.05 | -0.02 | -0.04 | 0.00 | -0.04 | -0.06 | -0.04 | -0.06 | 0.00
Distribution10 | -0.11 | -0.12 | -0.09 | -0.11 | -0.03 | -0.09 | -0.12 | -0.11 | -0.11 | 0.00
Distribution11 | -0.06 | -0.09 | -0.04 | -0.06 | -0.01 | -0.01 | -0.09 | -0.06 | -0.01 | 0.04
Distribution12 | -0.11 | -0.11 | -0.09 | -0.11 | -0.09 | -0.10 | -0.12 | -0.11 | -0.08 | -0.03
Distribution13 | -0.19 | -0.22 | -0.16 | -0.19 | -0.08 | -0.17 | -0.21 | -0.19 | -0.13 | -0.01
Distribution14 | -0.01 | -0.02 | 0.00 | -0.01 | 0.00 | 0.00 | -0.03 | -0.01 | -0.02 | -0.01
Distribution15 | -0.19 | -0.22 | -0.16 | -0.19 | -0.08 | -0.17 | -0.21 | -0.19 | -0.13 | -0.01
Distribution16 | -0.09 | -0.1 | -0.08 | -0.09 | -0.01 | -0.09 | -0.11 | -0.09 | -0.07 | 0.00
Distribution17 | -0.16 | -0.19 | -0.14 | -0.16 | -0.07 | -0.12 | -0.18 | -0.16 | -0.10 | 0.00
Distribution18 | -0.05 | -0.06 | -0.03 | -0.05 | -0.02 | -0.02 | -0.05 | -0.05 | -0.02 | 0.01
Distribution19 | -0.09 | -0.10 | -0.08 | -0.09 | -0.01 | -0.08 | -0.11 | -0.09 | -0.06 | 0.01
Distribution20 | -0.02 | -0.03 | -0.01 | -0.02 | 0.01 | 0.00 | -0.04 | -0.02 | 0.00 | 0.02
Distribution21 | -0.1 | -0.12 | -0.09 | -0.1 | -0.02 | -0.08 | -0.12 | -0.1 | -0.04 | 0.02
#My APA-format theme
#https://gist.github.com/akshaycuhk/01576c57149a9a3d14514c9a3c4b4b1d
install.packages("ggplot2")
library(ggplot2)
apatheme=theme_bw()+
theme(panel.grid.major=element_blank(),
panel.grid.minor=element_blank(),
panel.border=element_blank(),
axis.line=element_line(),
text=element_text(family='Times'),
legend.position='bottom', axis.text=element_text(size=14),
axis.title=element_text(size=14,face="bold"))
credplot.gg <- function(d){
# d is a data frame with 4 columns
# d$x gives variable names
# d$y gives center point
# d$ylo gives lower limits
# d$yhi gives upper limits
require(ggplot2)
p <- ggplot(d, aes(x=x, y=ES1, ymin=ES2, ymax=ES3))+
geom_pointrange()+
geom_hline(yintercept = 0, linetype=2)+
coord_flip()+
xlab('Distribution')+
ylab('Effect size')
return(p)
}
# load your data below
d <- read.table(file.choose(), sep=",", header=TRUE)
Fig1 <-credplot.gg(d) +xlim("Distribution1",
"Distribution2",
"Distribution3",
"Distribution4",
"Distribution5",
"Distribution6",
"Distribution7",
"Distribution8",
"Distribution9",
"Distribution10",
"Distribution11",
"Distribution12",
"Distribution13",
"Distribution14",
"Distribution15",
"Distribution16",
"Distribution17",
"Distribution18",
"Distribution19",
"Distribution20",
"Distribution21")
Fig1
我还不能嵌入图像,所以这里是数据文件、脚本和图形的链接: https://www.dropbox.com/sh/aczv1dw5mjmone8/AACqekiFVdJqeA1cRvIvs7NFa?dl=0
我的问题:我有没有办法将点估计数从 3 个增加到 10 个?具体来说,我可以为所有 21 个分布(Distribution1 -> Distribution21)绘制所有十个估计值(ES1 -> ES10)吗?理想情况下,每个点估计在线上都有自己的形状/标记,以将其与其他点区分开来,并且图例会伴随该图。
感谢任何愿意帮助我的人:)
【问题讨论】: