<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<meta content="text/html; charset=UTF-8">
<style type="text/css" style="">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<div dir="ltr">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p>Hi Michael, </p>
<p><br>
</p>
<p>Sorry. I copied the wrong link. I am using data from this link. Attaching the data as a csv as well. <span style="font-family:Calibri,Helvetica,sans-serif,Helvetica,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:16px">Below
 is the code and output. </span><a href="http://www.metafor-project.org/doku.php/tips:rma.uni_vs_rma.mv" class="x_OWAAutoLink" id="LPlnk81908" title="http://www.metafor-project.org/doku.php/tips:rma.uni_vs_rma.mv
Cmd+Click or tap to follow the link" style="font-size:12pt">http://www.metafor-project.org/doku.php/tips:rma.uni_vs_rma.mv</a></p>
<p><br>
</p>
<p>Perhaps just to be clear - I am trying to bootstrap errors in estimation which uses rma.mv and moderator variables. </p>
<p><br>
</p>
<p></p>
<div style="font-family:Calibri,Helvetica,sans-serif,serif,EmojiFont; font-size:16px; margin-top:0px; margin-bottom:0px">
<b>##Code</b></div>
<div style="font-family:Calibri,Helvetica,sans-serif,serif,EmojiFont; font-size:16px">
</div>
<div>dat <- read_csv("test.csv")</div>
<div>#RE </div>
<div>rma(yi, vi, data=dat)</div>
<div>#CRVE</div>
<div>rma.mv(yi, vi, random = ~ 1 | trial, data=dat) </div>
<div>#Bootstrapping</div>
<div>res <-rma.mv(yi, vi, random = ~ 1 | trial, data=dat, mods = ~ alloc)</div>
<div><br>
</div>
<div>boot.func <- function(df, indices) {</div>
<div>  sub <- dat[indices,]</div>
<div>  res <-rma.mv(yi, vi, random = ~ 1 | trial, data=dat, mods = ~ alloc)</div>
<div>  if (is.element("try-error", class(res))) NA else c(coef(res), vcov(res))</div>
<div>}</div>
<br style="font-family:Calibri,Helvetica,sans-serif,serif,EmojiFont; font-size:16px">
<div style="font-family:Calibri,Helvetica,sans-serif,serif,EmojiFont; font-size:16px; margin-top:0px; margin-bottom:0px">
 </div>
<div style="font-family:Calibri,Helvetica,sans-serif,serif,EmojiFont; font-size:16px; margin-top:0px; margin-bottom:0px">
<b>## Output</b></div>
<div style="font-family:Calibri,Helvetica,sans-serif,serif,EmojiFont; font-size:16px">
Bootstrap Statistics :</div>
<div style="font-family:Calibri,Helvetica,sans-serif,serif,EmojiFont; font-size:16px">
        original  bias    std. error</div>
<div style="font-family:Calibri,Helvetica,sans-serif,serif,EmojiFont; font-size:16px">
t1*  -0.51792376       0           0</div>
<div style="font-family:Calibri,Helvetica,sans-serif,serif,EmojiFont; font-size:16px">
t2*  -0.44786464       0           0</div>
<div style="font-family:Calibri,Helvetica,sans-serif,serif,EmojiFont; font-size:16px">
t3*   0.08899601       0           0</div>
<div style="font-family:Calibri,Helvetica,sans-serif,serif,EmojiFont; font-size:16px">
t4*   0.19465035       0           0</div>
<div style="font-family:Calibri,Helvetica,sans-serif,serif,EmojiFont; font-size:16px">
t5*  -0.19465035       0           0</div>
<div style="font-family:Calibri,Helvetica,sans-serif,serif,EmojiFont; font-size:16px">
t6*  -0.19465035       0           0</div>
<div style="font-family:Calibri,Helvetica,sans-serif,serif,EmojiFont; font-size:16px">
t7*  -0.19465035       0           0</div>
<div style="font-family:Calibri,Helvetica,sans-serif,serif,EmojiFont; font-size:16px">
t8*   0.26607085       0           0</div>
<div style="font-family:Calibri,Helvetica,sans-serif,serif,EmojiFont; font-size:16px">
t9*   0.19465035       0           0</div>
<div style="font-family:Calibri,Helvetica,sans-serif,serif,EmojiFont; font-size:16px">
t10* -0.19465035       0           0</div>
<div style="font-family:Calibri,Helvetica,sans-serif,serif,EmojiFont; font-size:16px">
t11*  0.19465035       0           0</div>
<div style="font-family:Calibri,Helvetica,sans-serif,serif,EmojiFont; font-size:16px">
t12*  0.31363498       0           0</div>
<br style="font-family:Calibri,Helvetica,sans-serif,serif,EmojiFont; font-size:16px">
<div style="font-family:Calibri,Helvetica,sans-serif,serif,EmojiFont; font-size:16px; margin-top:0px; margin-bottom:0px">
 </div>
