########################################################## # # # PREVENTION OF TUBERCULOSIS # # # # # ########################################################## # # Combining binary data # # vac.dis = number of diseases in the vaccinated group # vac.nodis = number of no diseases in the vaccinated group # novac.dis = number of diseases in the non-vaccinated group # novac.nodis = number of no diseases in the non-vaccinated group # vac = number of indivduals in the vaccinated group # novac = number of individuals in the non-vaccinated group vac.dis <- c( 4, 6, 3, 62, 33, 180, 8, 505, 29, 17, 186, 5, 27) vac.nodis <- c(119, 300, 228, 13536, 5036, 1361, 2537, 87886, 7470, 1699, 50448, 2493, 16886) novac.dis <- c( 11, 29, 11, 248, 47, 372, 10, 499 , 45, 65, 141, 3, 29) novac.nodis <- c(128, 274, 209, 12619, 5761, 1079, 619, 87892, 7232, 1600, 27197, 2338, 17825) vac <- vac.dis + vac.nodis novac <- novac.dis + novac.nodis # Possible covariates which may explain heterogeneity # # latitude = surrogate variable for the place where the study was conducted # year = year of publication # allocation = type of allocation (1 = random, 2 = alternate, 3 = systematic) # latitude <- c(44, 55, 42, 52, 13, 44, 19, 13, 27, 42, 18, 33, 33) year <- c(48, 49, 60, 77, 73, 53, 73, 80, 68, 61, 74, 69, 76) allocation <- c( 1, 1, 1, 1, 2, 2, 1, 1, 1, 3, 3, 3, 3) # ############################################################## # # # Effect size: log relative risk and standard error # # # ############################################################## p.vac <- vac.dis / vac p.novac <- novac.dis / novac log.rr <- log(p.vac / p.novac) std.logrr <- sqrt(1 / vac.dis - 1 / vac + 1 / novac.dis - 1 / novac) # ############################################################ # Generic inverse variance method using R package meta # ############################################################ library(meta) # # Combining log relative risks using functions metagen and metabin # Note: results are backtransformed to the relative risk scale comb.logrr <- metagen(log.rr, std.logrr) comb.logrr metabin(vac.dis, vac, novac.dis, novac, method = "Inverse", sm = "RR") # # Confidence interval plot with fixed and random effects meta-analysis plot(comb.logrr, comb.f = TRUE, comb.r = TRUE, main = "Tuberculosis studies", xlab = "Log relative risk", xlim = c(-2.5,1)) # ############################################################ # Meta-regression using R package metafor # ############################################################ library(metafor) # # covariate latitude centered around its mean lat.center <- latitude-mean(latitude) # # random effect meta-analysis # rr <- rma.uni(yi=log.rr, sei=std.logrr, method="REML") summary(rr) # # meta-regession with covariate latitude metareg.lat <- rma.uni(yi=log.rr, sei=std.logrr, mods=cbind(lat.center), method="REML") summary(metareg.lat) meta.reg.lat2 <- rma.uni(yi=log.rr, sei=std.logrr, mods=cbind(lat.center), method="REML", knha=TRUE) summary(meta.reg.lat2)