### copy data into 'dat' and examine data
dat <- dat.dagostino1998
head(dat, 16)
if (FALSE) {
### load metafor package
library(metafor)
### compute standardized mean differences and corresponding sampling variances
dat <- escalc(measure="SMD", m1i=mt, m2i=mc, sd1i=sdt, sd2i=sdc, n1i=nt, n2i=nc, data=dat,
add.measure=TRUE)
### compute log odds ratios and corresponding sampling variances
dat <- escalc(measure="OR", ai=xt, ci=xc, n1i=nt, n2i=nc, data=dat,
replace=FALSE, add.measure=TRUE, add=1/2, to="all")
### inspect data for the first study
head(dat, 8)
### fit a random-effects model for incremental change in runny nose severity at day 1
res <- rma(yi, vi, data=dat, subset=outcome=="rnic1")
res
### fit a random-effects model for reaching the goal of therapy for runny nose severity at day 1
res <- rma(yi, vi, data=dat, subset=outcome=="rngoal1")
res
predict(res, transf=exp)
### construct approximate V matrix assuming a correlation of 0.7 for sampling errors within studies
dat$esid <- ave(dat$study, dat$study, FUN=seq)
V <- vcalc(vi, cluster=study, obs=esid, rho=0.7, data=dat)
### fit a model for incremental change in runny nose severity at day 1 and at day 2, allowing for
### correlated sampling errors (no random effects added, since there does not appear to be any
### noteworthy heterogeneity in these data)
res <- rma.mv(yi, V, mods = ~ 0 + outcome, data=dat, subset=outcome %in% c("rnic1","rnic2"))
res
### test if there is a difference in effects at day 1 and day 2
anova(res, X=c(1,-1))
}
Run the code above in your browser using DataLab