Está en la página 1de 57

Ujian Khi Kuasa Dua

Definitions
Parametric Tests
Statistical tests that involve assumptions about or
estimations of population parameters. (data
come from normally distributed populastion)
Nonparametric Tests
Also known as distribution-free tests
Statistical tests that do not rely on assumptions
of distributions or parameter estimates
(what were going to be learning)

More Definitions
The Chi-Square (X2) test is a nonparametric
test that is used to test hypotheses about
distributions of frequencies across categories
of data.
Different from what weve been learning
Then: averages, scales
Now: Frequencies, Categories

Two Applications of Chi-Square Test


The X2 goodness-of-fit test.

Used when we have distributions of frequencies


across two or more categories on one variable.
Test determines how well a hypothesized distribution
fits an obtained distribution.

The X2 test of independence.

Used when we compare the distribution of


frequencies across categories in two or more
independent samples.
Used in a single sample when we want to know
whether two categorical variables are related.

The Chi-Square Distribution


Statisticians have found that if H0 is true and
we calculate the X2 statistic for all possible
samples of size N, the values for a probability
distribution called the X2 distribution.

Characteristics of the X2
distribution
A family of distributions varying in df (like the t
distribution).
Positively skewed; the amount of skew
decreases as df increases.
Minimum value = 0 (X2 cant be negative)
Average (typical) value increases (the entire
distribution shifts to the right) as df increases.

Characteristics of the X2
distribution

Assumptions for the Chi-square Test


The chi-square Test of Independence can be used
for any level variable, including interval level
variables grouped in a frequency distribution. It
is most useful for nominal variables for which we
do not another option.
Assumptions: No cell has an expected frequency
less than 5.
If these assumptions are violated, the chi-square
distribution will give us misleading probabilities.

2 Types
Goodness-of-fit Test
X2 Test of Independence

The X2 Goodness-of-Fit Test


A test for comparing observed
frequencies with theoretically
predicted frequencies.

Flowers & Genetics


In my backyard, I have a new hybrid rose bush.
I hypothesize that (according to Mendelian
genetic theory) that I should have 50% pink
flowers, 25% white flowers, and 25% red
flowers.

Flowers
I grow 120 of these plants from seed. The
resulting colors of flowers are as follows:
Pink

White

Red

75

20

25

Flowers - Reality & Expectations


Recall, my expectations were 50% Pink, 25%
White, 25% Red.
Observed

Pink
75

White
20

Red
25

So, if I planted 120 seeds, Id expect this set of


colored flowers.
Expected

Pink
60

White
30

Red
30

Flowers - Reality & Expectations


Observed
Expected

Pink
75
60

White
20
30

Red
25
30

If my hypothesis is true (50%, 25%, 25%), how


likely is it that I could get this difference
between my actual distribution and my
expected distribution of colored flowers?

The chi-Square Test


If my hypothesis is true (50%, 25%, 25%), how
likely is it that I could get this difference
between my actual distribution and my
expected distribution of colored flowers?
Used to determine if the probability < , in
which case the hypothesis is rejected

The Chi-Square Test


Hypotheses
H0: P(pink, white, red) = .5, .25, .25
The population proportions of pink, white, and
red flowers are .5, .25, and .25, respectively.

H1: P(pink, white, red) .5, .25, .25


The population proportions of pink, white, and
red flowers are something other than .5, .25, and
.25, respectively.

The Chi-Square Test


Notice that the hypotheses for the Chi-Square
Goodness-of-Fit Test are stated in terms of
proportions.
The Chi-Square TEST is conducted on actual
frequencies not proportions.
Specifically, the X2 test operates on
differences between observed and expected
frequencies.
First - make sure everything is a frequency.

In the Chi-Square Test


we calculate (O-E)2/E in each cell,
sum all of the (O-E)2/E values over all cells,
and compare this summed value to a critical
value.

The Dreaded Six Steps


State H0 and H1.
Choose
Relevant probability distribution is X2 with k 1 df.
Find X2crit & state decision rule: I will reject H0
if X2obt > X2crit
Calculate X2obt
Apply decision rule.

Calculating X2
Observed
Expected

Pink
75
60

