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