Skip to content
Prev 4978 / 5636 Next

[R-meta] question on scatter plot of estimates (Fisher's Z) against the standard error

Dear Greta and colleagues:
Probably, I think I found the solution to reproduce outside the metafor
package the funnel plot without funnel background and with :
yaxis="seinv" for the inverse of the standard errors
I got the same results as in the funnel plot from the metafor package using
the inverse of the square root of the variance (not of the standard
deviation) as 1/SE, that would be:
Inv_SE <- 1/sqrt(vi_data),  where vi is the variance data.



## Greta example using metafore function funenel()
ri <- c(0.5, 0.6, 0.7, 0.8, 0.9)
ni <- c(100,110,150,200,250)
dat <-escalc(measure = "ZCOR",  ri = ri, ni = ni)
funnel_all <- rma.mv(yi,  vi,  data=dat)


png(file = "funnel_Greta_example.png",
    width = 250,
    height = 200,
    res = 600,
    units = "mm")
f1 <- funnel(funnel_all,
             back = "white",
             # shade = "white",
             yaxis = "seinv",
             level = 0,
             # ylim = c(1, 5),
             refline=0,
             main="my plot",
             ylab = "Presicion (1/SE)",
             xlim = c(0.53,1.5))
# shade = c("white", "gray55", "gray75"),
# refline = 0)
# bg = "grey")
# legend = TRUE)
#grid(NULL, NULL,lwd = 1.6)
abline(h=c(9.849, 11.316,12.783, 14.249, 15.716 ), col="grey", lwd=1, lty=3)
abline(v=1, col="blue", lwd=2)
abline(v=c( 0.6, 0.8, 1, 1.2, 1.4), col="grey", lwd=1, lty=3)
dev.off()

##

## Variance : from general model extracted
vi_data <-funnel_all$vi

## Estimates : from general model extracted estimates
yi_data <-funnel_all$yi[1:5]

## square root of the variance
SE_5 <- 1/sqrt(vi_data)

# estimates
E <-funnel_all$yi

N<-dat$ni

## construct data frame
df <- data.frame (Estimates = c(E), Standsrd_Error = c(SE_5))
View(df)
library(ggplot2)

###################################### MY PLOT
###################################

## Scatter plot
scaleFUN <- function(x) sprintf("%.2f", x)
p<- ggplot(df, aes(x=Estimates, y=Standsrd_Error)) +
  geom_point(aes(size = Estimates), alpha=0.7,  color="#2568E6")+
  scale_size_area() +
  labs(x = "Fisher's z",
       y = "Standard Error (SE)")+
  theme(plot.title = element_text(hjust = 0.5))+
  # theme(plot.margin = unit(2 ,8, 8, 2), "cm"))+
  scale_y_continuous(n.breaks = 12,labels=scaleFUN)+
  scale_x_continuous(n.breaks = 12,labels=scaleFUN)+
  geom_vline(xintercept = 0)+
  theme(axis.text.y = element_text(size = 15))+
  theme(axis.text.x = element_text(size = 15))+
  theme(axis.title.y = element_text(size = 15))+
  theme(axis.title.x = element_text(size = 15))+
  ggtitle( "Fisher's z vs. Standard Error")+
  theme(plot.title = element_text(size = 17, face = "bold"))+
  theme(legend.text = element_text(size = 15))
p
png(filename = "myExample.png", width = 28,  height = 18 ,units = "cm" ,
res =100 )
print(p)




[image: image.png]
On Tue, Nov 7, 2023 at 9:49?AM Gabriel Cotlier <gabiklm01 at gmail.com> wrote:

            
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-meta-analysis/attachments/20231107/4b649718/attachment-0001.html>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 579878 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-meta-analysis/attachments/20231107/4b649718/attachment-0001.png>