# NOT RUN {
### REPRODUCE THE RESULTS IN ISHAK ET AL (2007), TABLES 1 AND 2
# CREATE THE OUTCOME AND WITHIN-STUDY MATRICES (THE LATTER WITHOUT CORRELATION)
y <- as.matrix(dbs[1:4*2+1])
S <- as.matrix(dbs[1:4*2+2])
# INDEPENDENT RANDOM EFFECTS (TABLE 1, FIRST MODEL)
mv1 <- mixmeta(y ~ 1, S, bscov="diag", data=dbs)
print(summary(mv1), digits=1, report="var")
# HETEROGENEOUS AR1 RANDOM-EFFECTS (TABLE 1, THIRD MODEL)
mv3 <- mixmeta(y ~ 1, S, bscov="har1", data=dbs)
print(summary(mv3), digits=1, report="var")
# BUILD THE LIST HETEROGENEOUS AR1 WITHIN-STUDY ERRORS (CORRELATION AT 0.97)
cormat <- 0.97^abs(col(matrix(1,4,4)) - row(col(matrix(1,4,4))))
addS <- lapply(seq(nrow(S)), function(i) inputcov(sqrt(S[i,]), cormat))
addS <- lapply(addS, function(x) x[apply(!is.na(x),1,any), apply(!is.na(x),2,any)])
# ADD HAR1 WITHIN-STUDY ERRORS (TABLE 1, FOURTH MODEL) USING addSlist
# }
# NOT RUN {
mv4 <- mixmeta(y ~ 1, bscov="har1", data=dbs, control=list(addSlist=addS))
print(summary(mv4), digits=1, report="var")
# }
# NOT RUN {
# }
# NOT RUN {
### USE A LONG FORMAT, AS MORE FLEXIBLE AND ALLOWS MORE COMPLEX MODELS
# RESHAPE THE DATASET
long <- reshape(dbs, direction="long", idvar="author", v.names=c("eff","var"),
varying=list(1:4*2+1, 1:4*2+2))
# RE-RUN THE LAST (FOURTH) MODEL
mv4b <- mixmeta(eff ~ factor(time) - 1, random = ~ factor(time) -1 | author,
bscov="har1", data=long, control=list(addSlist=addS))
print(summary(mv4b), digits=1, report="var")
# COMMON RANDOM EFFECTS (TABLE 1, SECOND MODEL)
mv2 <- mixmeta(eff ~ factor(time) - 1, var, random = ~ factor(time) -1 | author,
bscov="id", data=long)
print(summary(mv2), digits=1, report="var")
# FOURTH MODEL WITH ADDITIONAL CENTERED META-PREDICTORS (TABLE 2)
mv4plus <- mixmeta(eff ~ factor(time) - 1 + I(duration-14) + I(baseline-52),
random = ~ factor(time) -1 | author, bscov="har1", data=long,
control=list(addSlist=addS))
print(summary(mv4plus), digits=1, report="var")
# }
# NOT RUN {
### SEE help(gliomas) FOR A COMPLEMENTARY EXAMPLE
# }
Run the code above in your browser using DataLab