Skip to content

Instantly share code, notes, and snippets.

@MJacobs1985
Created June 22, 2022 19:09
Show Gist options
  • Save MJacobs1985/51b5fec3a4f394f0586e0ef806666b88 to your computer and use it in GitHub Desktop.
Save MJacobs1985/51b5fec3a4f394f0586e0ef806666b88 to your computer and use it in GitHub Desktop.
#### IMPORT LIBRARIES ####
rm(list = ls())
library(brms)
library(dplyr)
library(ggplot2)
library(rethinking)
library(dmetar)
library(meta)
library(tidybayes)
library(ggridges)
library(grid)
library(gridExtra)
library(glue)
library(stringr)
library(forcats)
library(readxl)
library(tidyr)
library(dmetar)
theme_set(theme_bw())
#### LOAD DATA ####
df <- read_excel("PregnantVaccineData.xlsx")
#### Meta-analysis of proportions - no sub-group analysis, no cleaning, just proportions ####
def<-df%>%
select(Study, Propmeta, eventexp, nexp)%>%
drop_na()%>%
filter(Propmeta=="1")%>%
metaprop(event=eventexp,
n=nexp,
data=.,
studlab = Study,
sm="Plogit",
level = 0.95,
fixed=TRUE,
random=TRUE,
hakn=F,
method.tau="DL")
forest(def)
#### Meta-analysis of odds ratios - including all studies included by the paper itself - no further selection ####
def<-df%>%
select(Study, ORmeta, eventexp, nexp, eventcontrol, ncontrol)%>%
filter(ORmeta=="1")%>%
drop_na()%>%
metabin(eventexp,
nexp,
eventcontrol,
ncontrol,
studlab=Study,
data = .,
method = "Inverse",
sm="OR",
MH.exact = TRUE,
fixed = FALSE,
random = TRUE,
method.tau = "REML",
hakn = TRUE,
prediction = TRUE)
summary(def)
exp(def$TE.random)
def$tau2
find.outliers(def)
def.inf <- InfluenceAnalysis(def, random = TRUE)
plot(def.inf, "baujat")
plot(def.inf, "influence")
plot(def.inf, "es")
plot(def.inf, "i2")
forest.meta(def, layout = "RevMan5")
drapery(def,
labels ="studlab",
type = "pval",
legend = FALSE)
funnel(def)
metabias(def, method.bias = 'linreg', k.min = 10, plotit = T)
#### Meta-analysis of odds ratio Stillbirth - replicating Nature analysis ####
df2<-df%>%
select(Study,
eventexp, nexp,
eventcontrol, ncontrol,
Outcome)%>%
filter(Outcome=="Stillbirth")
def2<-metabin(eventexp,
nexp,
eventcontrol,
ncontrol,
studlab=Study,
tau.common=FALSE,
data = df2,
method = "GLMM",
sm="OR",
MH.exact = TRUE,
fixed = FALSE,
random = TRUE,
method.tau = "ML",
hakn = TRUE,
prediction = TRUE)
summary(def2)
forest.meta(def2, layout = "RevMan5")
exp(def2$TE.random)
def2$tau2
find.outliers(def2)
def.inf <- InfluenceAnalysis(def2, random = TRUE)
plot(def.inf, "baujat")
plot(def.inf, "influence")
plot(def.inf, "es")
plot(def.inf, "i2")
drapery(def2,
labels ="studlab",
type = "pval",
legend = FALSE)
funnel(def2)
metabias(def2, method.bias = 'linreg', k.min = 5, plotit = T)
#### Meta-analysis of odds ratio Stillbirth - replicating Nature analysis - sub-group analysis by design ####
df3<-df%>%
select(Study,
eventexp, nexp,
eventcontrol, ncontrol,
Outcome,Design)%>%
filter(Outcome=="Stillbirth")%>%
drop_na()
def3<-metabin(eventexp,
nexp,
eventcontrol,
ncontrol,
studlab=Study,
subgroup=Design,
tau.common=FALSE,
data = df3,
method = "GLMM",
sm="OR",
MH.exact = TRUE,
fixed = FALSE,
random = TRUE,
method.tau = "ML",
hakn = TRUE,
prediction = TRUE)
summary(def3)
forest.meta(def3, layout = "RevMan5")
exp(def3$TE.random)
def3$tau2
find.outliers(def3)
def.inf <- InfluenceAnalysis(def3, random = TRUE)
plot(def.inf, "baujat")
plot(def.inf, "influence")
plot(def.inf, "es")
plot(def.inf, "i2")
drapery(def3,
labels ="studlab",
type = "pval",
legend = FALSE)
funnel(def3)
metabias(def3, method.bias = 'linreg', k.min = 5, plotit = T)
### Reply from Dr. Asma Khalil
df1 <- read_excel("PregnantVaccineData.xlsx")
df11<-df1%>%
select(Study,
eventexp,
nexp,
eventcontrol, ncontrol,
Outcome)%>%
filter(Outcome=="Stillbirth")%>%
drop_na()
m1<-metabin(eventexp,
nexp,
eventcontrol,
ncontrol,
studlab=Study,
tau.common=FALSE,
data = df11,
method = "GLMM",
sm="OR",
method.tau = "ML",
prediction = TRUE)
m1
forest.meta(m1, layout = "RevMan5")
m2<-metabin(eventexp,
nexp,
eventcontrol,
ncontrol,
studlab=Study,
tau.common=FALSE,
data = df11,
method ="GLMM",
model.glmm = "CM.AL",
sm="OR",
method.tau = "ML",
prediction = TRUE,
hakn = TRUE)
m2
forest.meta(m2, layout = "RevMan5")
m3<-metabin(eventexp,
nexp,
eventcontrol,
ncontrol,
studlab=Study,
data = df11,
method = "GLMM",
model.glmm = "CM.EL",
sm="OR",
tau.common=FALSE,
method.tau = "ML",
prediction = TRUE)
m3
forest.meta(m3, layout = "RevMan5")
m4<-metabin(eventexp,
nexp,
eventcontrol,
ncontrol,
studlab=Study,
data = df11,
method = "MH",
sm="OR",
tau.common=FALSE,
method.tau = "ML",
prediction = TRUE,
hakn = TRUE)
m4
summary(m4)
m5<-metabin(eventexp,
nexp,
eventcontrol,
ncontrol,
studlab=Study,
data = df11,
method = "Inverse",
sm="OR",
tau.common=FALSE,
method.tau = "ML",
prediction = TRUE,
hakn = TRUE)
m5
m6<-metabin(eventexp,
nexp,
eventcontrol,
ncontrol,
studlab=Study,
data = df11,
method = "Peto",
sm="OR",
tau.common=FALSE,
method.tau = "ML",
prediction = TRUE,
hakn = TRUE)
m6
## Applying GLMM model of Nature authors after correspondence: no sub-group
def2<-metabin(eventexp,
nexp,
eventcontrol,
ncontrol,
studlab=Study,
tau.common=FALSE,
data = df11,
method = "GLMM",
model.glmm = "CM.AL",
sm="OR",
MH.exact = TRUE,
fixed = FALSE,
random = TRUE,
method.tau = "ML",
prediction = TRUE)
def2
## Applying GLMM model of Nature authors after correspondence: sub-group
df3<-df1%>%
select(Study,
eventexp,
nexp,
eventcontrol,
ncontrol,
Outcome,
Design)%>%
filter(Outcome=="Stillbirth")%>%
drop_na()
def3<-metabin(eventexp,
nexp,
eventcontrol,
ncontrol,
studlab=Study,
subgroup=Design,
tau.common=FALSE,
data = df3,
method = "GLMM",
sm="OR",
model.glmm = "CM.AL",
method.tau = "ML",
prediction = TRUE)
def3
def4<-metabin(eventexp,
nexp,
eventcontrol,
ncontrol,
studlab=Study,
subgroup=Design,
tau.common=FALSE,
data = df3,
method = "GLMM",
sm="OR",
model.glmm = "CM.AL",
method.tau = "ML",
hakn = TRUE,
prediction = TRUE)
def4
## Applying GLMM model of Nature authors on Canada, Uk and Israel
df4<-df1%>%
select(Study,
eventexp,
nexp,
eventcontrol,
ncontrol,
Outcome,
Country)%>%
filter(Outcome=="Stillbirth" &
Study %in% c("BORNOntario, 2021","UKHSA, 2021","Goldshtein, 2021"))%>%
drop_na()
def5<-metabin(eventexp,
nexp,
eventcontrol,
ncontrol,
studlab=Study,
tau.common=FALSE,
data = df4,
method = "GLMM",
model.glmm = "CM.AL",
sm="OR",
method.tau = "ML",
hakn = FALSE,
prediction = TRUE)
def5
def6<-metabin(eventexp,
nexp,
eventcontrol,
ncontrol,
studlab=Study,
tau.common=FALSE,
data = df4,
method = "GLMM",
model.glmm = "CM.AL",
sm="OR",
method.tau = "ML",
hakn = TRUE,
prediction = TRUE)
def6
forest.meta(def6, layout = "RevMan5")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment