4
$\begingroup$

I have issue combining metafor and boot package. My original meta-analysis model is following and this runs well:

Lu_i<- rma(yi=Hedges_g,vi=Vg, dat=intensive,  mods=~Landscape:Contrast-1, method="REML", random=list(~1|Study,~1|id))

I am using “boot” package for obtain confidence intervals. So I run following function for non-parametric bootstrapping:

boot.func <- function(dat, indices) {
    res <- try(rma(yi=Hedges_g,vi=Vg, data=intensive, mods=~Landscape:Contrast-1,                 method="REML",random=list(~1|Study,~1|id),subset=indices), silent=TRUE)
    if (is.element("try-error", class(res))) {
    NA
  } else {
    c(coef(res), vcov(res), res$tau2, res$se.tau2^2)
  }
  }

However, following command gives error message and do not perform full bootstrapping:

res.boot2 <- boot(intensive, boot.func, R=5000)

Error in boot(intensive, boot.func, R = 5000) : 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)

Any tips for help? I think, my code should be correct, because it runs with bigger dataset and also for smaller dataset, but unfortunately not for this subgroup analysis, which I need. Actually, the code runs with very small bootstrapping number (maximum R=32), but with bigger number, I get soon error message, although, the code runs a while. Any suggestions?

$\endgroup$
5
$\begingroup$

First of all, the rma() function does not have a random argument. I think you meant to use the rma.mv() function.

If you switch to rma.mv(), then the elements you want to extract are:

c(coef(res), vcov(res), res$sigma2)

There is no res$se.sigma2 (at least not at the moment).

Also note that for models with moderators vcov(res) will be a matrix. This will get coerced to a vector which is fine, but just keep that in mind.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.