You are on page 1of 29

TIN HỌC THỐNG KÊ

PHÂN TÍCH DỮ LIỆU THỐNG KÊ BẰNG SPSS

HYPOTHESIS TESTING
/haɪˈpɑː.θə.sɪs ˈtes.tɪŋ/

PEARSON'S CHI-SQUARE TEST FOR INDEPENDENCE

AN INTERNATIONAL STANDARD UNIVERSITY


NỘI DUNG

1
Sample vs. Population

Nhu cầu kiểm định

3
Kiểm
4
định Chi-Square
Sample vs. Population

https://towardsdatascience.com/what-is-the-difference-between-population-and-
sample-e13d17746b16
Sample vs. Population

http://sphweb.bumc.bu.edu/otlt/MPH-
Modules/BS/BS704_BiostatisticsBasics/BS704_BiostatisticsBasics2.html
NHU CẦU KIỂM ĐỊNH
• Khi nghiên cứu, chúng ta thường chọn tập mẫu để khảo sát.
• Với kết quả thu thập được chúng ta tính toán các thông số của từng biến.
• Câu hỏi đặt ra là: Liệu kết quả thu được là do sự lựa chọn ngẫu nhiên hay có
mối liên hệ gì giữa các biến hay không?
• Ví dụ: Which holiday do you prefer?
Gender Beach Cruise
Men 209 280
Women 225 248

Does Gender affect Preferred Holiday?

• Nếu Gender có ảnh hưởng đến lựa chọn loại hình du lịch, ta nói chúng phụ
thuộc nhau (dependent variables).
NHU CẦU KIỂM ĐỊNH
Gender Beach Cruise
Men 209 280
Women 225 248

p<0.05 thường
Bằng cách nào được dùng để kiểm
đó chúng ta tính định sự độc lập
được p=0.132

Vậy p=0.132>0.05, kết


luận 2 biến độc lập
(không liên quan)
GIÁ TRỊ p
p là xác suất các biến độc lập nhau (independent)​

Is it likely you
would get
such different
results
surveying Men
each time?
Với giá trị p=0.132, ta nói chuyện
đó có thể xảy ra thường xuyên
GIÁ TRỊ p
• Việc chọn mẫu là ngẫu nhiên nên kết quả khảo sát cũng ngẫu nhiên.
• Chắc chắn phải có sai khác đôi chút giữa các lần khảo sát.
• Hầu hết mọi người cho rằng p<0.05 là đủ để kết luận các nhóm có câu trả
lời khác nhau (không phụ thuộc nhau - độc lập nhau).
GIÁ TRỊ p
• Ví dụ: Which pet do you prefer?

Gender Cat Dog


Men 207 282
Women 231 242

• Bằng cách “nào đó” ta tính được p = 0.043


• Do p < 0.05, kết quả cho ta thấy khả năng hai biến không độc lập.
• Nói cách khác, vì 0.043<0.05, chúng ta nghĩ rằng giới tính có liên quan đến
sở thích động vật.
Men and Women have
different preferences
for Cats and Dogs
TẠI SAO CHỌN p<0.05?
• It’s just a choice!
• Sử dụng p < 0.05 là phổ biến, tuy nhiên có thể chọn p<0.01 để tăng độ chắc
chắn.
TÍNH TOÁN GIÁ TRỊ p
• Sử dụng Chi-Square Test.
• Đọc giống như “Hi” nhưng với âm K /ˈkaɪ skweə(r) ˌtest/
• Tiếng Việt có thể đọc là Khi Bình Phương hoặc Ki Bình Phương
• Ký hiệu 𝜒 ℎ𝑜ặ𝑐 𝜒 2
• Chú ý:
• Kiểm định chỉ làm việc trên dữ liệu phân loại (categorical) như giới tính,
màu sắc, độc tuổi.
• Không làm việc trên dữ liệu số như chiều cao, cân nặng.
• Số lượng quan sát phải đủ lớn (hầu hết > 25).
ĐẶT GIẢ THUYẾT
• Bước 1: Xác định giả thuyết - State our hypotheses
• H0: (Null Hypothesis) Gender and preference for cats or dogs
are independent.
• Ha: (Alternate Hypothesis) Gender and preference for cats or dogs
are not independent.

https://luminousmen.com/post/demystifying-hypothesis-testing
CHI-SQUARE TEST

Lay the data out in a table: Cat Dog


Men 207 282

Women 231 242

Cat Dog
Men 207 282 489
Add up rows and columns:
Women 231 242 473

438 524 962


CHI-SQUARE TEST
Calculate "Expected Value" for each entry:

Cat Dog
489×438 489×524
Men 489
962 962
473×438 473×524
Women 473
962 962
438 524 962

Cat Dog
Men 222.64 266.36 489

Women 215.36 257.64 473

438 524 962


