Skip to content

Commit c5c46b9

Browse files
committed
hartung knapp metafor
1 parent 5aac75b commit c5c46b9

File tree

3 files changed

+120
-2
lines changed

3 files changed

+120
-2
lines changed

Clinical-Trials/RCT/RCT.Rmd

+51-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This is an R Markdown document. Markdown is a simple formatting syntax for autho
1515

1616
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
1717

18-
The data is from Jama Cardiology on Associations of Omega-3 Fatty Acid Supplement Use With Cardiovascular Disease Risks Meta-analysis of 10 Trials Involving 77917 Individuals
18+
The data is from Jama Cardiology on Associations of Omega-3 Fatty Acid Supplement Use With Cardiovascular Disease Risks Meta-analysis of 10 Trials Involving 77917 Individuals.
1919

2020
```{r metafor}
2121
library(tidyverse)
@@ -41,20 +41,67 @@ result<-predict(res, transf=exp, digits=2)
4141
forest(res, targs=list(study=rct$study),
4242
main="RCT of Omega3 fatty acid for cardiovascular disease")
4343
# funnel plot
44+
png(file="funnelplot.png")
4445
funnel(res, refline=0, level=c(90, 95, 99), shade=c("white", "gray", "darkgray"))
46+
dev.off()
4547
4648
```
4749

4850
```{r random effect}
4951
dat <- escalc(measure = "OR",ai=ai, n1i=n1i, ci=ci, n2i=n2i,data=rct)
5052
res.DL<-rma(yi,vi, method = "DL",data=dat)
5153
forest(res.DL,main="RCT of Omega3 fatty acid for cardiovascular disease")
54+
55+
#create subgroups
56+
rct1<-rct[1:5,]
57+
rct2<-rct[6:10,]
58+
rct1$group[rct1$year>=1999]<-"wide"
59+
rct2$group[rct2$year>=1999]<-"narrow"
60+
rct3<-rbind(rct1,rct2)
61+
dat$group<-rct3$group
62+
63+
#plot subgroups
64+
res.group <- rma(yi, vi, mods = ~ group, data=dat)
65+
res.wide<- rma(yi, vi, subset=(group=="wide"), data=dat)
66+
res.wide
67+
res.narrow<- rma(yi, vi, subset=(group=="narrow"), data=dat)
68+
res.narrow
69+
#https://stackoverflow.com/questions/39392706/using-the-r-forestplot-package-is-there-a-way-to-assign-variable-colors-to-boxe
70+
#confidence interval
71+
rmeta_conf <-
72+
structure(list(
73+
mean = c(NA, NA, exp(-0.0676), exp(-0.0266), NA, exp(-0.0352)),
74+
lower = c(NA, NA, exp(-0.1873), exp(-0.0715), NA, exp(-0.0753)),
75+
upper = c(NA, NA, exp(0.0520), exp(0.0183), NA, exp(0.0049))),
76+
.Names = c("mean", "lower", "upper"),
77+
row.names = c(NA, -6L),
78+
class = "data.frame")
79+
80+
81+
#table data
82+
tabletext<-cbind(c("","Trials","wide","narrow",NA,"Summary"),
83+
c("Events","(Drugs)",sum(filter(dat,group=="wide")$ai),sum(filter(dat,group=="narrow")$ai),NA,NA),
84+
c("Events","(Control)",sum(filter(dat,group=="wide")$ci),sum(filter(dat,group=="narrow")$ci),NA,NA),
85+
c("","OR","0.934","0.974",NA,"0.965")
86+
)
87+
88+
#use forestplot
89+
library(forestplot)
90+
forestplot(tabletext,
91+
rmeta_conf,new_page = TRUE,
92+
is.summary=c(TRUE,TRUE,rep(FALSE,8),TRUE),
93+
clip=c(0.1,2.5),
94+
xlog=TRUE,
95+
col=fpColors(box="royalblue",line="darkblue", summary="royalblue"))
96+
5297
```
5398
```{r baujat}
5499
# adjust margins so the space is better used
100+
png(file="baujat.png")
55101
par(mar=c(5,4,2,2))
56102
# create Baujat plot to explore source of heterogeneity
57103
baujat(res.DL, xlim=c(0,20), ylim=c(0,0.2))
104+
dev.off()
58105
```
59106
```{r gosh}
60107
### fit FE model to all possible subsets
@@ -63,7 +110,10 @@ sav <- gosh(res.DL)
63110
### create GOSH plot
64111
### red points for subsets that include and blue points
65112
### for subsets that exclude study 16 (the ISIS-4 trial)
113+
png(file="gosh.png")
66114
plot(sav, out=dim(rct)[1], breaks=100)
115+
dev.off()
67116
```
68117

118+
69119
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.

