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

Dr. Gerta Rücker gert@@ruecker @end|ng |rom un|k||n|k-|re|burg@de
Thu Jul 20 22:21:01 CEST 2023


Dear Gabriel,

Both plots are correct and equivalent (though I like the metafor plot much more). If it is only to get rid of the confidence region, why don't you use the funnel() function of metafor and suppress all elements you don't want?
For example, try (object funnel_all taken from your R code, fictitious data coming from me, as you did not provide them!)

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)
funnel(funnel_all, back = "white", shade = "white", level = 0, xlim = c(0.5,1.6), refline = 2)

The xlim argument is used to fix the x-axis range, while putting the refline outside the visible region (simply a trick, I couldn't find an argument to determine the refline's color). You may also change the y-axis range, e.g.,

funnel(funnel_all, back = "white", shade = "white", level = 0, xlim = c(0.5,1.6), refline = 2, ylim = c(0.06, 0.105))
 
if you think this makes sense. With respect to the inverted axis, see Michael's post.

Best,
Gerta



UNIVERSITÄTSKLINIKUM FREIBURG
Institute for Medical Biometry and Statistics

Dr. Gerta Rücker
Guest Scientist

Stefan-Meier-Straße 26 · 79104 Freiburg
gerta.ruecker using uniklinik-freiburg.de

https://www.uniklinik-freiburg.de/imbi-en/employees.html?imbiuser=ruecker


-----Ursprüngliche Nachricht-----
Von: R-sig-meta-analysis <r-sig-meta-analysis-bounces using r-project.org> Im Auftrag von Gabriel Cotlier via R-sig-meta-analysis
Gesendet: Donnerstag, 20. Juli 2023 16:28
An: Michael Dewey <lists using dewey.myzen.co.uk>
Cc: Gabriel Cotlier <gabiklm01 using gmail.com>; R Special Interest Group for Meta-Analysis <r-sig-meta-analysis using r-project.org>
Betreff: Re: [R-meta] question on scatter plot of estimates (Fisher's Z) against the standard error

Dear Michael,
Here is the code below:
Thanks a lot.
Kind regards,
Gabriel

## Transformation of Pearson's Product-moment correlation coefficient (r)
to Fisher's Z
dat <-escalc(measure = "ZCOR",
             ri = ri,
             ni = ni,
             data = dat)

##
funnel_all <- rma.mv(yi,
                     vi,
                     # mods = ~ Type,
                     random = ~ 1 | Article / Sample_ID,
                     data=dat)

funnel_all
## funnel plot form metafor
funnel(funnel_all)

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

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

## calculate standard error SE: square root of the variance
SE<- sqrt(vi_data)

# estimates
E <-funnel_all$yi

## construct data frame
df <- data.frame (Estimates = c(E), Standsrd_Error = c(SE))
View(df)
library(ggplot2)
## 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 = "myplot.png", width = 28,  height = 18 ,units = "cm" , res
=100 )
print(p)
dev.off()



On Thu, Jul 20, 2023 at 4:51 PM Michael Dewey <lists using dewey.myzen.co.uk>
wrote:

> Dear Gabriel
>
> Comments in-line
>
> On 20/07/2023 05:55, Gabriel Cotlier wrote:
> > Dear Michael,
> >
> > I think you are completely right, in the fact, the plot I am producing
> > is indeed valid for the purpose for which I want to use it, meaning it
> > is representative of the relationship I want to show. Therefore, I
> > assume that the plot I am getting, is supposed to be sufficient.
> >
> > However, I receive from the function metafore:: funnel (model), for a
> > model without modierators, a very nice representation of the scarring of
> > the observed outcomes or the estimates (x axis), as a function of the SE
> > (e.i., square root of the sampling variance, SE assumef to have a pseudo
> > confidence interval region drawn around each of its values). While, when
> > I plot by myself
> > x = observed outcomes
> > y = square root of the sampling variance,
> >
> > Then the plot shows that:
> > a.  the scattering of the points appears upside down with respect to the
> > output of the function metafore:: funnel (model),
>
> I have already answered that one in a previous post. It is just the
> convention
>
> > b. the scale of the y axis, instead of having a defined top at zero and
> > from there values are represented downwards, the scale is different.
> >
>
> Without your code it is hard to tell but I suspect you are not plotting
> what you think you are. Are you plotting the inverse of the se?
>
> Michael
>
> >
> > Anyways, I started thinking that in any case, such a difference in the
> > plot I am doing by myself is not necessarily wrong, but is just a
> > different way of representing the data. Just the scattering of the
> > points in one  case looks like the upside down scattering of the other.
> > And I assume this is because maybe the function metafore::funnel()
> > applies some operation on the square root of the mean (y axis) that I
> > presume is the calculation of the aforementioned pseudo confidence
> > interval for each value, but I am not sure.
> >
> > Thanks a lot for your response.
> > Kind regards,
> > Gabriel
> >
> > On Wed, Jul 19, 2023 at 7:20 PM Michael Dewey <lists using dewey.myzen.co.uk
> > <mailto:lists using dewey.myzen.co.uk>> wrote:
> >
> >     I am sorry Gabriel but I do not understand why the plot you say you
> >     produced fails to do what you say you want.
> >
> >     Michael
> >
> >     On 19/07/2023 10:59, Gabriel Cotlier wrote:
> >      > Hello Michael,
> >      > Thank you very much for your response.
> >      > I just would like to show that the of data set I have has high
> >      > uncertainty given that no possible pattern is observable or
> >     detectable
> >      > and no order is possible to visulize in the scattering,
> >      > I thought that a plot with x axis = fisher's z observed
> >      > outcomes (estimates) and y axis = standard error or any
> >     other measure of
> >      > uncertainty could at least visually demostrate that assumption.
> >      > If such a lack of pattern or high uncertainty in the data set can
> >     also
> >      > be demonstrated numerically, even better.
> >      > Kind regards,
> >      > Gabriel
> >      >
> >      > On Wed, Jul 19, 2023 at 12:29 PM Michael Dewey
> >     <lists using dewey.myzen.co.uk <mailto:lists using dewey.myzen.co.uk>
> >      > <mailto:lists using dewey.myzen.co.uk
> >     <mailto:lists using dewey.myzen.co.uk>>> wrote:
> >      >
> >      >     Dear Gabriel
> >      >
> >      >     I am not realy sure what you are trying to do but one point
> which
> >      >     occurs
> >      >     to me is that forest plots are conventional plotted with small
> >      >     values of
> >      >     standard error at the top.
> >      >
> >      >     Michael
> >      >
> >      >     On 19/07/2023 06:07, Gabriel Cotlier via R-sig-meta-analysis
> >     wrote:
> >      >      > Dear all,
> >      >      >
> >      >      > I have already posted this question with no response.
> >      >      > Maybe this time I am luckier and someone with more
> >     knowledge than
> >      >     me in the
> >      >      > Metafor package can answer me.
> >      >      >
> >      >      > In a nutshell, what I would like is to be able to produce a
> >      >     scatter plot of
> >      >      > the observed oucomes or the estimates, in my case Fisher's
> >     z for
> >      >     the x axis
> >      >      > and the standard error in the y axis, with the standard
> error
> >      >     (SE) the
> >      >      > same as it appears when running the funnel() function for a
> >      >     funnel plot
> >      >      > with the model (without moderators) as the input argument.
> >      >     Actually, it is
> >      >      > a funnel plot without the background of the funnel
> >     distribution
> >      >     but just
> >      >      > the scatter of points, that is suppressing the funnel
> >     distribution on
> >      >      > the background.
> >      >      >
> >      >      > I tried to do so in agreement with the definition of SE
> >     used for
> >      >     the funnel
> >      >      > plot in the package Vignette published at Journal of
> >     Scientific
> >      >     software in
> >      >      > page 26:
> >      >      >
> >      >      > "*For models without moderators, the figure shows the
> observed
> >      >     outcomes on
> >      >      > the horizontal axis against their corresponding standard
> >     errors
> >      >     (i.e., the
> >      >      > square root of the sampling variances) on the vertical
> axis. A
> >      >     vertical
> >      >      > line indicates the **estimate based on the model. A pseudo
> >     confidence
> >      >      > interval region is drawn around this value with bounds
> >     equal to
> >      >     ±1.96 · SE,
> >      >      > where SE is the standard error value from the vertical
> axis.*"
> >      >      >
> >      >      >
> >      >      > I tried to reproduce the vertical axis (y) using the
> >     square root
> >      >     of the
> >      >      > sampling variable, but the result was an upside down
> >     scaling of the
> >      >      > observed outcomes or estimates on a different y scale for
> >     the x
> >      >     ticks. The
> >      >      > plot seems to have similarities with the funnel plot from
> the
> >      >     funnel()
> >      >      > function, but it is not exactly the same without the
> >     background
> >      >     of the
> >      >      > funnel distribution graphic. Maybe the problem could be
> >     that in the
> >      >      > funnel() function, contrary to my simple attempt to
> imitate it
> >      >     with the
> >      >      > square root of the sampling variable, the pseudo confidence
> >      >     interval is
> >      >      > estimated for each value? Could this be the reason?
> >      >      >
> >      >      >
> >      >      > If so, how could I reproduce the funnel () function plot
> >     without
> >      >     the funnel
> >      >      > distribution graphic in the background and just the
> >     scattering of the
> >      >      > points using the same pseudo-confidence interval?
> >      >      >
> >      >      >
> >      >      > Thanks a lot for your help and assistance.
> >      >      >
> >      >      > Kind regards,
> >      >      >
> >      >      > Gabriel
> >      >      >
> >      >      >       [[alternative HTML version deleted]]
> >      >      >
> >      >      > _______________________________________________
> >      >      > R-sig-meta-analysis mailing list @
> >      > R-sig-meta-analysis using r-project.org
> >     <mailto:R-sig-meta-analysis using r-project.org>
> >      >     <mailto:R-sig-meta-analysis using r-project.org
> >     <mailto:R-sig-meta-analysis using r-project.org>>
> >      >      > To manage your subscription to this mailing list, go to:
> >      >      > https://stat.ethz.ch/mailman/listinfo/r-sig-meta-analysis
> >     <https://stat.ethz.ch/mailman/listinfo/r-sig-meta-analysis>
> >      >     <https://stat.ethz.ch/mailman/listinfo/r-sig-meta-analysis
> >     <https://stat.ethz.ch/mailman/listinfo/r-sig-meta-analysis>>
> >      >      >
> >      >
> >      >     --
> >      >     Michael
> >      > http://www.dewey.myzen.co.uk/home.html
> >     <http://www.dewey.myzen.co.uk/home.html>
> >      >     <http://www.dewey.myzen.co.uk/home.html
> >     <http://www.dewey.myzen.co.uk/home.html>>
> >      >
> >      >
> >      >
> >     <
> http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient
> <
> http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient>>
> Virus-free.www.avg.com <http://Virus-free.www.avg.com> <
> http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient
> <
> http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient
> >>
> >      >
> >      > <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> >
> >     --
> >     Michael
> >     http://www.dewey.myzen.co.uk/home.html
> >     <http://www.dewey.myzen.co.uk/home.html>
> >
>
> --
> Michael
> http://www.dewey.myzen.co.uk/home.html
>

	[[alternative HTML version deleted]]

_______________________________________________
R-sig-meta-analysis mailing list @ R-sig-meta-analysis using r-project.org
To manage your subscription to this mailing list, go to:
https://stat.ethz.ch/mailman/listinfo/r-sig-meta-analysis


More information about the R-sig-meta-analysis mailing list