Skip to content
Permalink
main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
## Meta_final_code
## by Pu
## 2024May2
library(metafor)
library(readxl)
metafin<-read_xlsx('C:/Users/cp/Desktop/Meta Analysis/Dataset_Pu.xlsx')
## z adjustment
metafin<-escalc("ZCOR",ri=ri, ni=ni,data=metafin,var.names = c('yzi','vzi'))
## zero effect size
randem_zero<- rma(yzi,vzi, data= metafin, slab = author)
randem_zero
predict(randem_zero, digits=3, transf = transf.ztor)
confint(randem_zero)
## funnel plot
funnel(randem_zero)
## forest plot
forest(randem_zero, xlim = c(-1.2,1.2),atransf=transf.ztor,
digits = c(2,1),
cex=.6)
text(-1.2,24,"Authors(year)",pos=4, cex=1)
text(1.2,24,'r[95% CI]',pos=2,cex=1)
## small study effect test
regtest(randem_zero)
## influential case test
inf<- influence(randem_zero)
print(inf)
plot(inf)
## contour funnel plot
metafor::funnel(randem_zero, level=c(90, 95, 99), shade=c("white", "gray55", "gray75"), refline=0,
xlab= "r",legend=TRUE)
## number of authors
summary(metafin$nauthor)
sd(metafin$nauthor)
metafin$nau4<-0
metafin$nau4[metafin$nauthor>=4]<-1
table(metafin$nau4)
randem_nau4<- rma(yzi,vzi, mods= ~nau4,data= metafin, slab = author)
randem_nau4
## moving constant
metafin$invernau4<-1-metafin$nau4
randem_invernau4<- rma(yzi,vzi, mods= ~invernau4,data= metafin, slab = author)
randem_invernau4
## cite
summary(metafin$cite)
sd(metafin$cite)
randem_cite<-rma(yzi,vzi, mods= ~cite,data= metafin, slab = author)
randem_cite
## survey length
summary(metafin$days)
sd(metafin$days,na.rm=TRUE)
randem_days<-rma(yzi,vzi, mods= ~days,data= metafin, slab = author)
randem_days
metafin$tw<-NA
metafin$tw[metafin$days>=14]<-1
metafin$tw[metafin$days<14& metafin$days>0]<-0
summary(metafin$tw)
## interpolation
metafin$twitpl<-1
metafin$twitpl[metafin$days<14& metafin$days>0]<-0
randem_tw<-rma(yzi,vzi, mods= ~tw,data= metafin, slab = author)
randem_tw
randem_twitpl<-rma(yzi,vzi, mods= ~twitpl,data= metafin, slab = author)
randem_twitpl
## moving constant
metafin$invertwitpl<-1-metafin$twitpl
randem_invertwitpl<-rma(yzi,vzi, mods= ~invertwitpl,data= metafin, slab = author)
randem_invertwitpl
## nationwide
metafin$nw<-0
metafin$nw[metafin$scale=="nationwide"]<-1
summary(metafin$nw)
sd(metafin$nw)
randem_nw<-rma(yzi,vzi, mods= ~nw,data= metafin, slab = author)
randem_nw
## quota
metafin$quota<-0
metafin$quota[metafin$sampling=="online quota"]<-1
summary(metafin$quota)
sd(metafin$quota)
randem_quota<-rma(yzi,vzi, mods= ~quota,data= metafin, slab = author)
randem_quota
## average age
metafin$age40<-0
metafin$age40[metafin$aveage<40]<-1
summary(metafin$aveage)
sd(metafin$aveage)
randem_age<- rma(yzi,vzi, mods= ~aveage,data= metafin, slab = author)
randem_age
randem_age40<- rma(yzi,vzi, mods= ~age40,data= metafin, slab = author)
randem_age40
## female percent
summary(metafin$femper)
sd(metafin$femper)
randem_femper<- rma(yzi,vzi, mods= ~femper,data= metafin, slab = author)
randem_femper
## average education
summary(metafin$aveedu)
sd(metafin$aveedu,na.rm=TRUE)
randem_edu<- rma(yzi,vzi, mods= ~aveedu,data= metafin, slab = author)
randem_edu
## EU/US nation
table(metafin$nation)
metafin$euus<-0
metafin$euus[metafin$nation=='Finland'|metafin$nation=='France'|metafin$nation=='UK'|
metafin$nation=='Czech'|metafin$nation=='Poland'|metafin$nation=='US'|metafin$nation=='Italy'
|metafin$nation=='Serbia'|metafin$nation=='Slovakia']<-1
randem_euus<-rma(yzi,vzi, mods= ~euus,data= metafin, slab = author)
randem_euus
## moving constant
metafin$inveuus<-1-metafin$euus
randem_euus<-rma(yzi,vzi, mods= ~inveuus,data= metafin, slab = author)
randem_euus
## number of controls
summary(metafin$ncontrol)
sd(metafin$ncontrol)
randem_ncon<-rma(yzi,vzi, mods= ~ncontrol,data= metafin, slab = author)
randem_ncon
## make plots
predncon<-predict(randem_ncon, newmods = seq(0,30,1))
ncons<- 1/sqrt(metafin$vzi)
nconsize<- (ncons-min(ncons)/(max(ncons)-min(ncons)))/30
plot(metafin$ncontrol,metafin$yzi,xlab = 'Numbers of Controls',
ylab = "Correlation Coefficient (R)",xlim = c(0,30),ylim=c(0,0.8),cex=nconsize)
lines(seq(0,30,1), predncon$pred, col = "navy")
lines(seq(0,30,1), predncon$ci.lb, lty = "dashed", col=" blue")
lines(seq(0,30,1), predncon$ci.ub, lty = "dashed", col=" blue")
abline(h=0,col='red')
## months since 2020.1
metafin$monnumber<-metafin$month+(metafin$year-2020)*12
summary(metafin$monnumber)
sd(metafin$monnumber,na.rm = TRUE)
## interpolation
metafin$monnumberitpl<-metafin$monnumber
metafin$monnumberitpl[which(is.na(metafin$monnumberitpl))]<-8.579
summary(metafin$monnumberitpl)
randem_mon<-rma(yzi,vzi, mods= ~monnumber,data= metafin, slab = author)
randem_mon
randem_monitpl<-rma(yzi,vzi, mods= ~monnumberitpl,data= metafin, slab = author)
randem_monitpl
## plot
prednmonitpl<-predict(randem_monitpl, newmods = seq(0,20,1))
ncons<- 1/sqrt(metafin$vzi)
nconsize<- (ncons-min(ncons)/(max(ncons)-min(ncons)))/30
plot(metafin$monnumber,metafin$yzi,xlab = 'Numbers of Month Since 2020 Jan.',
ylab = "Correlation Coefficient (R)",xlim = c(0,20),ylim=c(0,0.8),cex=nconsize)
lines(seq(0,20,1), prednmonitpl$pred, col = "navy")
lines(seq(0,20,1), prednmonitpl$ci.lb, lty = "dashed", col=" blue")
lines(seq(0,20,1), prednmonitpl$ci.ub, lty = "dashed", col=" blue")
abline(h=0,col='red')
## type of conspiracy
table(metafin$xcontent)
metafin$xcontb<-factor(metafin$xcontent,
levels = c('Political interests','vaccine','mixed','Bioweapon/man made','Hidden truth','hoax'))
randem_xcontb<-rma(yzi,vzi, mods= ~xcontb,data= metafin, slab = author)
randem_xcontb
predxcontp<-predict(randem_xcontb, newmods = c(0,0,0,0,0))
predxcontp$pred
predxcontp$ci.lb
predxcontp$ci.ub
predxcontv<-predict(randem_xcontb, newmods = c(1,0,0,0,0))
predxcontv$pred
predxcontv$ci.lb
predxcontv$ci.ub
predxcontm<-predict(randem_xcontb, newmods = c(0,1,0,0,0))
predxcontm$pred
predxcontm$ci.lb
predxcontm$ci.ub
predxcontb<-predict(randem_xcontb, newmods = c(0,0,1,0,0))
predxcontb$pred
predxcontb$ci.lb
predxcontb$ci.ub
predxcontht<-predict(randem_xcontb, newmods = c(0,0,0,1,0))
predxcontht$pred
predxcontht$ci.lb
predxcontht$ci.ub
predxcontho<-predict(randem_xcontb, newmods = c(0,0,0,0,1))
predxcontho$pred
predxcontho$ci.lb
predxcontho$ci.ub
table(metafin$xcontent)
metafin$xcontnum<-0
metafin$xcontnum[metafin$xcontent=='Political interests']<-1
metafin$xcontnum[metafin$xcontent=='vaccine']<-2
metafin$xcontnum[metafin$xcontent=='mixed']<-3
metafin$xcontnum[metafin$xcontent=='Bioweapon/man made']<-4
metafin$xcontnum[metafin$xcontent=='Hidden truth']<-5
metafin$xcontnum[metafin$xcontent=='hoax']<-6
## plot
plot(metafin$xcontnum,metafin$yzi,xlab = 'Type of Conspiracy',
ylab = "Correlation Coefficient (R)",ylim=c(-0.3,1.1),cex=nconsize)
legend('topleft',cex=0.8,
c('1=Political interests','2=Vaccine','3=Mixed','4=Bioweapon/man made','5=Hidden truth','6=Hoax'))
lines(c(1,1,1),c(predxcontp$ci.lb,predxcontp$pred,predxcontp$ci.ub),lty=2,col='grey')
lines(c(2,2,2),c(predxcontv$ci.lb,predxcontv$pred,predxcontv$ci.ub),lty=2,col='grey')
lines(c(3,3,3),c(predxcontm$ci.lb,predxcontm$pred,predxcontm$ci.ub),lty=2,col='grey')
lines(c(4,4,4),c(predxcontb$ci.lb,predxcontb$pred,predxcontb$ci.ub),lty=2,col='grey')
lines(c(5,5,5),c(predxcontht$ci.lb,predxcontht$pred,predxcontht$ci.ub),lty=2,col='grey')
lines(c(6,6,6),c(predxcontho$ci.lb,predxcontho$pred,predxcontho$ci.ub),lty=2,col='grey')
points(1,predxcontp$pred,pch=1,lwd=5,col='grey')
points(2,predxcontv$pred,pch=1,lwd=5,col='grey')
points(3,predxcontm$pred,pch=1,lwd=5,col='grey')
points(4,predxcontb$pred,pch=1,lwd=5,col='grey')
points(5,predxcontht$pred,pch=1,lwd=5,col='grey')
points(6,predxcontho$pred,pch=1,lwd=5,col='grey')
abline(h=0,col='red')