Advance meta analysis in R

Chin Lin

Wednesday, October 1, 2014

前情提要

– 搜索文獻&擷取Paper中需要的資訊

– 在R之內讀取檔案&安裝套件

– 簡單的合併分析&畫出森林圖

– 畫出漏斗圖&檢定它是否對稱

– 非2*2Table的合併

– 次組分析

– Meta-regression

– Trial sequence analysis

– Network meta-analysis

Topic 1 非2*2Table的合併(連續變項)

– 請點這裡下載練習檔案

Topic 1 連續變項的分析

Example1=read.csv("d:/Example1.csv") #讀取檔案後存成Example1物件(資料表格式)
Example1 #看Example1的內容
##           study n.amlo mean.amlo var.amlo n.plac mean.plac var.plac
## 1  Protocol 154     46    0.2316   0.2254     48   -0.0027   0.0007
## 2  Protocol 156     30    0.2811   0.1441     26    0.0270   0.1139
## 3  Protocol 157     75    0.1894   0.1981     72    0.0443   0.4972
## 4 Protocol 162A     12    0.0930   0.1389     12    0.2277   0.0488
## 5  Protocol 163     32    0.1622   0.0961     34    0.0056   0.0955
## 6  Protocol 166     31    0.1837   0.1246     31    0.0943   0.1734
## 7 Protocol 303A     27    0.6612   0.7060     27   -0.0057   0.9891
## 8  Protocol 306     46    0.1366   0.1211     47   -0.0057   0.1291

– 注意裡面的prediction = TRUE,這是在說我希望呈現prediction interval。

Result1 = metacont(n.e = n.amlo, mean.e = mean.amlo, sd.e = sqrt(var.amlo),
n.c = n.plac, mean.c = mean.plac, sd.c = sqrt(var.plac),
data = Example1, studlab = study, prediction = TRUE)
Result1 #看分析結果
##                    MD            95%-CI %W(fixed) %W(random)
## Protocol 154   0.2343 [ 0.0969; 0.3717]     21.22      17.47
## Protocol 156   0.2541 [ 0.0663; 0.4419]     11.35      12.74
## Protocol 157   0.1451 [-0.0464; 0.3366]     10.92      12.45
## Protocol 162A -0.1347 [-0.3798; 0.1104]      6.67       9.04
## Protocol 163   0.1566 [ 0.0072; 0.3060]     17.94      16.21
## Protocol 166   0.0894 [-0.1028; 0.2816]     10.85      12.40
## Protocol 303A  0.6669 [ 0.1758; 1.1580]      1.66       2.90
## Protocol 306   0.1423 [-0.0015; 0.2861]     19.39      16.79
## 
## Number of studies combined: k=8
## 
##                          MD            95%-CI     z  p.value
## Fixed effect model   0.1619 [ 0.0986; 0.2252] 5.013 < 0.0001
## Random effects model 0.1589 [ 0.0710; 0.2467] 3.544   0.0004
## Prediction interval         [-0.0680; 0.3858]               
## 
## Quantifying heterogeneity:
## tau^2 = 0.0066; H = 1.33 [1; 2]; I^2 = 43.2% [0%; 74.9%]
## 
## Test of heterogeneity:
##      Q d.f.  p.value
##  12.33    7   0.0902
## 
## Details on meta-analytical method:
## - Inverse variance method
## - DerSimonian-Laird estimator for tau^2

Topic 1 連續變項的分析(續)

– 森林圖

forest(Result1)

plot of chunk unnamed-chunk-4

– 漏斗圖&漏斗圖的檢定

metabias(Result1,k.min=3)
## 
##  Linear regression test of funnel plot asymmetry
## 
## data:  Result1
## t = 0.3378, df = 6, p-value = 0.747
## alternative hypothesis: asymmetry in funnel plot
## sample estimates:
##    bias se.bias   slope 
##  0.5885  1.7422  0.1104
funnel(Result1)

plot of chunk unnamed-chunk-5

Topic 1 非2*2Table的合併(整合參數)

– 如果你忘了,請點這裡複習一下上禮拜的部份(Page 11 to 14)

– 下面這是轉換的公式

Meta1

Topic 1 整合參數的分析

– 這是上週我們使用的Folic acid的資料,只是現在只留下了RR&他的95% CI

Example2=read.csv("d:/RR_95%CI.csv") #讀取檔案後存成Example2物件(資料表格式)
Example2$logRR=log(Example2$RR) #計算logRR
Example2$SE1=(log(Example2$RR)-log(Example2$lower))/1.96 #使用下界計算SE
Example2$SE2=(log(Example2$upper)-log(Example2$RR))/1.96 #使用上界計算SE
Result2=metagen(TE=logRR,seTE=SE1,sm="RR",studlab=Study,data=Example2)
Result2 #看看分析結果
forest(Result2)

Meta2 Meta3

練習1

Meta4 Meta5

Topic 2 - 次組分析