<div style="font-family:Calibri,Helvetica,sans-serif,serif,EmojiFont; font-size:16px; margin-top:0px; margin-bottom:0px">
 </div>
<div style="font-family:Calibri,Helvetica,sans-serif,serif,EmojiFont; font-size:16px">
Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) : </div>
<div style="font-family:Calibri,Helvetica,sans-serif,serif,EmojiFont; font-size:16px">
  index 0 outside bounds</div>
<div style="font-family:Calibri,Helvetica,sans-serif,serif,EmojiFont; font-size:16px">
In addition: Warning messages:</div>
<div style="font-family:Calibri,Helvetica,sans-serif,serif,EmojiFont; font-size:16px">
1: In sqrt(tv[, 2L]) : NaNs produced</div>
<div style="font-family:Calibri,Helvetica,sans-serif,serif,EmojiFont; font-size:16px">
2: In norm.inter(z, (1 + c(conf, -conf))/2) :</div>
<div style="font-family:Calibri,Helvetica,sans-serif,serif,EmojiFont; font-size:16px">
  extreme order statistics used as endpoints</div>
<br>
<p></p>
<p><br>
</p>
<p><br>
</p>
<div id="x_Signature">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,Helvetica,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<p><span style="color:rgb(117,123,128)"></span></p>
<p class="x_MsoNormal"><b><span lang="EN-US" style="font-size:9.0pt; font-family:"Corbel",sans-serif; color:black">Tarun Khanna</span></b></p>
<p class="x_MsoNormal"><span lang="EN-US" style="font-size:9.0pt; font-family:"Corbel",sans-serif; color:black">PhD Researcher</span></p>
<p class="x_MsoNormal"><span lang="EN-US" style="font-size:9.0pt; font-family:"Corbel",sans-serif; color:black"><br>
</span><b style=""><span lang="EN-US" style="font-size:9.0pt; font-family:"Corbel",sans-serif; color:#BA0020">Hertie School</span></b></p>
<p class="x_MsoNormal"><span lang="EN-US" style="font-size:9.0pt; font-family:"Corbel",sans-serif"><span style="color:black"><br style="">
</span></span></p>
<p class="x_MsoNormal"><span lang="DE" style="font-size:9.0pt; font-family:"Corbel",sans-serif; color:black">Friedrichstraße 180
</span></p>
<p class="x_MsoNormal"><span lang="EN-GB" style="font-size:9.0pt; font-family:"Corbel",sans-serif; color:black">10117 Berlin ∙ Germany<br>
</span><span lang="EN-GB" style="font-size:9pt; font-family:Corbel,sans-serif; background:rgb(255,255,255)">khanna</span><span lang="EN-GB" style="font-size:9.0pt; font-family:"Corbel",sans-serif"><span style="background-color:rgb(255,255,255)">@hertie-school.org</span><span style="color:black; background-color:rgb(255,255,255)">
 ∙ </span></span><span lang="DE"><a href="http://www.hertie-school.org/" id="LPNoLP"><span lang="EN-GB" style="font-size:9pt; font-family:Corbel,sans-serif; background-color:rgb(255,255,255)">www.hertie-school.org</span></a></span><span lang="EN-GB" style="font-family:"Corbel",sans-serif"></span></p>
