Utf-8 Session8

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

8-1

Session 8

The Chi-Squared Test



Observed and Expected Frequencies 8-2
Degrees of Freedom 8-3
The Chi-Squared (_
2
) Distributions 8-4
Comparing Observed and Expected Frequencies
the _
2
Test 8-6
Why do we do Hypothesis Testing? 8-7
Example 8-8
The _
2
Test in SPSS 8-8
Practical session 8 8-11
Additional practical session 8 8-11

8-2
SESSION 8: The Chi-Squared Test

Observed and Expected Frequencies

'Do you see yourself as having a career?'

Males Females Total Males Females Total
Yes 170 123 293 Yes 293
No 121 187 308 No 308
Total 291 310 601 Total 291 310 601
Observed frequencies Marginal totals

Our data provides us with information such as that found in the left-hand
table; we have 'observed' the frequencies. magine for a moment that the
only information we have are the row and column totals, as in the right-hand
table. We could still get frequencies in each of the cells, by using the
marginal totals to obtain Expected Frequencies.

To do this, we have to make an assumption:

We assume that equal proportions of males and females choose each
category

or, to put it another way;

We assume independence between GENDER and CAREER

or even;

We assume there is no association between GENDER and CAREER.

Under this assumption, what are the expected frequencies? Let's take the
top left cell - males answering 'yes'.

The proportion of the sample that is male:
291
601


The number of 'yes' answers: 293.

Therefore, under our independence assumption, we would expect the number
of males who answered 'yes' to be
291
601
* 293 = 141.9
n general, the expected frequency for a particular cell will be:


(corresponding row marginal total) * (corresponding column marginal total)
sample size

So the table of expected frequencies will be:
8-3

Males Females Total
Yes 141.9 151.1 293
No 149.1 158.9 308
Total 291 310 601
Expected frequencies

Notice how the Expected Frequencies differ from the Observed Frequencies.
This difference will be tested formally using the Chi-squared test. However,
basically:

OBSERVED ~ EXPECTED NDEPENDENCE / NO ASSOCATON
OBSERVED ~/~ EXPECTED NO NDEPENDENCE / ASSOCATON


Degrees of Freedom

When using statistical tests, you will repeatedly come across something
called Degrees of Freedom. What are they?

Look at the table of marginal totals on the previous page. With the restriction
that the cells must add up to the marginal totals, put a frequency of your
choice in any one of the cells, and see how this determines the frequencies in
the other cells.

How many cells can you fill in freely?

Males Females Total
Yes Free Fixed 293
No Fixed Fixed 308
Total 291 310 601

The answer is one

Try this in the following table:

ncome band A B C Total
Managing income well 100
Not managing income well 100
Total 50 50 100 200

n general, in a table with r rows and c columns, you have 'freedom of choice'
in (r-1) * (c-1) ceIIs - this is the number of degrees of freedom.
8-4
The Chi-Squared (_ __ _
2
) Distributions

The shape of the chi-squared distribution depends on the number of degrees
of freedom, v.

Figure 8.1

The total area under any one curve = 1.
The Probability (a < _
2
(3)
< b) = area under the curve (v = 3), between a and b.

For a given value a, and v degrees of freedom:
the CriticaI Region is the region where _
2
(v)
> a
the Significance LeveI = 100 * Prob (Critical Region).

Two important and often used Significance Levels are 5% and 1%. Figures
8.2 and 8.3 illustrate the Critical Regions for these Significance Levels for 3
and 10 degrees of freedom.
0.0 2.5 5.0 7.5 10.0 12.5 15.0 17.5 20.0
0.0000
0.0025
0.0050
0.0075
0.0100
0.0125
0.0150
0.0175
0.0200
0.0225
0.0250
0.0275
0.0300
Probability oI
( )
2
v
_
( )
2
v
_
3 = v
5 = v
10 = v
a
b
8-5

Figure 8.2

Figure 8.3


v
Significance
Level
Probability of
Critical Region

Critical Region
3 5% 0.05 _
2
(3)
> 7.81
3 1% 0.01 _
2
(3)
> 11.34
10 5% 0.05 _
2
(10)
> 18.31
10 1% 0.01 _
2
(10)
> 23.21
TabIe 8.1
0.0 2.5 5.0 7.5 10.0 12.5 15.0 17.5 20.0
0.0000
0.0025
0.0050
0.0075
0.0100
0.0125
0.0150
0.0175
0.0200
0.0225
0.0250
0.0275
0.0300
Probability oI
( )
2
3
_
( )
2
3
_
Area
Area 1
0 5 10 15 20 25 30
0.000
0.002
0.004
0.006
0.008
0.010
0.012
0.014
Probability oI
( )
2
10
_
( )
2
10
_
Area 5
Area 1
8-6
You can look up the values in the Table 8.1 in a table called 'Percentage
Points of the _
2
-Distribution' found in books of statistical tables.

n general:

NUMBER OF DEGREES
OF FREEDOM CRTCAL
+ REGON
SGNFCANCE LEVEL


Comparing Observed and Expected Frequencies - the _ __ _
2
Test

Above, we calculated expected frequencies and noticed they differed from the
observed frequencies. How large do these differences have to be for us to
reject the NuII Hypothesis (the original assumption) that there is no
association between the two variables of interest? This is formally tested
using the _ __ _
2
Test:

1. Subtract the expected frequency from the observed frequency in each cell.
2. Square this difference for each cell.
3. Divide each squared difference by the expected frequency of that cell.
4. Add together the results for all the cells in the table.

n summary, where O is 'observed' and E is 'expected';
( )

2

all cells

This is the _ __ _
2
Test Statistic. How does this tell us whether there is any
association between the two variables?

Consider a large number of samples, each with the same marginal totals.
Whereas the observed cell frequencies will be different for each table, the
expected cell frequencies, calculated with the assumption of independence,
will be the same for each table. Calculate the _
2
Test Statistic for each table.
Now,

The distribution of these statistics _
2

as
The number of samples

But which _
2
distribution?

Calculate the degrees of freedom, v vv v, as described on page 2. We then
use _ __ _
2
(v vv v)
.

8-7
What is the significance level?

The usual choice is 5% area under the curve = 0.05

Then, under the assumption of independence,

NUMBER OF DEGREES
OF FREEDOM CRTCAL
+ REGON
SGNFCANCE LEVEL

For example;
v=2 significance level = 5%

critical region: _
2
(2)
> 5.99.

So, if we took 100 samples of a 2 * 3 table, with the same marginal totals, we
would expected to find 5 samples with a _
2
Test Statistic > 5.99. However,
we would only expect 1 sample to have a _
2
Test Statistic > 9.21. (These
figures can be found be looking up v=2 and the significance levels of 5% and
1% in a 'Percentage Points' table.)

We accept or reject the Null Hypothesis at the 5% level as follows:

Observed _
2
Test Statistic falls within
the Critical Region



Under assumption of independence,
the probability of obtaining _
2
Test
Statistic greater than that observed
is < 0.05



Evidence of association at 5% level
(reject the Null Hypothesis)
Observed _
2
Test Statistic falls
outside the Critical Region



Under assumption of independence,
the probability of obtaining _
2
Test
Statistic greater than that observed
is > 0.05



No evidence of association at 5%
level (accept the Null Hypothesis)


Why do we do Hypothesis Testing?

We want to use our sample to make about the 'population' from
which it was drawn. For example, an apparent association between two
variables within a sample may provide evidence that these two variables
really associated in the full population, or there may not be sufficient
evidence to say the pattern in the sample is any more than chance
fluctuations among the cases chosen.
8-8
ExampIe 1991 General Social Survey

Life Males Females Total Males Females Total
Exciting 213 221 434 Exciting 188.2 245.8 434
Not exciting 212 334 546 Not exciting 236.8 309.2 546
Total 425 555 980 Total 425 555 980
Observed frequencies Expected frequencies

Null Hypothesis: No association between SEX and LFE
Alternative Hypothesis: Association present

_
2
Test Statistic =

( ) ( ) ( ) ( ) 213 188 2
188 2
212 2368
2368
221 2458
2458
334 309 2
309 2
10 36
2 2 2 2

+

+

+

=
.
.
.
.
.
.
.
.
.

Degrees of freedom = (2-1) * (2-1) = 1 Critical
+ Region
Significance level = 5% _
2
(1)
> 3.84

Observed _
2
Test Statistic of 10.36 lies in Critical Region

Reject Null Hypothesis

Evidence of a significant association between the two variables SEX and
LFE at 5% significance level