– 也許在合併這些文獻之前,我們早就懷疑有些因子可能會影響治療效果了!(注意,按照Cochrane的Guildline,次組分析必須在事前有機轉/流行病學等研究提出合理的懷疑)

– 不要忘記怎麼讀檔&分析,我們使用上週的程式碼

Folic=read.csv("d:/Folic acid.csv")
Folic
Result=metabin(event.e = ev.trt, n.e = n.trt, event.c = ev.ctrl, n.c =  n.ctrl, studlab = name,
data = Folic, sm = "RR", method.tau="DL")
Result
Result1=metabin(event.e = ev.trt, n.e = n.trt, event.c = ev.ctrl, n.c =  n.ctrl, studlab = name,
data = Folic, sm = "RR", method.tau="DL", byvar=food)
Result1
forest(Result1, bylab="Food fortification")

Meta6

Topic 2 - 次組分析(續)

Folic$pubyear[Folic$year<=2007]="Early than 2007"
Folic$pubyear[Folic$year>=2008]="Later than 2008"
Result2=metabin(event.e = ev.trt, n.e = n.trt, event.c = ev.ctrl, n.c =  n.ctrl, studlab = name,
data = Folic, sm = "RR", method.tau="DL", byvar=pubyear)
forest(Result2, bylab="Year of publish")

Meta7

練習2

– 你可以在Excel裡面修改你的原始檔,增加新變數後重新讀檔進R,之後再進行分析。

Meta8

Topic 3 - Meta-regression

– Meta-regression基本上就是次組分析的延伸,而且它能夠容許同時存在兩個以上的因子。

Meta9

Meta8

– 因此,若我們將DM = < 30%做為參考組,那我們的交互作用項理論上應該要是0.99/0.89=1.11 (以Fixed model為例)

– 當然,在Meta-regression中是log尺度的,所以實際上的數字應該是log(1.11)=0.11

Topic 3 - Meta-regression(續)

library(metafor) #載入metafor套件,若尚未安裝則需先安裝
Folic$DM=c(0,1,0,0,1,0,0,1,0,0,1,1,1)
res1=rma(ai = ev.trt, ci = ev.ctrl, n1i = n.trt, n2i = n.ctrl, mods=~DM, data=Folic, method="FE",measure="RR")
res1

Meta10

– 當DM=0(也就是DM盛行率<30%)時,合併的結果為exp(-0.1173)=0.889

– 當DM=1(也就是DM盛行率>30%)時,合併的結果為exp(-0.1173+0.1092)=0.992

– DM的調節效果(或稱交互作用效果)為exp(0.1092)=1.115

Topic 3 - 更複雜的例子

– 另外,這次我們用Mixed effects model:

library(metafor) #載入metafor套件,若尚未安裝則需先安裝
Folic$DMr=c(0.136,0.455,0.193,0.232,0.55,0,0.226,0.4,0.11,0.24,0.4,1,0.405) #產生一個連續變項
res2=rma(ai = ev.trt, ci = ev.ctrl, n1i = n.trt, n2i = n.ctrl, mods=~DMr+factor(food), data=Folic, method="DL",measure="RR")
res2
##Mixed-Effects Model (k = 13; tau^2 estimator: DL)
##
##tau^2 (estimated amount of residual heterogeneity):     0 (SE = 0.0079)
##tau (square root of estimated tau^2 value):             0
##I^2 (residual heterogeneity / unaccounted variability): 0.00%
##H^2 (unaccounted variability / sampling variability):   1.00
##R^2 (amount of heterogeneity accounted for):            100.00%
##
##Test for Residual Heterogeneity: 
##QE(df = 9) = 8.7522, p-val = 0.4605
##
##Test of Moderators (coefficient(s) 2,3,4): 
##QM(df = 3) = 4.3740, p-val = 0.2238
##
##Model Results:
##
##                                 se     zval    pval    ci.lb    ci.ub   
##intrcpt             -0.1621  0.0763  -2.1251  0.0336  -0.3117  -0.0126  *
##DMr                  0.4535  0.3464   1.3091  0.1905  -0.2255   1.1326   
##factor(food)partly  -0.0830  0.1370  -0.6056  0.5448  -0.3515   0.1856   
##factor(food)yes     -0.0728  0.1488  -0.4889  0.6249  -0.3644   0.2189   
##
##---
##Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Meta13

練習3

– 將dose(葉酸劑量)分為5mg/day以下&以上

– 將hcy(介入組血液中HCY的下降率)分為-20%以上&以下

– dose < 5mg/day 和 hcy > -20% 之研究的合併RR

– dose > 5mg/day 和 hcy > -20% 之研究的合併RR

– dose < 5mg/day 和 hcy < -20% 之研究的合併RR

– dose > 5mg/day 和 hcy < -20% 之研究的合併RR

– 如果你很快的做完了,試著想一下Ecological fallacy,他是否會發生在meta-analysis之中?

小結

– metabin(), metacont(), metagen()

– forest(), funnel(), metabias()

– rma()

Cochrane Handbook for Systematic Reviews)

meta package說明

metafor package說明