效应大小

meta
Published

October 24, 2024

Modified

November 10, 2024

Doing Meta-Analysis in R: A Hands-on Guide

效应大小(effect sizes)+标准误

观察性研究

算术均值

\[ \bar x =\frac{\sum_{i=1}^n x_i}{n} \]

\[ SE_{\bar x} = \frac{s}{\sqrt{n}} \]

Show the code
set.seed(123)
sample <- rnorm(n = 50, mean = 20, sd = 5)
mean(sample)
[1] 20.17202
Show the code
sd(sample)/sqrt(50)
[1] 0.6546889

要对均值进行荟萃分析,我们的数据集至少应包含以下列:

  • n 研究中观测值的数量 (样本量)。

  • mean 研究中报告的平均值。

  • sd 研究中报告的变量的标准差。

比例

\[ p=\frac{k}{n} \]

\[ SE_{p} = \sqrt{\frac{p(1-p)}{n}} \]

Show the code
k <- 25
n <- 125

p <- k/n
p
[1] 0.2
Show the code
sqrt((p*(1-p))/n)
[1] 0.03577709

logit 转换确保采样分布大致正态

\[ p_{\text{logit}} = \log_{e} \left(\frac{p}{1-p}\right) \]

\[ SE_{p_{\text{logit}}} = \sqrt{\frac{1}{np}+\frac{1}{n(1-p)}} \]

R 中使用的元分析函数会自动执行这种 logit 转换

我们的数据集至少应包含以下列:

  • n 研究中的总样本量。

  • k 研究中指定亚组的样本量。

相关性

Pearson Product-Moment Correlation

两个连续变量

\[ r_{xy} = \frac{\sigma^{2}_{xy}}{\sigma_x \sigma_y} \]

\[ SE_{r_{xy}} = \frac{1-r_{xy}^2}{\sqrt{n-2}} \]

  • r≈0.10:效果小。

  • r≈0.30:中等效果。

  • r≈0.50:大效果。

在元分析中,相关性通常转化为 Fisher’s z

\[ z = 0.5\log_{e}\left(\frac{1+r}{1-r}\right) \]

\[ SE_{z} = \frac{1}{\sqrt{n-3}} \]

Show the code
set.seed(12345)
x <- rnorm(20, 50, 10)
y <- rnorm(20, 10, 3)

r <- cor(x,y)
r
[1] 0.2840509
Show the code
z <- 0.5*log((1+r)/(1-r))
z
[1] 0.2920831

R 中对相关性进行荟萃分析时手动转换。我们在数据集中唯一需要的列是:

  • COR 研究的(未转换的)相关系数。

  • n. 研究的样本量。

Point-Biserial Correlation

y是连续变量,x是二分类变量

\[ {r_{pb}}= \frac{(\bar{y_1}-\bar{y_2})\sqrt{p_1(1-p_1)}}{s_y} \]

实验性研究

(Standardized) Mean Differences

组间均值差值

\[ \text{MD}_{\text{between}} = \bar{x}_1 - \bar{x}_2 \]

\[ SE_{\text{MD}_{\text{between}}} = s_{\text{pooled}}\sqrt{\frac{1}{n_1}+\frac{1}{n_2}} \]

其中,\(s_{pooled}\) 表示两组的合并标准差

\[ s_{\text{pooled}} = \sqrt{\frac{(n_1-1)s^2_1+(n_2-1)s^2_2}{(n_1-1)+(n_2-1)}} \]

Show the code
set.seed(123)
x1 <- rnorm(n = 20, mean = 10, sd = 3)
x2 <- rnorm(n = 20, mean = 15, sd = 3)

s1 <- sd(x1)
s2 <- sd(x2)
n1 <- 20
n2 <- 20
Show the code
# Calculate the mean difference
MD <- mean(x1) - mean(x2)
MD
[1] -4.421357
Show the code
# Calculate s_pooled
s_pooled <- sqrt(
  (((n1-1)*s1^2) + ((n2-1)*s2^2))/
    ((n1-1)+(n2-1))
)

# Calculate the standard error
se <- s_pooled*sqrt((1/n1)+(1/n2))
se
[1] 0.8577262

对于均差的荟萃分析,我们只需要在数据集中准备以下列:

  • n.e. 干预/实验组中的观察值数量。

  • mean.e. 干预/实验组的平均值。

  • sd.e. 干预/实验组的标准差。

  • n.c. 对照组中的观测值个数。

  • mean.c. 对照组的均值。

  • sd.c. 控制组中的标准差。

