[R-meta] R-sig-meta-analysis Digest, Vol 35, Issue 7

Tarun Khanna kh@nn@ @end|ng |rom hert|e-@choo|@org
Tue Apr 21 16:35:16 CEST 2020


Hi Wolfgang,


Let me start by just using the example on Metafor help.


I used the dataset provided in the example on the Metafor page: http://www.metafor-project.org/doku.php/tips:bootstrapping_with_ma. I was able to replicate the results on the page. Then I added the variable alloc as a moderator variable in the estimation.


##Code


#Bootstrapping
res <-rma.mv(yi, vi, random = ~ 1 | trial, data=dat, mods = ~ alloc)

boot.func <- function(df, indices) {
  sub <- dat[indices,]
  res <-rma.mv(yi, vi, random = ~ 1 | trial, data=dat, mods = ~ alloc)
  if (is.element("try-error", class(res))) NA else c(coef(res), vcov(res))
}

library(boot)

set.seed(8781328)
res.boot <- boot(dat, boot.func, R=10000)
boot.ci(res.boot, index=1:2) #CI for average effect
boot.ci(res.boot, index=3:4) #CI for tau2


## Output


Bootstrap Statistics :
        original  bias    std. error
t1*  -0.51792376       0           0
t2*  -0.44786464       0           0
t3*   0.08899601       0           0
t4*   0.19465035       0           0
t5*  -0.19465035       0           0
t6*  -0.19465035       0           0
t7*  -0.19465035       0           0
t8*   0.26607085       0           0
t9*   0.19465035       0           0
t10* -0.19465035       0           0
t11*  0.19465035       0           0
t12*  0.31363498       0           0


Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) :
  index 0 outside bounds
In addition: Warning messages:
1: In sqrt(tv[, 2L]) : NaNs produced
2: In norm.inter(z, (1 + c(conf, -conf))/2) :
  extreme order statistics used as endpoints


Best

Tarun


Tarun Khanna

PhD Researcher

Hertie School


Friedrichstraße 180

10117 Berlin ∙ Germany
khanna using hertie-school.org ∙ www.hertie-school.org<http://www.hertie-school.org/>

________________________________
From: Viechtbauer, Wolfgang (SP) <wolfgang.viechtbauer using maastrichtuniversity.nl>
Sent: 21 April 2020 15:05:08
To: Tarun Khanna; r-sig-meta-analysis using r-project.org
Subject: RE: R-sig-meta-analysis Digest, Vol 35, Issue 7

Yes, one can also use bootstrapping on regression coefficients. Please provide a fully reproducible example that illustrates your attempts.

Best,
Wolfgang

>-----Original Message-----
>From: R-sig-meta-analysis [mailto:r-sig-meta-analysis-bounces using r-project.org]
>On Behalf Of Tarun Khanna
>Sent: Tuesday, 21 April, 2020 14:35
>To: r-sig-meta-analysis using r-project.org
>Subject: Re: [R-meta] R-sig-meta-analysis Digest, Vol 35, Issue 7
>
>Dear Wolfgang,
>
>I have a follow up question to Crystals'. Does bootstrapping also work with
>regressions that have moderator variables?
>
>I used the link that you provided, http://www.metafor-
>project.org/doku.php/tips:bootstrapping_with_ma, and ran a regression with
>"alloc" as a moderator variable and then tried bootstrapping the errors but
>the std. errrs were calculated as zero. This is the output that i got:
>
>Bootstrap Statistics :
>        original  bias    std. error
>t1*  -0.51792376       0           0
>t2*  -0.44786464       0           0
>t3*   0.08899601       0           0
>t4*   0.19465035       0           0
>t5*  -0.19465035       0           0
>t6*  -0.19465035       0           0
>t7*  -0.19465035       0           0
>t8*   0.26607085       0           0
>t9*   0.19465035       0           0
>t10* -0.19465035       0           0
>t11*  0.19465035       0           0
>t12*  0.31363498       0           0
>
>> boot.ci(res.boot, index=1:2) #CI for average effect
>Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) :
>  index 0 outside bounds
>In addition: Warning messages:
>1: In sqrt(tv[, 2L]) : NaNs produced
>2: In norm.inter(z, (1 + c(conf, -conf))/2) :
>  extreme order statistics used as endpoints
>
>I also tried doing it with my own data set and got the following error:
>
>Error in t.star[r, ] <- res[[r]] :
>  number of items to replace is not a multiple of replacement length
>In addition: There were 50 or more warnings (use warnings() to see the first
>50)
>
>If bootstrapping does indeed work with moderator variables, what might be
>wrong?
>
>Best
>Tarun
>
>Tarun Khanna
>PhD Researcher
>Hertie School
>
>Friedrichstraße 180
>10117 Berlin ∙ Germany
>khanna using hertie-school.org ∙ www.hertie-school.org<http://www.hertie-<http://www.hertie-school.org<http://www.hertie->
>school.org/>

	[[alternative HTML version deleted]]



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