[R-meta] Accounting for uncertainty in a mixed-effects regression

Viechtbauer Wolfgang (SP) wolfgang.viechtbauer at maastrichtuniversity.nl
Thu Feb 8 15:44:45 CET 2018

Thanks for the follow-up. Are you now getting some sensible SEs for regions with low coverage?


>-----Original Message-----
>From: Cesar Terrer Moreno [mailto:cesar.terrer at me.com]
>Sent: Wednesday, 07 February, 2018 15:42
>To: Viechtbauer Wolfgang (SP)
>Cc: Michael Dewey; r-sig-meta-analysis at r-project.org
>Subject: Re: [R-meta] Accounting for uncertainty in a mixed-effects
>Downloading the latest version via your link solved the issue. Thanks!
>> On 6 Feb 2018, at 19:35, Viechtbauer Wolfgang (SP)
><wolfgang.viechtbauer at maastrichtuniversity.nl> wrote:
>> There is some (convoluted) code in predict.rma() that allows matching
>of terms by names. So, for example, if the variables in the model are
>called "X", "Y", and "Z", then one could do 'newmods = c(Z=3, X=1, Y=2)'
>or any other order and the function puts things in the correct order. In
>fact, it does partial matching, so if the variables are called "Xblah",
>"Yblah", "Zblah", then 'newmods = c(Z=3, X=1, Y=2)' would still work.
>There was a bug in that part of the code that would trip up the partial
>matching when there are interactions. I fixed that a while ago in the
>'devel' version. Make sure to install this:
>> https://github.com/wviechtb/metafor#installation
>> With this installed, I have no problems running this (and as you
>already figured out, since predict() by default adds the intercept
>automatically, it needs to be removed from what you feed to newmods):
>> ### silly madeup test data
>> k <- 500
>> dat <- data.frame(yi = rnorm(k, 0, 1),
>>                  vi = rep(.01, k),
>>                  MAP = runif(k, 0, 1),
>>                  MAT = runif(k, 0, 1),
>>                  CO2dif = runif(k, 0, 1),
>>                  Biome = sample(c("ARef", "Boreal_Forest",
>"Tropical_Forest"), k, replace=TRUE))
>> res <- rma(yi, vi, mods = ~ MAP + MAT*CO2dif + Biome, data=dat)
>> res
>> X <- model.matrix(~ MAP + MAT*CO2dif + Biome, data=dat)
>> X <- X[,-1]
>> sav <- predict(res, newmods = X)
>> sav
>> Best,
>> Wolfgang

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