[R-meta] rma.mv predict() with newmods

Viechtbauer, Wolfgang (SP) wo||g@ng@v|echtb@uer @end|ng |rom m@@@tr|chtun|ver@|ty@n|
Mon May 6 10:51:26 CEST 2019


Indeed, the tau2.levels and gamma2.levels arguments need to be of the same length as the predicted values. And so for each predicted value, you specify which level of tau2 (and gamma2) applies. 

I am going to use a smaller example to illustrate this:

library(metafor)
dat <- dat.berkey1998
V <- lapply(split(dat[,c("v1i", "v2i")], dat$trial), as.matrix)
V <- bldiag(V)
res <- rma.mv(yi, V, mods = ~ outcome + outcome:I(year - 1983) - 1,
              random = ~ outcome | trial, struct="UN", data=dat)
res

X <- rbind(cbind(1,0,1979:1988-1983,0), # AL for years 1979 to 1988
           cbind(0,1,0,1979:1988-1983)) # PD for years 1979 to 1988

predict(res, newmods = X, tau2.levels=c(rep("AL",10), rep("PD",10)))

So, we want 10 predicted values for AL and 10 predicted values for PD, so tau2.levels is set accordingly.

Best,
Wolfgang

-----Original Message-----
From: R-sig-meta-analysis [mailto:r-sig-meta-analysis-bounces using r-project.org] On Behalf Of Gram, Gil (IITA)
Sent: Friday, 03 May, 2019 10:22
To: r-sig-meta-analysis using r-project.org
Subject: Re: [R-meta] rma.mv predict() with newmods

Thanks a lot Wolfgang,

Both methods now indeed work on my full model, which indeed has much more data (3941 rows) than the example (50 rows).

One question though, since I’m using rma.mv and my random structure has ~ inner | outer terms, I understand I should use the use the tau2.levels and gamma2.levels arguments to specify the levels of the inner factors IF I’m interested in the credibility/prediction intervals.

mod = rma.mv(yi, vi, method = 'ML', struct="UN", sparse=TRUE, data=dat,
             mods = ~ classOR:totalN + classMR:totalN + classMR:classOR:totalN + classOR:I(totalN^2) + classMR:I(totalN^2) + classMR:classOR:I(totalN^2) + classMR:classOR:time:totalN + classMR:classOR:time:I(totalN^2) + cropSys + idF,
             random = list(~1|ref, ~1|idRow, ~ treatment|idSite, ~ treatment|idSite.time))

> levels(dat$treatment)
[1] "Control" "MR"      "OR"      "ORMR”

But the arguments need to be vectors of the same length as the predicted values, i.e. 813240 x 54 (more levels than in the example), so this doesn’t work:
pred = predict(mod, newmods = X, tau2.levels = c('Control', 'OR', 'MR', 'ORMR'), gamma2.levels = c('Control', 'OR', 'MR', 'ORMR’))

How should I specify the tau2/gamma2.levels arguments?
And I don’t understand how I then could choose for which level combination(s) the credibility/prediction interval should be provided?

In case it might help you help me, this is the full model as an .rds R object: https://we.tl/t-BsfxyI9eBu

with much appreciation for your work and help.

Gil Gram
PhD researcher  |  Natural resource management/CCAFS
International Institute of Tropical Agriculture (IITA)
East African Hub/Kampala/Country office
Address: IITA-Uganda Plot 15B, Naguru East Road. P.O Box 7878, Kampala
Mobile: +256 755 315236  |  Belgium Mobile: +32 484 981200
Skype: gil.gram


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