组间标准化均值差值

在文献中,标准化均值差也通常称为 Cohen's d

\[ \text{SMD}_{\text{between}} = \frac{\bar{x}_1 - \bar{x}_2}{s_{\text{pooled}}} \]

通常使用 Cohen (1988) 的约定进行解释:

  • SMD ≈ 0.20: small effect.

  • SMD ≈ 0.50: moderate effect.

  • SMD ≈ 0.80: large effect.

\[ SE_{\text{SMD}_{\text{between}}} = \sqrt{\frac{n_1+n_2}{n_1n_2} + \frac{\text{SMD}^2_{\text{between}}}{2(n_1+n_2)}} \]

Show the code
library(esc)

# This is just some example data that we made up
grp1m <- 50   # mean of group 1
grp2m <- 60   # mean of group 2
grp1sd <- 10  # sd of group 1
grp2sd <- 10  # sd of group 2
grp1n <- 100  # n of group1
grp2n <- 100  # n of group2

# Calculate effect size
esc_mean_sd(grp1m = grp1m, grp2m = grp2m, 
            grp1sd = grp1sd, grp2sd = grp2sd, 
            grp1n = grp1n, grp2n = grp2n)

Effect Size Calculation for Meta Analysis

     Conversion: mean and sd to effect size d
    Effect Size:  -1.0000
 Standard Error:   0.1500
       Variance:   0.0225
       Lower CI:  -1.2940
       Upper CI:  -0.7060
         Weight:  44.4444

小样本校正,Hedges’g

要对标准化均数差进行荟萃分析,我们的数据集至少应包含以下列:

  • n.e. 干预/实验组中的观察值数量。

  • mean.e. 干预/实验组的平均值。

  • sd.e. 干预/实验组的标准差。

  • n.c. 对照组中的观测值个数。

  • mean.c. 对照组的均值。

  • sd.c. 控制组中的标准差。

组内(标准化)均值差值

当在两个不同的时间点(例如,干预前和干预后)测量同一组人时,通常会出现这种情况。

\[ \text{MD}_{\text{within}} = \bar{x}_{\text{t}_2} - \bar{x}_{\text{t}_1} \]

(对数)风险比

Event No Event
Treatment a b n treatntreat
Control c d n control
n E n¬E

\[ {p_{E}}_{\text{treat}} = \frac{a}{a+b} = \frac{a}{n_{\text{treat}}} \]

\[ {p_{E}}_{\text{control}} = \frac{c}{c+d} = \frac{c}{n_{\text{control}}} \]

\[ \text{RR} = \frac{{p_{E}}_{\text{treat}}}{{p_{E}}_{\text{control}}} \]

Show the code
# Define data
a <- 46         # events in the treatment group
c <- 77         # events in the control group
n_treat <- 248  # sample size treatment group
n_contr <- 251  # sample size control group

# Calculate the risks
p_treat <- a/n_treat
p_contr <- c/n_contr

# Calculate the risk ratio
rr <- p_treat/p_contr
rr
[1] 0.6046292

log-risk ratio

\[ \log \text{RR} = \log_{e}(\text{RR}) \]

\[ SE_{\log \text{RR}} = \sqrt{\frac{1}{a}+\frac{1}{c} - \frac{1}{a+b} - \frac{1}{c+d}} \]

Show the code
# Calculate the log-risk ratio and its standard error
log_rr <- log(rr)
log_rr
[1] -0.5031398
Show the code
se_log_rr <- sqrt((1/a) + (1/c) - (1/n_treat) - (1/n_contr))
se_log_rr
[1] 0.1634314

continuity correction

treatment arm continuity correction

(fixed-effect) Mantel-Haenszel method

我们的数据集中应包含以下列:

  • event.e. 处理组或实验组中的事件数。

  • n.e. 处理组或实验组的样本量。

  • event.c. 控制组中的事件数。

  • n.c. 对照组的样本量。

比值比

\[ \text{OR} = \frac{a/b}{c/d} \]

\[ \log \text{OR} = \log_{e}(\text{OR}) \]

\[ SE_{\log \text{OR}} = \sqrt{\frac{1}{a}+\frac{1}{b}+\frac{1}{c}+\frac{1}{d}} \]

Show the code
library(esc)

# Define data
grp1yes <- 45  # events in the treatment group
grp1no <- 98   # non-events in the treatment group
grp2yes <- 67  # events in the control group
grp2no <- 76   # non-events in the control group

# Calculate OR by setting es.type to "or"
esc_2x2(grp1yes = grp1yes, grp1no = grp1no,
        grp2yes = grp2yes, grp2no = grp2no,
        es.type = "or")

Effect Size Calculation for Meta Analysis

     Conversion: 2x2 table (OR) coefficient to effect size odds ratio
    Effect Size:   0.5209
 Standard Error:   0.2460
       Variance:   0.0605
       Lower CI:   0.3216
       Upper CI:   0.8435
         Weight:  16.5263

\[ \text{RR} = \frac{\text{OR}}{\left(1-\dfrac{c}{n_{\text{control}}}\right)+ \left(\dfrac{c}{n_{\text{control}}}\times \text{OR} \right)} \]

为了对 R 中的比值比进行荟萃分析,我们的数据集中应包括以下列:

  • event.e. 处理组或实验组中的事件数。

  • n.e. 处理组或实验组的样本量。

  • event.c. 控制组中的事件数。

  • n.c. 对照组的样本量。

发病率比 Incidence Rate Ratios

校正

小样本偏倚

Hedges’g

\[ g = \text{SMD} \times (1-\frac{3}{4n-9}) \]

Show the code
# Load esc package
library(esc)

# Define uncorrected SMD and sample size n
SMD <- 0.5
n <- 30

# Convert to Hedges g
g <- hedges_g(SMD, n)
g
[1] 0.4864865

不可靠

reliability coefficient rxx test-retest-reliability

Hunter 和 Schmidt 方法 attenuation

计算相关性的校正版本

\[ {r_{xy}}_{c} = \frac{r_{xy}}{\sqrt{r_{xx}}} \]

\[ {r_{xy}}_{c} = \frac{r_{xy}}{\sqrt{r_{xx}}\sqrt{r_{yy}}} \]

当结果x在两组中观察到

\[ \text{SMD}_c = \frac{\text{SMD}}{\sqrt{r_{xx}}} \]

标准误的校正

\[ SE_c = \frac{SE}{\sqrt{r_{xx}}} \]

\[ SE_c = \frac{SE}{\sqrt{r_{xx}}\sqrt{r_{yy}}} \]

Show the code
# Define uncorrected correlation and SMD with their standard error
r_xy <- 0.34
se_r_xy <- 0.09
smd <- 0.65
se_smd <- 0.18

# Define reliabilities of x and y
r_xx <- 0.8
r_yy <- 0.7

# Correct SMD for unreliability in x
smd_c <- smd/sqrt(r_xx)
smd_c
[1] 0.7267221
Show the code
se_c <- se_smd/sqrt(r_xx)
se_c
[1] 0.2012461
Show the code
# Correct correlation for unreliability in x and y
r_xy_c <- r_xy/(sqrt(r_xx)*sqrt(r_yy))
r_xy_c
[1] 0.4543441
Show the code
se_c <- se_r_xy/(sqrt(r_xx)*sqrt(r_yy))
se_c
[1] 0.1202676

范围限制

\[ U = \frac{s_{\text{unrestricted}}}{s_{\text{restricted}}} \]

\[ {r_{xy}}_c = \frac{U\times r_{xy}}{\sqrt{(U^2-1)r_{xy}^2+1}} \]

\[ \text{SMD}_c = \frac{U\times \text{SMD}}{\sqrt{(U^2-1)\text{SMD}^2+1}} \]

\[ SE_{{r_{xy}}_c} = \frac{{r_{xy}}_c}{r_{xy}}SE_{r_{xy}} \]

\[ SE_{{\text{SMD}}_c} = \frac{{\text{SMD}}_c}{\text{SMD}}SE_{\text{SMD}} \]

Show the code
# Define correlation to correct
r_xy <- 0.34
se_r_xy <- 0.09

# Define restricted and unrestricted SD
sd_restricted <- 11
sd_unrestricted <- 18

# Calculate U
U <- sd_unrestricted/sd_restricted

# Correct the correlation
r_xy_c <- (U*r_xy)/sqrt((U^2-1)*r_xy^2+1)
r_xy_c
[1] 0.5091754
Show the code
# Correct the standard error
se_r_xy_c <- (r_xy_c/r_xy)*se_r_xy
se_r_xy_c
[1] 0.1347817