<p><span style="color:rgb(117,123,128)"></span></p>
</div>
</div>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Michael Dewey <lists@dewey.myzen.co.uk><br>
<b>Sent:</b> 21 April 2020 17:28:43<br>
<b>To:</b> Tarun Khanna; Viechtbauer, Wolfgang (SP); r-sig-meta-analysis@r-project.org<br>
<b>Subject:</b> Re: [R-meta] R-sig-meta-analysis Digest, Vol 35, Issue 7</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">Dear Tarun<br>
<br>
In the example on that page it uses dat.collins1985b but that does not <br>
contain either a variable trial, nor one called alloc. Can you post a <br>
complete minimal reproducible example showing the packages you use and <br>
which data-set you are using?<br>
<br>
Michael<br>
<br>
On 21/04/2020 15:35, Tarun Khanna wrote:<br>
> Hi Wolfgang,<br>
> <br>
> <br>
> Let me start by just using the example on Metafor help.<br>
> <br>
> <br>
> I used the dataset provided in the example on the Metafor page: <a href="http://www.metafor-project.org/doku.php/tips:bootstrapping_with_ma">
http://www.metafor-project.org/doku.php/tips:bootstrapping_with_ma</a>. I was able to replicate the results on the page. Then I added the variable alloc as a moderator variable in the estimation.<br>
> <br>
> <br>
> ##Code<br>
> <br>
> <br>
> #Bootstrapping<br>
> res <-rma.mv(yi, vi, random = ~ 1 | trial, data=dat, mods = ~ alloc)<br>
> <br>
> boot.func <- function(df, indices) {<br>
>    sub <- dat[indices,]<br>
>    res <-rma.mv(yi, vi, random = ~ 1 | trial, data=dat, mods = ~ alloc)<br>
>    if (is.element("try-error", class(res))) NA else c(coef(res), vcov(res))<br>
> }<br>
> <br>
> library(boot)<br>
> <br>
> set.seed(8781328)<br>
> res.boot <- boot(dat, boot.func, R=10000)<br>
> boot.ci(res.boot, index=1:2) #CI for average effect<br>
> boot.ci(res.boot, index=3:4) #CI for tau2<br>
> <br>
> <br>
> ## Output<br>
> <br>
> <br>
> Bootstrap Statistics :<br>
>          original  bias    std. error<br>
> t1*  -0.51792376       0           0<br>
> t2*  -0.44786464       0           0<br>
> t3*   0.08899601       0           0<br>
> t4*   0.19465035       0           0<br>
> t5*  -0.19465035       0           0<br>
> t6*  -0.19465035       0           0<br>
> t7*  -0.19465035       0           0<br>
> t8*   0.26607085       0           0<br>
> t9*   0.19465035       0           0<br>
> t10* -0.19465035       0           0<br>
> t11*  0.19465035       0           0<br>
> t12*  0.31363498       0           0<br>
> <br>
> <br>
> Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) :<br>
>    index 0 outside bounds<br>
> In addition: Warning messages:<br>
> 1: In sqrt(tv[, 2L]) : NaNs produced<br>
> 2: In norm.inter(z, (1 + c(conf, -conf))/2) :<br>
>    extreme order statistics used as endpoints<br>
> <br>
> <br>
> Best<br>
> <br>
> Tarun<br>
> <br>
> <br>
> Tarun Khanna<br>
> <br>
> PhD Researcher<br>
> <br>
> Hertie School<br>
> <br>
> <br>
> Friedrichstraße 180<br>
> <br>
> 10117 Berlin ∙ Germany<br>
> khanna@hertie-school.org ∙ <a href="http://www.hertie-school.org<http://www.hertie-school.org/">
www.hertie-school.org<http://www.hertie-school.org/</a>><br>
> <br>
> ________________________________<br>
> From: Viechtbauer, Wolfgang (SP) <wolfgang.viechtbauer@maastrichtuniversity.nl><br>
> Sent: 21 April 2020 15:05:08<br>
> To: Tarun Khanna; r-sig-meta-analysis@r-project.org<br>
> Subject: RE: R-sig-meta-analysis Digest, Vol 35, Issue 7<br>
> <br>
> Yes, one can also use bootstrapping on regression coefficients. Please provide a fully reproducible example that illustrates your attempts.<br>
> <br>
> Best,<br>
> Wolfgang<br>
> <br>
>> -----Original Message-----<br>
>> From: R-sig-meta-analysis [<a href="mailto:r-sig-meta-analysis-bounces@r-project.org">mailto:r-sig-meta-analysis-bounces@r-project.org</a>]<br>
>> On Behalf Of Tarun Khanna<br>
>> Sent: Tuesday, 21 April, 2020 14:35<br>
>> To: r-sig-meta-analysis@r-project.org<br>
>> Subject: Re: [R-meta] R-sig-meta-analysis Digest, Vol 35, Issue 7<br>
>><br>
>> Dear Wolfgang,<br>
>><br>
>> I have a follow up question to Crystals'. Does bootstrapping also work with<br>
>> regressions that have moderator variables?<br>
>><br>
>> I used the link that you provided, <a href="http://www.metafor-">http://www.metafor-</a><br>
>> project.org/doku.php/tips:bootstrapping_with_ma, and ran a regression with<br>
>> "alloc" as a moderator variable and then tried bootstrapping the errors but<br>
>> the std. errrs were calculated as zero. This is the output that i got:<br>
>><br>
>> Bootstrap Statistics :<br>
>>         original  bias    std. error<br>
>> t1*  -0.51792376       0           0<br>
>> t2*  -0.44786464       0           0<br>
>> t3*   0.08899601       0           0<br>
>> t4*   0.19465035       0           0<br>
>> t5*  -0.19465035       0           0<br>
>> t6*  -0.19465035       0           0<br>
>> t7*  -0.19465035       0           0<br>
>> t8*   0.26607085       0           0<br>
>> t9*   0.19465035       0           0<br>
>> t10* -0.19465035       0           0<br>
>> t11*  0.19465035       0           0<br>
>> t12*  0.31363498       0           0<br>
>><br>
>>> boot.ci(res.boot, index=1:2) #CI for average effect<br>
>> Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) :<br>
>>   index 0 outside bounds<br>
>> In addition: Warning messages:<br>
>> 1: In sqrt(tv[, 2L]) : NaNs produced<br>
>> 2: In norm.inter(z, (1 + c(conf, -conf))/2) :<br>
>>   extreme order statistics used as endpoints<br>
>><br>
>> I also tried doing it with my own data set and got the following error:<br>
>><br>
>> Error in t.star[r, ] <- res[[r]] :<br>
>>   number of items to replace is not a multiple of replacement length<br>
>> In addition: There were 50 or more warnings (use warnings() to see the first<br>
>> 50)<br>
>><br>
>> If bootstrapping does indeed work with moderator variables, what might be<br>
>> wrong?<br>
>><br>
>> Best<br>
>> Tarun<br>
>><br>
>> Tarun Khanna<br>
>> PhD Researcher<br>
>> Hertie School<br>
>><br>
>> Friedrichstraße 180<br>
>> 10117 Berlin ∙ Germany<br>
>> khanna@hertie-school.org ∙ <a href="http://www.hertie-school.org<http://www.hertie-<http://www.hertie-school.org<http://www.hertie-">
www.hertie-school.org<http://www.hertie-<http://www.hertie-school.org<http://www.hertie-</a>><br>
>> school.org/><br>
> <br>
>        [[alternative HTML version deleted]]<br>
> <br>
> _______________________________________________<br>
> R-sig-meta-analysis mailing list<br>
> R-sig-meta-analysis@r-project.org<br>
> <a href="https://stat.ethz.ch/mailman/listinfo/r-sig-meta-analysis">https://stat.ethz.ch/mailman/listinfo/r-sig-meta-analysis</a><br>
> <br>
> <br>
<br>
-- <br>
Michael<br>
<a href="http://www.dewey.myzen.co.uk/home.html">http://www.dewey.myzen.co.uk/home.html</a><br>
</div>
</span></font>
</body>
</html>