유의수준을 보정하여 FWER을 0.05로 고정시킴
피셔의 LSD는 실제로 보정을 하지 않는 방법이므로 쓰지 않는다. 셰페의 방법은 반대로 지나치게 보수적이어서 잘 쓰지 않는다. 여기서는 널리 쓰이는 봉페로니 교정과 투키의 HSD를 소개한다.
예제 데이터를 연다:
import pandas as pd
df = pd.read_csv('PlantGrowth.csv')
사후분석을 위한 준비를 한다:
from statsmodels.sandbox.stats.multicomp import MultiComparison
import scipy.stats
comp = MultiComparison(df.weight, df.group)
result = comp.allpairtest(scipy.stats.ttest_ind, method='bonf')
result[0]
group1 | group2 | stat | pval | pval_corr | reject |
---|---|---|---|---|---|
ctrl | trt1 | 1.1913 | 0.249 | 0.7471 | False |
ctrl | trt2 | -2.134 | 0.0469 | 0.1406 | False |
trt1 | trt2 | -3.0101 | 0.0075 | 0.0226 | True |
trt1
수준과 trt2
수준 간의 평균 차이만 유의미함 (p < 0.05)
from statsmodels.stats.multicomp import pairwise_tukeyhsd
hsd = pairwise_tukeyhsd(df['weight'], df['group'], alpha=0.05)
hsd.summary()
group1 | group2 | meandiff | p-adj | lower | upper | reject |
---|---|---|---|---|---|---|
ctrl | trt1 | -0.371 | 0.3921 | -1.0621 | 0.3201 | False |
ctrl | trt2 | 0.494 | 0.198 | -0.1971 | 1.1851 | False |
trt1 | trt2 | 0.865 | 0.012 | 0.1739 | 1.5561 | True |
trt1
수준과 trt2
수준 간의 평균 차이만 유의미함 (p < 0.05)