Created
June 25, 2014 04:28
-
-
Save joaovissoci/870b47ecb8dbb3e98847 to your computer and use it in GitHub Desktop.
#R TEMPLATE FOR NETWORK METANALYSIS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ##################################################################################### | |
| #R TEMPLATE FOR NETWORK METANALYSIS | |
| ##################################################################################### | |
| # | |
| # | |
| # | |
| # | |
| # | |
| ##################################################################################### | |
| #SETTING ENVIRONMENT | |
| ##################################################################################### | |
| #All packages must be installes with install.packages() function | |
| lapply(c("Hmisc","car","psych","nortest","ggplot2","pastecs","repmis", | |
| "mvnormtest","polycor"), | |
| library, character.only=T) | |
| ##################################################################################### | |
| #IMPORTING DATA | |
| ##################################################################################### | |
| #LOADING DATA FROM A .CSV FILE | |
| #data<-read.csv("/Users/rpietro/Desktop/MDD_BIPD_Baseline.csv",sep=",") | |
| #information between " " are the path to the directory in your computer where the data is stored | |
| #LOADING DATA FROM AN INTERNET PAGE (GOOGLE, GITHUB, FIGSHARE) | |
| #Import data from Dropbox, in .csv format | |
| #Instructions here http://goo.gl/Ofa7gQ | |
| #data <- repmis::source_DropboxData("teste.csv", | |
| # "us77xue32dck2gd", | |
| # sep = ",", | |
| # header = TRUE) | |
| ########################################################################################### | |
| #DATA MANAGEMENT | |
| ########################################################################################### | |
| #Creating a data frame (group of variables) | |
| #numeric<-with(data, data.frame(Peso,Altura,IMC, | |
| # Idade)) | |
| #Change variables properties | |
| #Change variable to factor | |
| #data$Classificacao<-as.factor(data$Classificacao) | |
| #Change variable to character | |
| #data$Classificacao<-as.character(data$Classificacao) | |
| #Change variable to numeric | |
| #data$Classificacao<-as.numeric(data$Classificacao) | |
| #Recoding variables | |
| #data$Classificacao<-car::recode(data$Classificacao,"1='baixo';2='medio'; | |
| # 3='alto'") | |
| ##################################################################################### | |
| #NETWORK METANALYSIS | |
| ##################################################################################### | |
| network<-mtc.network(vo2new) | |
| model <- mtc.model(network, type="nodesplit") | |
| plot(model) | |
| print(model) | |
| summary(model) | |
| results<-mtc.run(model,thin=10) | |
| gelman.plot(results) | |
| summary(results) | |
| #Iterations = 5001:24991 | |
| #Thinning interval = 10 | |
| #Number of chains = 4 | |
| #Sample size per chain = 2000 | |
| #1. Empirical mean and standard deviation for each variable, | |
| # plus standard error of the mean: | |
| # Mean SD Naive SE Time-series SE | |
| #d.2.3 2.367 1.2124 0.013555 0.02294 | |
| #d.2.control -3.383 0.9434 0.010548 0.01889 | |
| #deviance 94.203 6.2409 0.069775 0.07568 | |
| #sd.d 1.084 0.8009 0.008954 0.02060 | |
| #2. Quantiles for each variable: | |
| # | |
| # 2.5% 25% 50% 75% 97.5% | |
| #d.2.3 -0.05114 1.606 2.3804 3.160 4.725 | |
| #d.2.control -5.18383 -3.994 -3.3567 -2.764 -1.580 | |
| #deviance 83.14399 89.839 93.7918 98.112 107.479 | |
| #sd.d 0.03576 0.458 0.9444 1.537 3.015 | |
| #$DIC | |
| #Mean deviance Penalty (pD) DIC | |
| # 94.20308 18.24319 112.44626 | |
| plot(results) | |
| forest(results) | |
| ranks<-rank.probability(results) | |
| print(ranks) | |
| plot(ranks) | |
| plot(ranks,beside=TRUE) | |
| effects<-relative.effect(results,"TC") | |
| summary(effects) | |
| ##################################################################################### | |
| #NETWORK METANALYSIS - INDIRECT EFFECTS | |
| ##################################################################################### | |
| model<-mtc.anohe(network) | |
| summary(model) | |
| model<-mtc.nodesplit(network) | |
| summary(model) | |
| print(model) | |
| plot(model) | |
| ########################################################################################### | |
| #Examples from NetMeta package - extracted from http://goo.gl/NV5KZ0 | |
| ########################################################################################### | |
| ###Network meta-analysis using graph-theoretical method | |
| # | |
| data(Senn2013) | |
| ## | |
| ## Generation of an object of class 'netmeta' with | |
| ## reference treatment 'plac', i.e. placebo | |
| ## | |
| net1 <- netmeta(TE, seTE, treat1, treat2, studlab, | |
| data=Senn2013, sm="MD", reference="plac") | |
| ## Change printing order of treatments (placebo first) | |
| ## | |
| trts <- c("plac", "acar", "benf", "metf", "migl", "piog", | |
| "rosi", "sita", "sulf", "vild") | |
| net3 <- netmeta(TE, seTE, treat1, treat2, studlab, | |
| data=Senn2013, sm="MD", | |
| seq=trts) | |
| print(summary(net3), digits=2) | |
| ###Print and summary method for objects of class netmeta | |
| #Print and summary method for objects of class netmeta. | |
| print(net1, ref="plac", digits=3) | |
| summary(net1) | |
| ###Design-based decomposition of Cochran’s Q in network meta-analysis | |
| #This function performs a design-based decomposition of Cochran’s Q for assessing the homogeneity in the whole network, the homogeneity within designs, and the homogeneity/consistency between designs. It allows also an assessment of the consistency assumption after detaching the effect of single designs. | |
| decomp.design(x, tau.preset=x$tau.preset) | |
| ## Decomposition of Cochran's Q | |
| ## | |
| decomp.design(net1) | |
| ###Print method for objects of class decomp.design | |
| #Print and summary method for objects of class decomp.design. | |
| print(decomp.design(net1)) | |
| ###Forest plot | |
| #Draws a forest plot in the active graphics window (using grid graphics system). | |
| forest(net1, ref="plac") | |
| forest(net1, xlim=c(-1.5,1), ref="plac", | |
| xlab="HbA1c difference", | |
| leftcols="studlab", rightcols=NULL, | |
| leftlabs="Contrast to placebo") | |
| ###Network graph | |
| #This function generates a graph of the evidence network. | |
| trts <- c("plac", "benf", "migl", "acar", "sulf", | |
| "metf", "rosi", "piog", "sita", "vild") | |
| netgraph(net1, highlight="acar:metf", seq=trts) | |
| netgraph(net1, plastic=FALSE, highlight="acar:metf") ## Network graph without 3D look of the comparisons and one highlighted comparison | |
| netgraph(net1, seq=c(1, 3, 5, 2, 9, 4, 7, 6, 8, 10), | |
| labels=LETTERS[1:10])## Network graph with changed labels and specified order of the treatments | |
| ###Net heat plot | |
| netheat(net1) | |
| netheat(net1, random=TRUE) | |
| ###Measures for characterizing a network meta-analysis | |
| #This function provides measures for quantifying the direct evidence proportion, the mean path length and the minimal parallelism (the latter on aggregated and study level) of mixed treatment comparisons (network estimates) as well as the evidence flow per design, see König et al. (2013). These measures support the critical evaluation of the network meta-analysis results by rendering transparent the process of data pooling. | |
| nm1 <- netmeasures(net1) | |
| plot(nm1$meanpath, nm1$minpar, pch="", | |
| xlab="Mean path length", ylab="Minimal parallelism") | |
| text(nm1$meanpath, nm1$minpar, names(nm1$meanpath), cex=0.8)## Plot of minimal parallelism versus mean path length | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment