검정의 검정력

Python에서 배우는 추론 통계 기초

Paul Savala

Assistant Professor of Mathematics

검정력을 결정하는 요인

표본 크기 효과 크기 유의수준(알파)
대규모 사람들 그룹 이미지. 약을 투여받는 환자 이미지. 95% 신뢰구간 이미지.
Python에서 배우는 추론 통계 기초

체중 감소 데이터 시뮬레이션

from scipy.stats import norm


# 대조군: 평균 0파운드, 표준편차 1파운드
control = norm.rvs(loc=0,
scale=1,
size=100)
# 처치군: 평균 -2파운드, 표준편차 1파운드
treatment = norm.rvs(loc=-2, scale=1, size=100)
Python에서 배우는 추론 통계 기초

t-검정

$H_0$: 체중 감소 차이 없음(오답)

$H_a$: 처치군이 체중 감소(정답)

결론: $H_0$를 기각하고 $H_a$를 채택함(정답).

from scipy.stats import ttest_ind


# t-검정 수행 alpha = 0.05 t_test = ttest_ind(treatment, control, alternative='less')
# 유의성 확인 print(t_test.pvalue < alpha)
TRUE
Python에서 배우는 추론 통계 기초

작은 표본 크기

control = norm.rvs(loc=0, scale=1, size=5)
treatment = norm.rvs(loc=-2, scale=1, size=5)

# t-검정 수행 tt = ttest_ind(treatment, control, alternative='less')
print(tt.pvalue < 0.05)
FALSE

결론: H0 기각 실패(오류)

Python에서 배우는 추론 통계 기초

작은 효과 크기

# 체중 감소 = 0.2파운드, 표본 크기 = 100

treatment = norm.rvs(loc=-0.2, scale=1, size=100)
# t-검정 수행 t_test = ttest_ind(treatment, control, alternative='less')
print(t_test.pvalue < 0.05)
FALSE
Python에서 배우는 추론 통계 기초

효과가 작나요? 표본은 크게!

소수의 사람 옆에 대규모 그룹이 서 있는 모습.

Python에서 배우는 추론 통계 기초

검정력의 정의

유의한 효과가 있으면, 검정이 이를 탐지할까요?

카툰 손 위 세균을 확대경으로 보는 그림.

검정력: 대립가설(Ha)이 참일 때, 주어진 데이터로 영가설(H0)을 기각할 확률은?

표본 수집 전 검정력을 계산하십시오

Python에서 배우는 추론 통계 기초

검정력 계산

from statsmodels.stats import power
# 검정력 함수
tt_power = power.TTestIndPower()


# 검정력 계산 pwr = tt_power.power(effect_size=0.2,
nobs1=100,
alpha=0.05)
print(pwr)
0.291

탐지 확률이 낮습니다!

Python에서 배우는 추론 통계 기초

검정력에 맞춘 해 구하기

nobs1 = TTestIndPower().solve_power(effect_size=-0.2, 
                                    nobs1=None, # Solve for
                                    alpha=0.05,
                                    power=0.8)

print(nobs1)
13735.26
Python에서 배우는 추론 통계 기초

연습해 봅시다!

Python에서 배우는 추론 통계 기초

Preparing Video For Download...