CHI-SQUARE TEST
P(A & B) = P(A) x P(B)
Cat Dog P

Men 0.508 x 0.455 0.508 x 0.545 489 0.508

Women 0.492 x 0.455 0.492 x 0.545 473 0.492

438 524 962


P 0.455 0.545 1
x 962
Cat Dog
Men ? ? 489
Women ? ? 473
438 524 962
CHI-SQUARE TEST
Subtract expected from observed, square it, then divide by expected:

Cat Dog Cat Dog


Men 207 282 489 Men 222.64 266.36 489

Women 231 242 473 Women 215.36 257.64 473

438 524 962 438 524 962

Cat Dog Cat Dog

(207−222.64)2 (282−266.36)2 Men 1.099 0.918 489


Men 489
222.64 266.36

(231−215.36)2 (242−257.64)2 Women 1.136 0.949 473


Women 473
215.36 257.64

438 524 962 438 524 962


CHI-SQUARE TEST

Cat Dog

Men 1.099 0.918 489

Women 1.136 0.949 473

438 524 962

Now add up those calculated values:


1.099 + 0.918 + 1.136 + 0.949 = 4.102

Chi-Square is 4.102
CHI-SQUARE TEST
Degree of Freedom = (rows − 1) × (columns − 1)

For our example we have 2 rows and 2 columns:


DF = (2 − 1)(2 − 1) = 1×1 = 1

Chi-Square is 4.102 > 3.841. => Reject H0

OR:
p value is 0.04283

In this case p < 0.05, so this result is thought of as being "significant" meaning
we think the variables are not independent.

https://www.mathsisfun.com/data/chi-square-calculator.html
BÀI TẬP
500 students in Grade 8 were asked, "Which do you like best - Pop music or
Rock music?"
The results were:

Calculate the value of 𝜒 2 correct to 1 decimal place.


A. 5.2
B. 5.4
C. 5.6.
D. 5.8.
BÀI TẬP
A sample of boys and girls were asked to choose one color from three options -
blue, green and yellow - to paint their room, with the following results:

Which one of the following is true?

A. The result is significant and gender does affect the choice of color.
B. The result is significant and gender does not affect the choice of color.
C. The result is not significant and gender does affect the choice of color.
D. The result is not significant and gender does not affect the choice of color.
BÀI TẬP
A sample of people of different ages were asked whether or not they wear
glasses for reading, with the following results:

Does age group affect whether or not people wear glasses for reading?
KHÁI NIỆM ĐỘC LẬP
• Hai biến độc lập khi hoàn toàn không có liên quan với nhau.
• Hệ số tương quan (coefficient of correlation) = 0
• Nếu A và B độc lập thì:
• P(A & B) = P(A) x P(B)

https://sciencenotes.org/independent-and-dependent-variables-examples/
MỤC ĐÍCH CỦA CHI-SQUARE
• Khai thác khái niệm độc lập
• Kiểm định sự độc lập giữa hai biến
• Nếu hai biến không độc lập => có liên quan (association).
KIỂM ĐỊNH Ý NGHĨA THỐNG KÊ
• Triết lý phản biện của Popper
• Bước 1: Phát biểu giả thuyết vô hiệu (null hypothesis).
• Bước 2: Thu thập dữ liệu (D)
• Bước 3: Tính xác suất D xảy ra nếu giả thuyết vô hiệu đúng.

• Bước 1: Biến A và B độc lập.


• Bước 2: Thu thập dữ liệu (D) liên quan đến A và B
• Bước 3: Tính xác suất D xảy ra nếu A và B độc lập.
LOGIC CỦA CHI-SQUARE TEST
• Nếu hai biến độc lập: ước tính giá trị kỳ vọng (expected values – E)
• So sánh giá trị kỳ vọng với giá trị quan sát (observed data – O)
2
(𝑂 − 𝐸)
𝜒2 = ෍
𝐸
• Nếu 𝜒 2 lớn, bác bỏ giả thuyết vô hiệu (H0)

https://www.youtube.com/watch?v=misMgRRV3jQ
TYPE I AND TYPE II ERRORS

https://www.simplypsychology.org/type_I_and_type_II_errors.html
TYPE I AND TYPE II ERRORS

Null hypothesis (H0) is


Table of error types
True False

Correct inference
Type II error
Don't (true
(false negative)
reject negative)(probab
(probability = β)
Decision ility = 1−α)
about null
hypothesis (H0)
Type I error Correct inference
Reject (false positive) (true
(probability = α) positive)(probabil
ity = 1−β)
https://en.wikipedia.org/wiki/Type_I_and_type_II_errors
TYPE I AND TYPE II ERRORS

https://medium.com/@neeraj.kumar.iitg/statistical-performance-measures-
12bad66694b7
HỎI ĐÁP

AN INTERNATIONAL STANDARD UNIVERSITY

You might also like