Clinical-Trials/RCT/RCT_omega13.Rmd

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
title: "RCT_omega13"
3+
author: "GNtem2"
4+
date: "27/07/2020"
5+
output: html_document
6+
---
7+
8+
```{r setup, include=FALSE}
9+
knitr::opts_chunk$set(echo = TRUE)
10+
```
11+
12+
## R Markdown
13+
14+
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
15+
16+
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
17+
18+
```{r jaha}
19+
library(metafor)
20+
library(tidyverse)
21+
22+
library(tidyverse)
23+
library(metafor)
24+
25+
Trials=c("GISSI-P","JELIS","GISSI-HF","DOIT","SU.FOL.OM3","Alpha Omega","OMEGA","ORIGIN","R&P","AREDS-2","VITAL")
26+
27+
#
28+
Treatment_AMI=c(223,71,107,11,32,89,87,228,30,145,186)
29+
Treatment_No=c(5666,9326,3494,282,1253,2404,1919,6239,2147,12933,7740)
30+
Control_AMI=c(233,93,129,9,32,102,78,248,40,200,200)
31+
Control_No=c(5658,9319,3481,281,1248,2433,1885,6266,2056,12938,7740)
32+
33+
rct<-data.frame(Trials,Treatment_AMI,Treatment_No,Control_AMI,Control_No) %>% rename(ai=Treatment_AMI,n1i=Treatment_No,ci=Control_AMI,
34+
n2i=Control_No,study=Trials)
35+
36+
#peto's fixed effect method
37+
res <- rma.peto(ai=ai, n1i=n1i, ci=ci, n2i=n2i, data=rct)
38+
print(res, digits=2)
39+
40+
result<-predict(res, transf=exp, digits=2)
41+
#forest plot
42+
forest(res, targs=list(study=rct$study),
43+
main="RCT of Omega3 fatty acid for cardiovascular disease")
44+
# funnel plot
45+
46+
funnel(res, refline=0, level=c(90, 95, 99), shade=c("white", "gray", "darkgray"))
47+
48+
#DL
49+
dat <- escalc(measure = "OR",ai=ai, n1i=n1i, ci=ci, n2i=n2i,data=rct)
50+
res.DL<-rma(yi,vi, method = "DL",data=dat)
51+
forest(res.DL,main="RCT of Omega3 fatty acid for cardiovascular disease-DL")
52+
53+
#Hartung-ignore error message
54+
res.HK<-rma.uni(yi,vi=1/vi,method="FE",knha=TRUE,data=dat)
55+
forest(res.HK,main="RCT of Omega3 fatty acid for cardiovascular disease-DL")
56+
```
57+
58+
## Including Plots
59+
60+
You can also embed plots, for example:
61+
62+
```{r pressure, echo=FALSE}
63+
plot(pressure)
64+
```
65+
66+
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,9 @@ The issue regarding combining data from RCT and observational studies in the set
159159

160160

161161
### RCT
162-
Revman is an excellent tool for performing meta-analysis of trials but lacks the flexibility of R packages. Here we will use metafor package, see rct.Rmd. The following methods are demonstrated: fixed effect and random effect analyses, forest plot, funnel plot (for exploring publication bias), Baujat plot (for exploring source of heterogeneity) and GOSH plot (for exploring study heterogeneity using output of fixed effect model for all possible subsets). The data is from Jama Cardiology 2020 on Associations of Omega-3 Fatty Acid Supplement Use With Cardiovascular Disease Risks Meta-analysis of 10 Trials Involving 77917 Individuals.
162+
Revman is an excellent tool for performing meta-analysis of trials but lacks the flexibility of R packages. Here we will use metafor package, see RCT.Rmd. The following methods are demonstrated: fixed effect and random effect analyses, forest plot, funnel plot (for exploring publication bias), Baujat plot (for exploring source of heterogeneity) and GOSH plot (for exploring study heterogeneity using output of fixed effect model for all possible subsets).
163+
The data is from Jama Cardiology 2020 on Associations of Omega-3 Fatty Acid Supplement Use With Cardiovascular Disease Risks Meta-analysis of 10 Trials Involving 77917 Individuals. Subsequently a meta-analysis in J Am Heart
164+
Assoc. 2019;8:e013543. DOI: 10.1161/JAHA.119.013543 reported that contrary to the earlier meta-analysis, Omega-3 lowers the risk of cardiovascular diseases with effect related to dose. The analysis using DerSimonian Laird method is provided in RCT.Rmd and Hartung Knapp method is provided in RCT_omega13.Rmd.
163165

164166
Funnel plot of RCT on Associations of Omega-3 Fatty Acid Supplement Use With Cardiovascular Disease Risks
165167
![here](./Clinical-Trials/RCT/funnelplot.png)

0 commit comments

Comments
 (0)