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

Gabriel Cotlier g@b|k|m01 @end|ng |rom gm@||@com
Tue Nov 7 10:51:29 CET 2023


Dear Wolfgang,
That is amazing; I did not know I could use the funnel() function with
the colors and pch.
Thank you very much!!!
Kind regards,
Gabriel

On Tue, Nov 7, 2023 at 11:43 AM Viechtbauer, Wolfgang (NP) <
wolfgang.viechtbauer using maastrichtuniversity.nl> wrote:

> Dear Gabriel,
>
> The funnel() function accepts vectors for 'col' and 'pch'. So you could do:
>
> 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)
>
> grp <- c(1,2,1,1,2)
> cols <- c("red","blue")
> pchs <- c(19,15)
> funnel(funnel_all, back=NA, level=0, refline=1, yaxis="seinv",
> col=cols[grp], pch=pchs[grp])
> grid()
> abline(v=1, col="blue", lwd=2)
>
> Best,
> Wolfgang
>
> > -----Original Message-----
> > From: R-sig-meta-analysis <r-sig-meta-analysis-bounces using r-project.org>
> On Behalf
> > Of Gabriel Cotlier via R-sig-meta-analysis
> > Sent: Tuesday, November 7, 2023 08:50
> > To: Dr. Gerta Rücker <gerta.ruecker using uniklinik-freiburg.de>
> > Cc: Gabriel Cotlier <gabiklm01 using gmail.com>; R Special Interest Group for
> Meta-
> > Analysis <r-sig-meta-analysis using r-project.org>
> > Subject: Re: [R-meta] question on scatter plot of estimates (Fisher's Z)
> against
> > the standard error
> >
> > Hello all,
> > According to:
> > https://www.metafor-project.org/doku.php/plots:funnel_plot_variations I
> > think it could be the argument:
> >
> >    - yaxis="seinv" for the inverse of the standard errors
> >
> > Is what gives the 1/SE for each element in the vector of effect sizes in
> > the x-axis.
> >
> > How can I "stand alone"—that would be outside the metafore package or not
> > using the funnel function—to plot the same scatterplot of effect sizes
> > (x-axis) against 1/SE (y-axis) in communion and a simple R scatter
> > plot—without the funnel background—and afterwards use it to further
> cluster
> > by coloring or using shapes ("pch") the effect sizes according to
> different
> > categorical variables in the data frame?
> >
> > Thanks a lot for your help.
> > Kind regards,
> > Gabriel
> >
> > On Tue, Nov 7, 2023 at 9:13 AM Gabriel Cotlier <gabiklm01 using gmail.com>
> wrote:
> >
> > > Dear Greta and colleges,
> > >
> > > As can be seen below, Greta has provided a nice solution to a problem I
> > > could not solve before, which is to have as an output of metafor's
> package
> > > function funnel() for plotting the funnel plot without the background
> of
> > > the funnel itself, which I very slightly modified as follows:
> > >
> > > ###################
> > > ##
> > > ##.  CODE FUNNEL
> > > ##
> > > ###################
> > >
> > > ## data
> > > 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)
> > >
> > > ## model
> > > funnel_all <- rma.mv(yi,  vi,  data=dat)
> > >
> > > ## get max and min values for plot
> > > #funnel_all$yi
> > > #min(funnel_all$yi)
> > > #max(funnel_all$yi)
> > >
> > > ## funnel plot
> > > 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)
> > >
> > > This has been a very efficient solution for my problem of getting
> exactly
> > > the same funnel plot as the result of the metafore package
> > > function funnel() without the funnel as a background. However, now I am
> > > facing the challenge of having plotted the same funnel plot as the
> > > output from the metafor's funnel() function without the background but
> > > without the option of clustering by coloring or giving different point
> > > shapes to the effect szes (points in the funnel plot) according to a
> > > categorical in my data frame. I assume—probably wrongly—that for this
> task
> > > I would have to reproduce the same funnel plot as is output from the
> funnel
> > > plot function in the metafore package without the funnel background,
> as in
> > > the code above, and use my data frame with the categorical variables to
> > > color the points or give them different shapes and sizes using the
> > > categorical variables in my data frame. Now the funnel plot function
> plots
> > > in the x-axis the effect sizes, something I can easily get from my data
> > > frame, but in the y-axis it uses 1/standad error (or 1 / SD). The
> > > problem is that, as far as I understand, the standard error (SE)
> > > corresponds to the standard deviation, or the R function sd() which
> gives
> > > one value per input vector. Therefore, for some reason, plotting the
> effect
> > > sizes (a vector class numeric) in the x-axis and 1/sd(effect_sizes)
> will
> > > give me a number, not a vector of the same length as the effect sizes.
> > >
> > > *Therefore, how could one reproduce the same funnel plot as in the
> > > metafore function (without the funnel background, just a scatterplot)
> > > with an x-axis composed of the vector of effect sizes and a y-axis with
> > > another vector corresponding to 1/stands error (1/SE) of each element
> in
> > > the x-axis--If 1/SE is is equal to 1/sd(efect_sizes) which is a scaler
> and
> > > not a vector ?*
> > >
> > > I think maybe this could be achieved somehow by giving, in the y-axis,
> a
> > > kind of *"element-wise 1/SE"* to each element in the x-axis; that would
> > > be an value corresponding to 1/SE to each of the elements in the
> vector of
> > > effect sizes in the x-axis. Could this be the idea behind the funnel
> plot
> > > function with 1/SE on the y-axis?
> > >
> > > If so, can this be somehow achieved following the example provided by
> > > Greta below?
> > >
> > > 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)
> > >
> > > Thanks a lot for your help and guidance.
> > > Kind regards,
> > > Gabriel
>

	[[alternative HTML version deleted]]



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