White
20
30

Red
25
30

Now find the critical value.

Total
120
120

Interpretation
Since we reject H0, the geneticists hypothesis
does not fit the data.
The population distribution across the three
categories is probably different than .50 pink,
.25 white, .25 red.

Another Example
Alley Chosen
Original

Right

Total

Observed

23

32

Expected

32

Expected frequencies: the expected value for


the number of observations in a cell if H0 is
true.

The Chi-Square (X2) Statistic


The formula is as below:

Boleh anda mengira X2 untuk jadual ini?


Alley Chosen
Original

Right

Total

Observed

23

32

Expected

16

16

32

Extension to Multicategory Case

Observed
Expected

A
4
8

Alley Chosen
B
C
5
8
8
8

D
15
8

Total
32
32

Chi-Square Test of Independence

The X2 test of Independence


Used when:
We want to compare the distribution of
frequencies across categories in two or more
independent samples.
We want to determine whether the paired
observations obtained in two or more categorical
variables are independent or associated.

Analysis of Contingency Table


Contingency Table: A two-dimensional table in
which each observation is classified on the
basis of two variables simultaneously.
We want to know if the distribution of one
variable is conditional of a second variable.

The X2 Test of Independence


Test statistic for the test of independence is
the same as in the goodness-of-fit test:

Two differences:
Calculation of expected frequencies
Calculation of df

df in X2 Independence Tests
df = (# rows - 1) (# columns - 1)
Why?
Remember marginals are fixed in X2
independence tests.

Calculations of expected frequencies


Expected frequency for a given cell is obtained
by multiplying together totals for the row and
column which the cell is located (marginal
totals).

Physical Contact in Neonates


A developmental psychologist hypothesizes
that mothers who have physical contact with
their infants immediately after birth are more
likely to hold them on the left side, where the
sound of the mothers heartbeat is more
pronounced, than mothers who do not have
such early contact with their infants.

She observes 125 early-contact mothers and


105 late contact mothers with the following
results:
Early
Late

Left
80
55

Right
45
50

She observes 125 early-contact mothers and


105 late contact mothers with the following
results:
Early
Late

Left
80 73.4
55 61.6
135

Right
45 51.6
50 43.4
95

125
105
230

The X2 Test of Independence

X2 obt = 3.15
X2 crit = 3.84
Apakah kesimpulan anda?

Contoh 2: Kemurungan & Masalah


Berat Badan
Drug
Placebo

Success
13
14

Relapse
36
30

Anda ingin menguji jika pemberian ubat


Prozac (untuk kemurungan) akan membantu
pesakit mengekalkan berat badan mereka
selepas treatment.

How to write the report


Ujian chi-square telah dijalankan untuk
menguji hipotesis kajian bahawa pemberian
ubat Prozac dapat membantu pesakit anorexia
nervosa untuk mengekalkan berat badan
mereka selepat menjalani rawatan. Data
daripada kajian ini mendapati tidak ada bukti
bahawa kejayaan pesakit anorexia nervosa
mengekalkan berat badan adalah bergantung
kepada status mereka diberi ubat Prozac atau
tidak (X2 (1) = 0.317, p>0.05).

Contoh #3 Test of Proportion


Sex of Bystander
F

Help

23%

28%

No Help

77%

72%

1303

1320

Sex of Bystander
F

Help

300

370

670

No Help

1003

950

1953

Total

1303

1320

2623

Any Questions? Please Ask if you


are not Sure!

Spearmans Correlation
Coefficient

PengiraanPekali Korelasi Spearman

d = perbezaan RANK
antara satu pasangan data
n = bilangan pasangan
data

English
26
75
15
71
62
64
58
80
76
61

Maths
66
70
40
60
65
56
59
77
67
63

English

Maths

Rank Eng

Rank Math

d2

26

66

-5

25

75
15

70
40

8
1

9
1

-1
0

1
0

71

60

62
64

65
56

5
6

6
2

-1
4

1
16

58

59

80

77

10

10

76

67

61

63

-1

1
54

Pengiraan

Nilai Kritikal Spearman r

Nilai Kritikal

Maka apakah kesimpulan anda?

The End

También podría gustarte