[R-meta] Mixed effects meta-analysis model selection with glmulti
Viechtbauer Wolfgang (SP)
wolfgang.viechtbauer at maastrichtuniversity.nl
Wed Oct 11 21:33:30 CEST 2017
Hi Bronwen,
Difficult to say what the problem is without knowing what kind of errors you are encountering or what the full code looks like.
But let me try this out myself, using the example from:
http://www.metafor-project.org/doku.php/tips:model_selection_with_glmulti
but now using rma.mv() to fit the same type of model. So:
library(metafor)
library(glmulti)
dat <- get(data(dat.bangertdrowns2004))
dat <- dat[!apply(dat[,c("length", "wic", "feedback", "info",
"pers", "imag", "meta")], 1, anyNA),]
rma.glmulti <- function(formula, data, random, ...)
rma.mv(formula, vi, data=data, random=random, method="ML", ...)
res <- glmulti(yi ~ length + wic + feedback + info + pers + imag + meta, data=dat,
level=1, fitfunction=rma.glmulti, crit="aicc", confsetsize=128,
random = ~ 1 | id)
print(res)
This works like a charm here. And yes, the code for the multimodel inference you have is correct (and also works with the example above).
Note that it is in principle unnecessary to have the 'random = ~ 1 | id' part in glmulti(). I would just do:
rma.glmulti <- function(formula, data, random, ...)
rma.mv(formula, vi, data=data, random = ~ 1 | id, method="ML", ...)
res <- glmulti(yi ~ length + wic + feedback + info + pers + imag + meta, data=dat,
level=1, fitfunction=rma.glmulti, crit="aicc", confsetsize=128)
print(res)
Again, this works as it should.
So I don't know what problem you are having.
Best,
Wolfgang
-----Original Message-----
From: R-sig-meta-analysis [mailto:r-sig-meta-analysis-bounces at r-project.org] On Behalf Of Bronwen Stanford
Sent: Wednesday, 11 October, 2017 18:39
To: r-sig-meta-analysis at r-project.org
Subject: [R-meta] Mixed effects meta-analysis model selection with glmulti
I would like to perform model selection on a meta-analysis model with mixed
effects, using rma.mv from metafor and the glmulti package. Code was
provided for doing this with fixed effects (
http://www.metafor-project.org/doku.php/tips:model_selection_with_glmulti)
but I can't figure out how to modify the code to work with multilevel
models.
I've tried
rma.glmulti <- function(formula, data, ...) {
rma.mv(formula, vi, data=data, method="ML",random=random)
}
but it creates errors
I'm also not sure whether I would need to modify the second part of the
code
setOldClass("rma.mv")
setMethod('getfit', 'rma.mv', function(object, ...) {
if (object$test=="z") {
cbind(estimate=coef(object), se=sqrt(diag(vcov(object))), df=100000)
} else {
cbind(estimate=coef(object), se=sqrt(diag(vcov(object))),
df=object$k-object$p)
}
})
Any help you can provide would be really appreciated!
Thank you
Bronwen
More information about the R-sig-meta-analysis
mailing list