Evidence of a significant difference in proportions of males and females
considering that life is exciting.


The _ __ _
2
Test in SPSS

Of course, you don't have to do these calculations every time you want to do
a _
2
Test - SPSS will do it for you quite simply. Firstly, in the GSS data
recoded the variable LIFE so that categories 2 and 3 (ROUTNE and DULL)
were combined into one category, NOT EXCTNG, with value 2.

Using the sequence

Analyze
Descriptive Statistics
Crosstabs...

will give the familiar Crosstabs dialogue box. Move the variable LIFE into the
Rows area, and SEX into the CoIumns area. Clicking on the CeIIs button,
we can select CoIumn Percentages and Expected Counts in addition to the
Observed Counts.

Recoded to have
only 2 categories
8-9
Clicking on the Statistics button gives the Crosstabs: Statistics dialogue
box, seen in Figure 8.4. We select the Chi-square option and then click on
Continue.


Figure 8.4

Clicking OK produces two tables: the Crosstabs and the Chi-Square Tests
(Figures 8.5 and 8.6)


Figure 8.5

We can see from the CoIumn Percentages that whereas about half the
males thought life was EXCTNG, only about 40% of the females agreed.

SPSS produces several different test results when you request the Chi-
Square option, as can be seen in Figure 8.6. We will use the Pearson Chi-
Square, produced in the first line of the table.
8-10

Figure 8.6

SPSS calculates the test statistic and the degrees of freedom in the first two
columns VaIue and df (the value of the test statistic differs slightly from our
calculation due to the greater accuracy of SPSS). At this point we could work
out the Critical Region from Percentage Points tables and compare this with
the test statistic to decide whether to accept or reject our Null Hypothesis.
However, SPSS provides a quick and simple way for us to make our decision.

The third column, Asymp. Sig. (2-sided), contains the significance level for
10.345 on 1 degree of freedom. For a test statistic of 3.841, this would read
0.05 the 5% level of significance. n this case we see it is 0.001, or about
0.1% (it is actually between 0.05% and 0.15%, but is rounded).

n other words, we would expect to see a test statistic of 10.345 or larger in
only about 1 of 1000 samples with no association between SEX and LFE.
This is strong evidence that our original assumption of independence was
incorrect, and we therefore reject the Null Hypothesis.

F THE SGNFCANCE S LESS THAN 0.05 (5%), REJECT THE NULL
HYPOTHESS OF NDEPENDENCE.


(NB Occasionally, you will see a value of .000 in the Asymp. Sig. (2-taiIed)
column - this does not mean that there is no significance! t is actually a very
significant value - one that is less than .0005. SPSS has simply run out of
space to print all the decimal places.)
8-11
PracticaI session 8

Open the GSS91t data in the usual way.

n Exercise 7, Question 3, you produced a bar chart of HAPPY with the
clusters defined by SEX. You will have seen that there were differences in
the percentages of males and females in each category. Does this mean
there is an association between gender and how happy people are?

Test this by performing a _
2
Test on HAPPY and SEX. Don't forget to select
Expected Counts, and column percentages.

Save your output as exer8.spo

Write down your Null and Alternative Hypotheses. Using the Pearson _
2

Statistic, is there evidence to reject the Null Hypothesis at the 5% level?
What is the actual level of significance?


AdditionaI practicaI session 8

Both these questions relate to the GSS91t data set.

1. PRESTG80 - The OccupationaI Prestige Score

Look at the Histogram of PRESTG80 that you produced and saved in
Practical session 7 (a:\exer7.spo) or look back at Figure 7.5.

We want to recode the numerical variable PRESTG80 into a categorical
variable with a small number of categories. Use the Histogram to help you
decide on the number and width of these categories. Use Recode to create a
new variable, GROCCPR.

Test whether there is an association between whether people are happy
(HAPPY) and their Occupational Prestige (GROCCPR).

2. LIFE - whether peopIe find Iife exciting or duII

Recode the variable LIFE so that category 2 contains those answering either
ROUTNE or DULL. Change the VaIue LabeIs accordingly.

Produce a Histogram of AGE, and decide how to split this numerical variable
into a small number of categories. Create a new variable, GRPAGE.

Test whether there are age-related differences in how exciting people found
life.

Save your output in exer8a.spo

You might also like