<div dir="ltr"><font size="4">Hello Wolfgang,</font><div><font size="4"><br></font><div><font size="4">Sorry for the delay in replay. W</font><span style="font-size:large">ith regards to the use : </span></div><div><br></div><div><span style="background-color:rgb(255,255,255)"><font size="4"><span style="font-family:monospace">addpoly(coef(resSep)[[2]], sei = resSep$se[2], row= 16, mlab="" , efac = 0.5, col='blue')</span><br style="font-family:monospace"><span style="font-family:monospace">addpoly(coef(resSep)[[1]], sei = resSep$se[1] ,row= 1, mlab="", efac = 0.5, col='green')</span></font></span><br></div><div><span style="font-family:monospace;font-size:large;background-color:rgb(255,255,0)"><br></span></div><div><font size="4">I wanted to pool out the effect size estimated for each moderator in the model together with their CI for upper and lower bounds:</font></div><div><font size="4"><br></font></div><font face="monospace" size="4"># estimate se zval pval <a href="http://ci.lb">ci.lb</a> ci.ub <br># alloc_charNegative -0.8346 0.1491 -5.5969 <.0001 -1.1269 -0.5424 *** <br></font><div><font face="monospace" size="4"># alloc_charPositive 4.9600 0.2166 22.9006 <.0001 4.5355 5.3845 *** </font></div><div><br></div><div><font size="4">Which I could do with the code above. </font></div><div><font size="4"><br></font></div><div><font size="4">However, I do not understand why, using <font face="monospace">sei =.se$resSep</font><font face="arial, sans-serif"> (in this particular case)</font> I got the CI for upper and lower bounds (two last columns in the upper list above), all correctly pooled out, although --if do not understand incorrectly-- the</font><font size="4"> "se" value is supposed to be the Standard Error (se) and not the "<a href="http://ci.lb">ci.lb</a>" and "ci.ub", is this correct?</font><font size="4"> </font><span style="font-size:large"> </span></div><div><font size="4"><br></font></div><div><font size="4">Yes, indeed the use of <font face="monospace">pred()</font>, seems a good and very practical option to pool out same data, so I tried it as :</font></div><div><font size="4"><br></font></div><div><font size="4"> </font><span style="font-family:monospace;font-size:large">addpoly(resSep$pred[1], sei = c(sepSpe$ci.lib[1] , resSep$ci.ub), row= 16, mlab="" , efac = 0.5, col='blue')</span></div><div><br></div><div><font face="monospace" size="4"># for the size effect:</font></div><div><font face="monospace" size="4">resSep$pred[1] </font></div><div><font face="monospace" size="4"><br></font></div><div><font face="monospace" size="4"># for the CI upper and lower bound :</font></div><div><font face="monospace" style="" size="4">c(sepSpe$ci.lib[1] , resSep$ci.ub)</font><br></div><div><br></div><div><font face="arial, sans-serif" size="4">with the following:</font></div><div><font face="arial, sans-serif" size="4"><br></font></div><div><font face="monospace" size="4">pred <- predict(resSep, newmods=diag(2)) # in the</font><font face="monospace" size="4"> model I used there are two effect size(s)</font></div><div><span style="font-family:monospace;font-size:large">pred</span><font face="monospace" size="4"><br></font></div><div><font face="monospace" size="4"># pred se <a href="http://ci.lb">ci.lb</a> ci.ub <a href="http://pi.lb">pi.lb</a> pi.ub <br># 1 -0.8346 0.1491 -1.1269 -0.5424 -1.6830 0.0137 <br># 2 4.9600 0.2166 4.5355 5.3845 4.0575 5.8625 <br></font></div><div><span style="font-family:monospace;font-size:large"><br></span></div><div><span style="font-size:large"><font face="arial, sans-serif">The I used pred in </font><font face="monospace">addpoly()</font><font face="arial, sans-serif"> function:</font></span></div><div><span style="font-family:monospace;font-size:large"><br></span></div><div><font face="monospace" size="4">addpoly(pred$pred[1], sei= c(pred$<a href="http://ci.lb">ci.lb</a>[1], pred$ci.ub[1]), row= 16, mlab="" , efac = 0.5, col='blue')<br><font color="#ff0000">Error in addpoly.default(pred$pred[1], sei = c(pred$<a href="http://ci.lb">ci.lb</a>[1], pred$ci.ub[1]), : <br> Length of 'vi' (or 'sei') does not match length of 'x'.</font></font><span style="font-family:monospace;font-size:large"><br></span></div><div><br></div><div><font face="arial, sans-serif" size="4">However something went wrong since I got the error above. What could I have done wrong ?</font></div><div><br></div><div><font face="arial, sans-serif" size="4">In addition, I wanted to ask something maybe a bit more "theoretical" (if it is possible to define it in this way...?), with regards to my understanding of the model's argument. I ask this to make sure I am choosing the correct model in agreement to the hypothesis I want to test.</font></div><div><font face="arial, sans-serif" size="4"><br></font></div><div><font face="arial, sans-serif" size="4"><b>- for <a href="http://rma.mv">rma.mv</a>() "random" argument :</b></font></div><div><font face="arial, sans-serif" size="4"><b><br></b></font></div><div><font face="arial, sans-serif" size="4">As far I have understood, the use of <a href="http://rma.mv">rma.mv</a>() argument "random = " will enable me to influence the model by setting the underlying assumption that it can be added a <span style="color:rgb(0,0,0)">random effects structure</span> in agreement with either:</font></div><div><font face="arial, sans-serif" size="4"><br></font></div><div><font size="4"><font face="arial, sans-serif">a. influencing particular separate on single id as: <code style="color:rgb(0,0,0)">random = ~ 1 | id <font face="arial, sans-serif">(for one id )</font></code> or for several Ids with </font><code style="color:rgb(0,0,0)">random = list(~ 1 | id1, ~ 1 | id2)</code><span style="color:rgb(0,0,0);font-family:sans-serif">) </span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">where the outcome obtained with different values of the </span><code style="color:rgb(0,0,0)">id</code><span style="font-family:arial,sans-serif;color:rgb(0,0,0)"> variable are assumed to be independent</span><span style="font-family:arial,sans-serif;color:rgb(0,0,0)"> and will split the variance (eg. sigma1, sigma2 etc.) obtaining one sigma per id.</span></font></div><div><font size="4"><span style="font-family:arial,sans-serif;color:rgb(0,0,0)"><br></span></font></div><div><font size="4"><span style="font-family:arial,sans-serif;color:rgb(0,0,0)">b. Whereas for assuming dependency the nested random effect is used which will produce "a kind of" branching effect with formulas like for instance </span><code style="color:rgb(0,0,0)">random = ~ 1 | id1/id2. </code></font><font size="4"><span style="color:rgb(0,0,0);font-family:sans-serif">F</span></font><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:large">or example, give an id = Article (i.e., research studies) and another id = Sample_ID (i.e., outputs of each research study --in my case the "</span><i style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:large">r</i><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:large"> correlations"), then a dependency is assumed since each records in id = Article (study) can have many id = Sample_ID ( <i>r</i> correlations). </span><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:large">In addition and as a consequence this influence is observed in the obtained effect size as well as in the fact that the variance (sigma) is splitted to sigma1 and sigma2. U</span><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:large">sing for instance the model notation with the formula: </span></div><div><font size="4"><span style="color:rgb(0,0,0);font-family:arial,sans-serif"><br></span></font></div><div><font size="4"><font face="monospace">res <- <a href="http://rma.mv">rma.mv</a>(yi,<br> vi,<br> random = ~ 1 | Article / Sample_ID, <br> data=dat)</font><span style="color:rgb(0,0,0);font-family:arial,sans-serif"><br></span></font></div><div><br></div><div><font size="4"><span style="color:rgb(0,0,0);font-family:arial,sans-serif"> due to assumed dependency "a kind of" branching effect occurs as I attempt to show in the diagram below: </span></font></div><div><font size="4"><span style="color:rgb(0,0,0);font-family:arial,sans-serif"><br></span></font></div><div><img src="cid:ii_lj9n2y670" alt="dep_indep.jpg" width="504" height="407" style="margin-right: 0px;"><br></div><div><br></div><div><span style="font-family:arial,sans-serif;font-size:large"><b>- for <a href="http://rma.mv">rma.mv</a>() "mods" argument :</b></span><font size="4"><span style="color:rgb(0,0,0);font-family:arial,sans-serif"><br></span></font></div><div><font size="4"><span style="color:rgb(0,0,0);font-family:arial,sans-serif"><br></span></font></div><div><font size="4"><span style="color:rgb(0,0,0);font-family:arial,sans-serif">Now, If I would like also to model the influences of different effect size in agreement to a give vector ( i.g a column in an input data table ) then using moderators with for instance a notation formula such as </span></font><span style="color:rgb(0,0,0);font-family:sans-serif;font-size:13.3333px"> </span><font size="4"><code style="color:rgb(0,0,0)">mods = ~ mod1 - 1</code><span style="color:rgb(0,0,0)"> , the influence of "grouping" by moderators' attributes (e.g. when a moderator is chosen as vector named "Method" that has as attributes: "method1", "method2", and "method3'') in agreement to the moderator vector attributes ( as I understood always a categorical variable, type = char ) it is assumed that outcome of a effect size will be influence by the moderator and observable in a effect size displayed in the model's <font face="monospace">summary().</font><font face="arial, sans-serif">The model's output will therefore display efect sizes per </font>moderator according to moderators' attributes namely </span></font><span style="color:rgb(0,0,0);font-size:large">"method1", "method2", and "method3" ( 3 effect sizes). </span><span style="color:rgb(0,0,0)"><font size="4"> In this fashion, broadly speaking, it can be said that "mods" argument will control the influence of different moderators in the models, giving as output an efect size for each moderator,a kind of" grouping effect of the effect sizes. This can be exemplified for instance with the model 's notation formula such as:</font></span></div><div><span style="color:rgb(0,0,0)"><font size="4"><br></font></span></div><div><font face="monospace" size="4">res1 <- <a href="http://rma.mv">rma.mv</a>(yi,<br> vi,<br> mods = ~ Method -1,<br> random = ~ 1 | Article / Sample_ID, <br> data=dat)<span style="color:rgb(0,0,0)"><br></span></font></div><div><span style="color:rgb(0,0,0)"><font size="4"><br></font></span></div><div><span style="color:rgb(0,0,0)"><font size="4">Now, my question is:</font></span></div><div><font size="4"><span style="color:rgb(0,0,0)">If I would be interested in modelling the influence of a moderator which has the binary attributes of either being "positive" or "negative", then I should consider using a vector as categorical variable (type = char) for instance one named as "alloc_sign" (which take positive for "positive" for positive correlations and "negative" for negative correlations ) then to model the effect of <i>r </i>correlation's sign I would possibly might use the formula: <font face="monospace">mods = ~ </font></span><span style="font-family:monospace;color:rgb(0,0,0)">alloc_sign</span><span style="color:rgb(0,0,0)"><font face="monospace"> -1, </font><font face="arial, sans-serif">in the model above, could be this correct? </font></span></font></div><div><font size="4"><span style="color:rgb(0,0,0)"><font face="arial, sans-serif"><br></font></span></font></div><div><font size="4"><span style="color:rgb(0,0,0)"><font face="arial, sans-serif">Thanks a lot for your guidance and help.</font></span></font></div><div><font size="4"><span style="color:rgb(0,0,0)"><font face="arial, sans-serif">Kind regards,</font></span></font></div><div><font size="4"><span style="color:rgb(0,0,0)"><font face="arial, sans-serif">Gabriel</font></span></font></div><div><br></div><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jun 23, 2023 at 5:21 PM Viechtbauer, Wolfgang (NP) <<a href="mailto:wolfgang.viechtbauer@maastrichtuniversity.nl">wolfgang.viechtbauer@maastrichtuniversity.nl</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I only looked at the highlighted part (where you use addpoly()) and this is also possible (assuming that the coefficients you pull out from resSep are the estimates you are interested in).<br>
<br>
Best,<br>
Wolfgang<br>
<br>
>-----Original Message-----<br>
>From: Gabriel Cotlier [mailto:<a href="mailto:gabiklm01@gmail.com" target="_blank">gabiklm01@gmail.com</a>]<br>
>Sent: Friday, 23 June, 2023 16:12<br>
>To: Viechtbauer, Wolfgang (NP)<br>
>Cc: R Special Interest Group for Meta-Analysis<br>
>Subject: Re: [R-meta] Question on Forest Plot by subgroups<br>
><br>
>Hello all,<br>
><br>
>Sorry for the many emails but here is the solution that finally works nicely !!<br>
><br>
>The issue was that I just needed to define the addpoly() function arguments<br>
>properly as in the code below highlighted in yellow.<br>
>With this code I could produce a forest plot combining two different models :<br>
>1. one general for all dataset obtaining its estimate and CI (at line # -1)<br>
>2. one by grouping using 2 moderators obtaining 2 estimates (one per moderator<br>
>which are particular variables of interest of the meta-analys) and their CI.<br>
><br>
>png(filename="ForestComputerSimulationPositiveAndNegatives.png",<br>
> res=95, width=1300, height=880, type="cairo")<br>
><br>
>mlabfun <- function(text, res) {<br>
> list(bquote(paste(.(text),<br>
> " (Q = ", .(formatC(res$QE, digits=2, format="f")),<br>
> ", df = ", .(res$k - res$p),<br>
> ", p ", .(metafor:::.pval(res$QEp, digits=2, showeq=TRUE,<br>
>sep=" ")), "; ",<br>
> I^2, " = ", .(formatC(I_TOT, digits=1, format="f")), "%, ",<br>
> paste(sigma^2,sep = "_", "1"), " = ",<br>
>.(formatC(res$sigma2[1], digits=3, format="f")), " ",<br>
> paste(sigma^2,sep = "_", "2"), " = ",<br>
>.(formatC(res$sigma2[2], digits=3, format="f")),")")))}<br>
><br>
><br>
>mlabfun1 <- function(text, resSep) {<br>
> list(bquote(paste(.(text),<br>
> " (Q = ", .(formatC(resSep$QE, digits=2, format="f")),<br>
> ", df = ", .(resSep$k - resSep$p),<br>
> ", p ", .(metafor:::.pval(resSep$QEp, digits=2, showeq=TRUE,<br>
>sep=" ")), "; ",<br>
> # I^2, " = ", .(formatC(I_TOT, digits=1, format="f")), "%, ",<br>
> paste(sigma^2,sep = "_", "1"), " = ",<br>
>.(formatC(resSep$sigma2[1], digits=3, format="f")), " ",<br>
> paste(sigma^2,sep = "_", "2"), " = ",<br>
>.(formatC(resSep$sigma2[2], digits=3, format="f")),")")))}<br>
>forest(res,<br>
> top = 2,<br>
> # xlim=c(-8, 6),<br>
> # alim = c(-3.36077, 5.181815),<br>
> alim = c(-2, 6),<br>
> # at=log(c(0.05, 0.25, 1, 4)),<br>
> # atransf=exp,<br>
> # width = 4,<br>
> showweights = TRUE,<br>
> ilab=cbind(ni), # content of extra columns of information<br>
> ilab.xpos=c(-4.6), # position of extra columns of information<br>
> cex=1,<br>
> ylim=c(-1, 22.5), # rows in the y-axis from min-row to max-row with text.<br>
> slab = paste(dat$Authors, dat$Year, sep = ", "),<br>
> order=alloc_char,<br>
> rows=c(2:13,17:18), # this devide by groups the studeies (3 groups)<br>
>=ageregar 4 esopacios entre lineas<br>
> mlab=mlabfun("RE Model", res),<br>
> # mlab="",<br>
> # psize= 1 ,<br>
> efac = 0.5, # size of the polygon (the diamond)<br>
> # header="Author(s) and Year")<br>
>)<br>
># abline(h=res$k+8, lwd=2, col="white")<br>
><br>
>### set font expansion factor (as in forest() above) and use a bold font<br>
>op <- par(cex=0.75, font=2)<br>
><br>
>### add additional column headings to the plot<br>
>text(c(-10.8), res$k+6, c("Author(s) and Year"), cex = 1.4, font = 2)<br>
>text(c(-4.6), res$k+6, c("Samples size"), cex = 1.4, font = 2)<br>
>text(c(8.3), res$k+6, c("Weight"),cex = 1.4, font=2)<br>
>text(c(8.3), res$k+5.3, c("%"),cex = 1.4, font=2)<br>
>text(c(10.8), res$k+6, c("Fisher's zr [95% CI]"),cex = 1.4, font=2)<br>
>text(c(res$k+9), c("Computer Simulation Dataset"), cex = 2, font = 2)<br>
><br>
>### switch to bold italic font<br>
>par(font=4)<br>
><br>
>### add text for the subgroups<br>
>text(-12.3, c(14,19), pos=4, c("Positive",<br>
> "Negative"), cex = 1.4)<br>
><br>
>### set par back to the original settings<br>
>par(op)<br>
><br>
>### add summary polygons for the three subgroups<br>
>addpoly(coef(resSep)[[2]], sei = resSep$se[2], row= 16, mlab="" , efac = 0.5,<br>
>col='blue')<br>
>addpoly(coef(resSep)[[1]], sei = resSep$se[1] ,row= 1, mlab="", efac = 0.5,<br>
>col='green')<br>
><br>
># text(x=-1, y=-2:80, labels=c(-2:80), col = "red" )<br>
><br>
>text(-12.5, 1, pos = 4, cex = 0.90, bquote(paste("RE Model (Q = ",<br>
>.(formatC(resSep$QE, digits=2, format="f")),<br>
> ", df = ", .(resSep$k -<br>
>resSep$p),<br>
> ", p = ",<br>
>.(metafor:::.pval(resSep$QEp, digits=2, showeq=TRUE, sep=" ")), "; ",<br>
> # I^2, " = ", .(formatC(I_NEG,<br>
>digits=1, format="f")), "%, ",<br>
> paste(sigma^2,sep = "_", "1"), "<br>
>= ", .(formatC(resSep$sigma2[1], digits=3, format="f")), " ",<br>
> paste(sigma^2,sep = "_", "2"), "<br>
>= ", .(formatC(resSep$sigma2[2], digits=3, format="f"))<br>
>)))<br>
><br>
><br>
>text(-12.5, 16, pos = 4, cex = 0.90, bquote(paste("RE Model (Q = ",<br>
>.(formatC(resSep$QE, digits=2, format="f")),<br>
> ", df = ", .(resSep$k -<br>
>resSep$p),<br>
> ", p = ",<br>
>.(metafor:::.pval(resSep$QEp, digits=2, showeq=TRUE, sep=" ")), "; ",<br>
> # I^2, " = ", .(formatC(I_POS,<br>
>digits=1, format="f")), "%, ",<br>
> paste(sigma^2,sep = "_", "1"),<br>
>" = ", .(formatC(resSep$sigma2[1], digits=3, format="f")), " ",<br>
> paste(sigma^2,sep = "_", "2"),<br>
>" = ", .(formatC(resSep$sigma2[2], digits=3, format="f"))<br>
>)))<br>
><br>
>text(8.5, 1, pos = 4, cex = 0.90, round(coef(resSep)[[1]],3))<br>
>text(8.5, 16, pos = 4, cex = 0.90, round(coef(resSep)[[2]],3))<br>
><br>
>dev.off()<br>
</blockquote></div>