Skip to content

Forestplot

3 messages · francogrex

#
I know there is a function forestplot from rmeta package and also the
plot.meta from the meta package and maybe others, but they are rather
complicated with extra plot parameters that I do not need and also they
process only objects created with other package functions. 
But I wonder if anyone has a much simpler function using the basic plot to
make a forestplot with only a median (or mean) and just the confidence
intervals, something like the data below in graphics. thanks

Events	2.50%	50%	97.50%
A	0.33	2.49	24.96
B	0.25	1.9	19.56
C	0.34	1.28	5.35
D	1.58	2.94	5.54
E	0.82	1.94	4.71
F	1.04	3.18	10.32
G	0.58	1.44	3.72
H	0.04	0.48	3.79
I	0.17	0.67	2.52
3 days later
#
Answering my own query here's a solution (if any reader was curious):

forestplot=function(mean,std,conf,threshold){
z=-qnorm((1-conf)/2)
CI.H <- mean+z*sqrt(std) # Calculate upper CI 
CI.L <- mean-z*sqrt(std) # Calculate lower CI 
plot(mean,1:length(mean),xlim=c(min(CI.L),max(CI.H)),pch=15,cex=1,
ylab="",xlab="mean & CIs",main="Forest plot")
arrows(mean,1:length(mean),CI.H,1:length(mean), angle=90,length=0.05)
arrows(mean,1:length(mean),CI.L,1:length(mean), angle=90,length=0.05)
abline(v=threshold,lty=3)
}
francogrex wrote:

  
    
#
Sorry here's the good code:

forestplot=function(mean,std,conf,threshold){
z=-qnorm((1-conf)/2)
CI.H <- mean+z*std # Calculate upper CI 
CI.L <- mean-z*std # Calculate lower CI 
plot(mean,1:length(mean),xlim=c(min(CI.L),max(CI.H)),pch=15,cex=1,
ylab="",xlab="mean & CIs",main="Forest plot")
arrows(mean,1:length(mean),CI.H,1:length(mean), angle=90,length=0.05)
arrows(mean,1:length(mean),CI.L,1:length(mean), angle=90,length=0.05)
abline(v=threshold,lty=3)
}