Chi Square for Large Contingency Table

2022. 4. 25. 22:00·.../Math
728x90
728x90

Categorical data가 여러 class를 갖는 경우에 대한 예제.

Darley와 Latané 의 실험 에 대한 $\chi^2$-Test.

  • 생명에 위협을 받는 등의 도움이 필요한 순간에
  • 도움을 주는 행위 여부 : 실험의 경우 sought help로 119등에 도움을 요청하는 행위를 하는지 여부임.
  • 방관자(bystander)의 수 : 실험에서 피험자가 현재 도움을 줘야하는 순간에 같이 있다고 인식한 사람 수.
  • 위 두 변수가 독립인지 여부를 확인.

해당 실험의 contingency table(유관표)은 다음과 같음.

  sought help :
yes
souhgt helf :
no
bystander = 0 11 2
bystander = 1 16 10
bystander = 4 4 9

 

import numpy as np
import scipy.stats as stats
import pandas as pd
import matplotlib.pyplot as plt
from IPython.display import Math, HTML

def report(chi2, p_value, dof, expected, idx=None, col=None):
  display(r'$\chi^2$ :'+ str(chi2))
  print('p-value :', p_value)
  print('dof :', dof)
  display(pd.DataFrame(data=expected, index=idx, columns=col))

num_bystanders = [0,1,4]
sought_assistance = ['Yes','No']

data = np.array([
                 [11,2],
                 [16,10],
                 [4,9]
])
df = pd.DataFrame(
    data = data,
    index = num_bystanders,
    columns = sought_assistance
)

display(df)

report(*stats.chi2_contingency(df),num_bystanders,sought_assistance)

결과는 $p$-value가 0.019로 도움을 주는 행위 여부와 방관자의 수가 독립이라는 null hypothesis를 고수하기 어렵다는 결론으로 이어진다.

  • 나온 testing statistics는 $\chi^2=7.91$이고 $\text{dof}=2$임.
  • null hypothesis가 참이라는 가정하에 위와 같은 빈도의 contingency table을 얻을 확률이 1.9% 라는 애기임.

참고로 독립일 경우의 예측되는 contingency table(유관표)은 다음과 같음.

  sought help :
yes
souhgt helf :
no
bystander = 0 7.75 5.25
bystander = 1 15.50 10.50
bystander = 4 7.75 5.25

Reference

Fundamental Statistics for the Behavioral Sciences 8th Edition, Ch19.4

'... > Math' 카테고리의 다른 글

Chi Square : Independence Test (Analysis of Contingency Table)  (0) 2022.04.25
Chi Square Test : Goodness of fit test  (0) 2022.04.25
[Math] The Law of Large Numbers (or The weak law of large numbers)  (0) 2022.04.21
[Math] Definition of Vector Space and Sub-Space  (0) 2022.04.05
[Statistics] Central Limit Theorem  (0) 2022.03.31
'.../Math' 카테고리의 다른 글
  • Chi Square : Independence Test (Analysis of Contingency Table)
  • Chi Square Test : Goodness of fit test
  • [Math] The Law of Large Numbers (or The weak law of large numbers)
  • [Math] Definition of Vector Space and Sub-Space
dsaint31x
dsaint31x
    반응형
    250x250
  • dsaint31x
    Dsaint31's blog
    dsaint31x
  • 전체
    오늘
    어제
    • 분류 전체보기 (748)
      • Private Life (13)
      • Programming (194)
        • DIP (112)
        • ML (26)
      • Computer (119)
        • CE (53)
        • ETC (33)
        • CUDA (3)
        • Blog, Markdown, Latex (4)
        • Linux (9)
      • ... (351)
        • Signals and Systems (103)
        • Math (172)
        • Linear Algebra (33)
        • Physics (42)
        • 인성세미나 (1)
      • 정리필요. (54)
        • 의료기기의 이해 (6)
        • PET, MRI and so on. (1)
        • PET Study 2009 (1)
        • 방사선 장해방호 (4)
        • 방사선 생물학 (3)
        • 방사선 계측 (9)
        • 기타 방사능관련 (3)
        • 고시 (9)
        • 정리 (18)
      • RI (0)
      • 원자력,방사능 관련법 (2)
  • 블로그 메뉴

    • Math
    • Programming
    • SS
    • DIP
  • 링크

    • Convex Optimization For All
  • 공지사항

    • Test
    • PET Study 2009
    • 기타 방사능관련.
  • 인기 글

  • 태그

    인허가제도
    Vector
    signals_and_systems
    Convolution
    Probability
    math
    DIP
    function
    SS
    Term
    cv2
    linear algebra
    fourier transform
    Optimization
    signal_and_system
    Programming
    Python
    opencv
    numpy
    SIGNAL
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
dsaint31x
Chi Square for Large Contingency Table
상단으로

티스토리툴바