## Install R package netmeta ## #install.packages("netmeta") ## Make R package available ## library(netmeta) ## ## ## Pairwise meta-analysis ## ## data(Fleiss93) ## m1 <- metabin(event.e, n.e, event.c, n.c, data = Fleiss93, sm = "OR", comb.random = FALSE) ## m2 <- metabin(event.e, n.e, event.c, n.c, data = Fleiss93, method = "GLMM", comb.random = FALSE) ## ## Results for Mantel-Haenszel method ## summary(m1) ## ## Results for Logistic regression model with fixed study effects ## summary(m2) ## Mantel-Haenszel weights (referring to the natural scale) ## m1$w.fixed ## Logistic regression weights not available ## m2$w.fixed ## Function to obtain importance weights (fixed effect model) ## wts <- function(x) { if (!inherits(x, "metabin")) stop("Argument 'x' must be an object of class 'metabin'.") dat <- x$data ## studies <- unique(dat$.studlab) ## weights <- data.frame(studlab = studies, w = rep_len(NA, length(studies))) for (i in studies) { dat.i <- dat[dat$.studlab != i, ] ## if (x$method != "GLMM") m.i <- metabin(event.e, n.e, event.c, n.c, data = dat.i, method = x$method, sm = x$sm, incr = x$incr, allincr = x$allincr, addincr = x$addincr, allstudies = x$allstudies, MH.exact = x$MH.exact, RR.Cochrane = x$RR.Cochrane) else m.i <- metabin(event.e, n.e, event.c, n.c, data = dat.i, method = x$method, sm = x$sm, model.glmm = x$model.glmm) ## weights$w[weights$studlab == i] <- 1 - (x$seTE.fixed / m.i$seTE.fixed)^2 } weights } ## Calculate and print importance weights ## w1 <- wts(m1) w2 <- wts(m2) w1 w2 ## Compare standardized and importance weights ## round(m1$w.fixed / sum(m1$w.fixed), 4) round(w1$w, 4) ## round(w2$w, 4) ## sum(w1$w) sum(w2$w) ## ## ## Hypothetical networks ## ## pdf("Additional File 2.pdf") ## ## Example: Chain network with four treatments A, B, C, and D ## study <- c("AB","BC","CD") effect <- rep(1, 3) se.effect <- rep(1, 3) t1 <- c("A", "B", "C") t2 <- c("B", "C", "D") ## net1 <- netmeta(effect, se.effect, t1, t2, study) ## Direct evidence proportion ## netmeasures(net1)$proportion ## Network plot for chain (not included in publication) ## netgraph(net1, start = "circle", iterate = TRUE, points = TRUE, adj = 0.5, cex.points = 10, col.points = c("red", "gray", "gray", "red"), cex = 2, lwd = 1, col = "black", thickness = "w.fixed") ## Importance weights ## ni1 <- netimpact(net1, verbose = TRUE) ni1 ## Show all subnetworks (not included in publication) ## netgraph(ni1, plastic = FALSE, points = TRUE, adj = 0.5, cex.points = 10, col.points = "gray", cex = 2, lwd = 1, col = "black", thickness = "w.fixed") ## ## ## Example: Circle network with eight treatments A - G ## ## study <- c("AB", "BC", "CD", "DE", "EF", "FG", "GA") effect <- rep(0, 7) se.effect <- rep(1, 7) t1 <- c("A", "B", "C", "D", "E", "F", "G") t2 <- c("B", "C", "D", "E", "F", "G", "A") ## net2 <- netmeta(effect, se.effect, t1, t2, study) ## Direct evidence proportion ## netmeasures(net2)$proportion ## Network plot for circle (Figure 2, left panel) ## netgraph(net2, plastic = FALSE, points = TRUE, adj = 0.5, cex.points = 10, col.points = "gray", cex = 2, lwd = 1, col = "black", thickness = "number.of.studies") ## Importance weights ## ni2 <- netimpact(net2, verbose = TRUE) ni2 round(7 * ni2$impact.fixed) ## Show all subnetworks (not included in publication) ## netgraph(ni2, plastic = FALSE, points = TRUE, adj = 0.5, cex.points = 10, col.points = "gray", cex = 2, lwd = 1, col = "black", thickness = "number.of.studies") ## Heatmap with importance weights ## heatmap(t(ni2$impact.fixed[ , choose(net2$n, 2):1]), Rowv = NA, Colv = NA, col = gray.colors(19, 0.95, 0.05), xlab = "Study", ylab = "Comparison") ## ## ## Example: Network with bridge and six treatments A - F ## ## study <- 1:7 t1 <- LETTERS[c(1, 1, 2:6)] t2 <- LETTERS[c(2, 3, 3, 4, 5, 6, 4)] effect <- rep(0, 7) se.effect <- rep(1, 7) ## net3 <- netmeta(effect, se.effect, t1, t2, study, comb.random = FALSE) ## Direct evidence proportion ## netmeasures(net3)$proportion ## Network plot for bridge (Figure 2, right panel) ## netgraph(net3, iterate = TRUE, points = TRUE, adj = 0.5, cex.points = 10, col.points = "gray", cex = 2, lwd = 1, col = "black", thickness = "number.of.studies") ## Importance weights (Table 2) ## ni3 <- netimpact(net3, verbose = TRUE) ni3 ## Show all subnetworks (not included in publication) ## netgraph(ni3, iterate = TRUE, points = TRUE, adj = 0.5, cex.points = 10, col.points = "gray", cex = 2, lwd = 1, col = "black", thickness = "number.of.studies") ## Show heatmap (not included in publication) ## heatmap(t(ni3$impact.fixed[, c("A:B", "A:C", "B:C", "A:D", "B:D", "A:E", "A:F", "C:D", "B:E", "B:F", "C:F", "C:E", "D:F", "D:E", "E:F")]), Rowv = NA, Colv = NA, xlab = "Study", ylab = "Comparison") ## ## ## Real data networks ## ## ## ## Parkinson example (included in R package netmeta); Table 1 ## data(parkinson) parkinson ## p4 <- pairwise(list(Treatment1, Treatment2, Treatment3), n = list(n1, n2, n3), mean = list(y1, y2, y3), sd = list(sd1, sd2, sd3), data = parkinson, studlab = Study) ## net4 <- netmeta(p4) ## Direct evidence proportion ## netmeasures(net4)$proportion ## Study weights per comparison (Table 5) ## for (i in unique(net4$treat1)) { for (j in unique(net4$treat2)) { dat <- net4$data[net4$data$treat1 == i & net4$data$treat2 == j, ] if (dim(dat)[1] > 1) { print(paste("Comparison", i, ":", j)) m.i <- metagen(TE, seTE, studlab, dat) print(round(100 * m.i$w.fixed / sum(m.i$w.fixed), 2)) } } } ## Network plot for parkinson data set (part of Figure 3) ## netgraph(net4, plastic = FALSE, number.of.studies = TRUE, points = TRUE, adj = 0.5, cex.points = 10, col.points = "gray", cex = 2, lwd = 1, col = "black", thickness = "number.of.studies", main = "Full network", seq = c(1, 2, 4, 5, 3), col.multiarm = "gray") ## Importance weights (Table 4) ## ni4 <- netimpact(net4, verbose = TRUE) ni4 ## Show all subnetworks (Figure 3) ## netgraph(ni4, plastic = FALSE, points = TRUE, adj = 0.5, cex.points = 10, col.points = "gray", cex = 2, lwd = 1, col = "black", thickness = "number.of.studies", col.multiarm = "darkgray", col.ignore = "red", seq = c(1, 2, 4, 5, 3)) ## Heatmaps with importance weights ## heatmap(t(ni4$impact.fixed[ , choose(net4$n, 2):1]), Rowv = NA, Colv = NA, xlab = "Study", ylab = "Comparison", cexCol = 1.5, cexRow = 1.5) ## heatmap(t(ni4$impact.fixed[ , choose(net4$n, 2):1]), Rowv = NA, Colv = NA, col = gray.colors(19, 0.95, 0.05), xlab = "Study", ylab = "Comparison") ## ## Example with thrombolytic data (Riley et al., 2018) ## thrombo <- read.csv2("Additional File 3.csv") ## p5 <- pairwise(list(treat1, treat2, treat3), list(r1, r2, r3), list(n1, n2, n3), data = thrombo, studlab = studlab, sm = "OR") ## net5 <- netmeta(p5, comb.random = FALSE) ## summary(net5) ## Direct evidence proportion ## netmeasures(net5)$proportion ## Network plot for thrombolytic data (Figure 1) ## netgraph(net5, seq = c("H", "C", "G", "A", "D", "F", "B", "E"), plastic = FALSE, points = TRUE, adj = 0.5, cex.points = 10, col.points = "gray", cex = 2, lwd = 1.25, col = "black", thickness = "number.of.studies", col.multiarm = gray.colors, main ="Full network") ## Importance weights ## ni5 <- netimpact(net5, verbose = TRUE) ## ## Table 6 (to compare with Table 4 in Riley et al. (2018)) ## round(100 * ni5$impact.fixed[, 1:7], 2) ## Heatmaps with importance weights (Figure 4) ## heatmap(t(ni5$impact.fixed[, choose(net5$n,2):1]), Rowv = NA, Colv = NA, col = gray.colors(19, 0.95, 0.05)) ## Study weights per comparison (Table 7) ## for (i in unique(net5$treat1)) { for (j in unique(net5$treat2)) { dat <- net5$data[net5$data$treat1 == i & net5$data$treat2 == j, ] if (dim(dat)[1] > 1) { print(paste("Comparison", i, ":", j)) m.i <- metagen(TE, seTE, studlab, dat) print(round(100 * m.i$w.random / sum(m.i$w.random), 2)) } } } ## Analysis based on the Mantel-Haenszel method for NMA ## nb5 <- netmetabin(p5) summary(nb5) ## Forest plots (not included in publication) ## labels <- c("streptokinase", "accelerated alteplase", "alteplase", "streptokinase + alteplase", "tenecteplase", "reteplase", "urokinase", "anistreptilase") forest(net5, ref = "A", labels = labels) forest(nb5, ref = "A", labels = labels) ## Importances based on the Mantel-Haenszel method ## nib5 <- netimpact(nb5, verbose = TRUE) ## Table (to compare with our Table 6 and Table 4 in Riley et al. (2018)) ## round(100 * nib5$impact.fixed[, 1:7], 2) dev.off()