chi-square test for independence

advertisement
COURSE: JUST 3900
INTRODUCTORY STATISTICS
FOR CRIMINAL JUSTICE
Chapter 17:
The Chi-Square Statistic
Instructor:
Dr. John J. Kerbs, Associate Professor
Joint Ph.D. in Social Work and Sociology
Parametric & Nonparametric Tests

Chapter 17 introduces two non-parametric
hypothesis tests using the chi-square
statistic:
the chi-square test for goodness of fit
 the chi-square test for independence.


Chapter 17 also describes two ways of
evaluating effect sizes for non-parametric
tests
Phi-Coefficients (ɸ)
 Cramer’s V (V)

Parametric & Nonparametric Tests

The term "non-parametric" refers to the fact
that the chi-square tests do not
1. require assumptions about population
parameters, or
 2. test hypotheses about population parameters.


Previous examples of hypothesis tests, such
as the t tests and analysis of variance, are
parametric tests and they do include
assumptions about parameters and
hypotheses about parameters.
Parametric & Nonparametric Tests
The most obvious difference between the
chi-square tests and the other hypothesis tests
we have considered (t and ANOVA) is the
nature of the data.
 For chi-square tests, the data are frequencies
for nominal- or ordinal-level data



T-tests and ANOVA examine numerical scores for
interval- or ratio-level data
Chi-Square tests have few (if any) assumptions

Thus, often called “distribution-free tests”
The Chi-Square Test for
Goodness-of-Fit
TEST #1: chi-square test for goodness-of-fit
uses frequency data from a sample to test
hypotheses about the shape or proportions of a
population.
 Each individual in the sample is classified into
one category on the scale of measurement



Nominal- or interval-level data
The data, called observed frequencies,
simply count how many individuals from the
sample are in each category.
Situations for Transforming
Scores into Categories

Appropriate times for transforming interval- or
ratio-level data into nominal- or ordinal-level
data for Chi-Square analyses
1. When it is easier to obtain categorical
measurements
 2. Original interval- or ratio-level variables violate
assumptions for t-tests and ANOVA
 3. Original interval- or ratio-level scores have high
variance, which can be removed by collapsing
interval- or ratio-level scores into nominal or ordinal
categories.

The Chi-Square Test for
Goodness-of-Fit

The null hypothesis specifies the proportion of the population
that should be in each category. Examples:





H0: No preference among different categories, equal proportions
H1: Preference among different categories with the population not
divided into equal proportions
H0: No difference in between the proportions for one population and
the known proportions for another population
H1: Population proportions are not equal to the values specified by
the null hypothesis
The proportions from the null hypothesis are used to compute
expected frequencies (fe) that describe how the sample would
appear if it were in perfect agreement with the null hypothesis.
Three Ways of Depicting
Frequency Distributions
NOTE: Frequency Table
Approach
NOTE: Bar-Graph
Approach
NOTE: Boxed
Frequencies Approach
Chi-Square Test for Independence

TEST #2: chi-square test for independence,
can be used and interpreted in two different
ways:
1. Testing
hypotheses about the relationship between
two variables in a population, or
2. Testing hypotheses about differences between
proportions for two or more populations.
Chi-Square Test for Independence



Although these two versions of the test for independence
appear to be different, they are equivalent and they are
interchangeable.
The first version of the test emphasizes the relationship
between chi-square and a correlation, because both
procedures examine the relationship between two variables.
The second version of the test emphasizes the relationship
between chi-square and an independent-measures t test (or
ANOVA) because both tests use data from two (or more)
samples to test hypotheses about the difference between two
(or more) populations.
Chi-Square Test for Independence
The first version of the chi-square test for
independence views the data as one sample in
which each individual is classified on two
different variables.
 The data are usually presented in a matrix with
the categories for one variable defining the
rows and the categories of the second variable
defining the columns.

Chi-Square Test for Independence
The data, called observed frequencies,
simply show how many individuals from the
sample are in each cell of the matrix.
 The null hypothesis for this test states that
there is no relationship (or no association)
between the two variables; that is, the two
variables are independent.

Chi-Square Test for Independence
The second version of the test for
independence views the data as two (or more)
separate samples representing the different
populations being compared.
 The same variable is measured for each
sample by classifying individual subjects into
categories of the variable.
 The data are presented in a matrix with the
different samples defining the rows and the
categories of the variable defining the columns.

Chi-Square Test for Independence
The data, again called observed frequencies,
show how many individuals are in each cell of
the matrix.
 The null hypothesis for this test states that the
proportions (the distribution across categories)
are the same for all of the populations

Chi-Square Test Statistic

Both chi-square tests use the same statistic.
The calculation of the chi-square statistic
requires two steps:
1.
The null hypothesis is used to construct an
idealized sample distribution of expected
frequencies that describes how the sample
would look if the data were in perfect agreement
with the null hypothesis.
Chi-Square Test Statistics
For the goodness of fit test, the expected frequency for
each category is obtained by
expected frequency = fe = pn
(p is the proportion from the null hypothesis and n is the size
of the sample)
For the test for independence, the expected frequency for
each cell in the matrix is obtained by
(row total)(column total)
expected frequency = fe = ────────────────
n
NOTE: This n represents
the total n for the entire
sample in the matrix
Chi-Square Test Statistics
2. A chi-square statistic is computed to measure the
amount of discrepancy between the ideal sample
(expected frequencies from H0) and the actual
sample data (the observed frequencies = fo).

A large discrepancy results in a large value for
chi-square and indicates that the data do not fit
the null hypothesis and the hypothesis should
be rejected.
Chi-Square Test Statistic
The calculation of chi-square is the same for all
chi-square tests:
(fo – fe)2
chi-square = χ2 = Σ ─────
fe
The fact that chi-square tests do not require
scores from an interval or ratio scale makes
these tests a valuable alternative to the t tests,
ANOVA, or correlation, because they can be
used with data measured on a nominal or an
ordinal scale.
4-Step Chi-Square Test
Goodness of Fit


Question: It has long been known that offenders often commit crimes under
the influence of drugs. A criminologist wants to examine the drug of choice
for drug-involved offenders who committed crimes for which they were
arrested while under the influence. A total of 50 drug-using arrestees are
sampled and each was asked to indicate which drug was in their system at
the time of their offense/arrest. The following data indicate how many
arrestees were using any given category of drugs:
Alcohol
Marijuana
Opiates
Other
18
17
7
8
The question for this hypothesis test is whether there are any preferences
among the four possible choices. Are any of the drugs reported more or
less often than would be expected simply by chance?
4-Step Chi-Square Test
Goodness of Fit

Step 1:

State the hypotheses and select the α level. For the chisquare test for goodness of fit,



H0 : In the general population of drug-using arrestees, there is no
difference for the drug of choice at the time of arrest.
H1 : In the general population of drug-using arrestees, one or more
of the drugs is preferred as evidenced by their use at the time of
arrest.
Alcohol
Marijuana
Opiates
Other
25%
25%
25%
25%
Alpha Level (α) = 0.05
4-Step Chi-Square Test
Goodness of Fit

Step 2:

Locate the critical region for the chi-square (χ2) test for
goodness of fit.

Step 2a: Find degrees of freedom (df = C – 1 = 4 – 1 = 3)

Step 2b: Use df (3) & alpha level (.05) to find critical value for χ2 test
χ2 crit = 7.81
Note: This value is found in Table B8
(The Chi-Square Distribution) on page 711
4-Step Chi-Square Test
Goodness of Fit

Step 3:

Calculate the Chi-Square Statistic

Step 3a: Compute expected frequencies (fe)
Null Hypothesis (H0) specifies proportions for each cell
With a sample of 50 arrestees, the expected frequencies
for each category of drugs is equal in proportion (25%)
for all categories

Step 3b: fe = pn = .25(50) = 12.5
Note: p = proportion from null hypothesis (.25) and
n = total number in sample (i.e., 50)

4-Step Chi-Square Test
Goodness of Fit
Step 3:

Calculate the Chi-Square Statistic

Step 3c: Using observed frequencies (fo) and expected frequencies
(fe), compute chi-square statistic
Χ2 = ∑
Χ2
=
Χ2 =
Χ2 =
Alcohol
Marijuana
Opiates
Other
Observed
18
17
7
8
Expected
12.5
12.5
12.5
12.5
𝑓𝑜 − 𝑓𝑒 2
𝑓𝑒
18−12.5 2
17−12.5 2
7−12.5
+
+
12.5
12.5
12.5
(5.5)2 + (4.5)2 + (−5.5)2 + (−4.5)2
12.5
12.5
12.5
12.5
30.25 + 20.25 + 30.25 + 20.25
12.5
12.5
12.5
12.5
2
+
8−12.5
12.5
Χ2 = 2.42 + 1.62 + 2.42 + 1.62 = 8.08
2
4-Step Chi-Square Test
Goodness of Fit

Step 4:

State a Decision and a Conclusion

Given that the calculated chi-square value (χ2 = 8.08) is larger than
the critical value for chi-square tests with df = 3 and α = .05
(χ2 crit = 7.81), we reject the null hypothesis. Thus, there are
significant differences among the four drugs, with some selected
more often and others less often than would be expected by
chance.
4-Step Chi-Square Test
for Independence

Purpose for test:

Use frequency data from the sample to evaluate the relationship
between two variables in the population. Each individual in the
sample is classified on both of the two variables, which creates a
two-dimensional frequency-distribution matrix. The frequency
distribution for the sample is then used to test hypotheses about the
corresponding frequency distribution for the population.

4-Step Chi-Square Test
for
Independence
Question: It has long been known that offenders who commit
misdemeanors and felonies often commit crimes under the influence of
drugs. A criminologist wants to examine the drug of choice for druginvolved offenders who committed crimes for which they were arrested
while under the influence. A total of 140 offenders (some were arrested
for felonies while others were arrested for misdemeanors) are sampled and
each was asked to indicate the nature of their arrest and which drug was in
their system at the time of their offense/arrest. The following data indicate
how many arrestees were using any given category of drugs:

Alcohol
Marijuana
Opiates
Other
Misdemeanors
29
25
18
8
80
Felons
11
15
22
12
60
40
40
40
20
140
The question for this hypothesis test is whether there are any preferences
among the four possible choices for these two groups. Are any of the
drugs reported more or less often than would be expected simply by
chance?
4-Step Chi-Square Test
for Independence

Step 1:

State the hypotheses and select the α level (α = 0.05). For
the chi-square test for independence,





H0 : There is no relationship between the two variables
H1 : There is a relationship between the two variables
H0 : For the general population of arrestees, there is no relationship
between offense type (misdemeanor versus felony) and the type of
drugs that were reported as being used at the time of arrest
H1 : For the general population of arrestees, there is a relationship
between offense type (misdemeanor versus felony) and the type of
drugs that were reported as being used at the time of arrest
H0 : In the population of arrestees, the proportions in the distribution
of drugs reported as being used at the time of arrest for
misdemeanors are not different from the proportions in the
distribution of drugs reported as being used by arrestees at the time
of arrest for felonies.
4-Step Chi-Square Test
for Independence

Step 2:

Locate the critical region for the chi-square (χ2) test for
independence.

Step 2a: Find degrees of freedom [df = (2 - 1) * (4 – 1) = 1*3 = 3)

Step 2b: Use df (3) & alpha level (.05) to find critical value for χ2 test
of independence
χ2 crit = 7.81
Note: This value is found in Table B8
(The Chi-Square Distribution) on page 711
4-Step Chi-Square Test
for Independence

Step 3:

Calculate the Chi-Square Statistic

Step 3a: Compute expected frequencies where fe =
𝑓𝑐 𝑓𝑟
𝑛
Note that fc = frequency total for column
Note that fe = frequency total for row
Note that n = number of arrestees in total sample
Alcohol
Marijuana
Opiates
Other
Misdemeanors
(40*80)/140
(40*80)/140
(40*80)/140
(20*80)/140
80
Felons
(40*60)/140
(40*60)/140
(40*60)/140
(20*60)/140
60
40
40
40
20
140
Alcohol
Marijuana
Opiates
Other
Misdemeanors
22.9
22.9
22.9
11.4
80
Felons
17.1
17.1
17.1
8.6
60
40
40
40
20
140

4-Step Chi-Square Test
for Independence
Step 3: Calculate the Chi-Square Statistic

Step 3c: Using expected frequencies below (fe) and observed
frequencies (fo) in parentheses below, compute chi-square statistic
Alcohol
Marijuana
Opiates
Other
Misdemeanors
22.9 (29)
22.9 (25)
22.9 (18)
11.4 (8)
80
Felons
17.1 (11)
17.1 (15)
17.1 (22)
8.6 (12)
60
40
40
40
20
140
Χ2 = ∑
Χ2
=
Χ2 =
Χ2 =
𝑓𝑜 − 𝑓𝑒 2
𝑓𝑒
29−22.9 2
25−22.9 2
18 −22.9 2
8−11.4 2
+ 22.9 + 22.9 + 11.4 +
22.9
11−17.1 2
15−17.1 2
22−17.1 2
12−8.6 2
+ 17.1 + 17.1 + 8.6
17.1
(−6.1)2 + (2.1)2 + (−4.9)2 + (−3.4)2 + (−6.1)2 + (−2.1)2 + (4.9)2 + (3.4)2
22.9
22.9
22.9
11.4
17.1
17.1
17.1
8.6
37.2 + 4.4 + 24.0 + 11.6 + 37.2 + 4.4 + 24.0 + 11.6
22.9 22.9 22.9 11.4 17.1 17.1 17.1 8.6
Χ2 = 1.62 + 0.19 + 1.05 + 1.02 + 2.18 + 0.26 + 1.40 + 1.35 = 9.07
4-Step Chi-Square Test
for Independence

Step 4:

State a Decision and a Conclusion

Given that the calculated chi-square value (χ2 = 9.05) is larger than
the critical value for chi-square tests with df = 3 and α = .05
(χ2 crit = 7.81), we reject the null hypothesis.

Thus, for the general population of arrestees, there is a relationship
between offense type (misdemeanor versus felony) and the type of
drugs that were reported as being used at the time of arrest
Measuring Effect Size for the ChiSquare Test for Independence

When both variables in the chi-square test for
independence consist of exactly two
categories (the data form a 2 x 2 matrix), it is
possible to re-code the categories as 0 and 1
for each variable and then compute a
correlation known as a phi-coefficient (ɸ) that
measures the strength of the relationship.
Measuring Effect Size for the ChiSquare Test for Independence
The value of the phi-coefficient, or the squared
value which is equivalent to an r 2, is used to
measure the effect size.
 When there are more than two categories for
one (or both) of the variables, then you can
measure effect size using a modified version of
the phi-coefficient known as Cramér’s V.
 The value of V is evaluated much the same as
a correlation.

Measuring Effect Size for the ChiSquare Test for Independence


Phi-coefficient (ɸ) is calculated as follows for a 2X2 matrix
Example: Consider a 2x2 matrix that is defined by gender
(1 row for males and 1 row for females) and offense type
(1 column for misdemeanors and 1 column for felonies). In
this example, χ2 = 6.66, n=60, and we need ɸ
χ2
𝑛
6.66
60
NOTE: If you square the phi-coefficient (ɸ2),
you get the percentage of variance
accounted for in the association between
the two variables (gender and crime type).

ɸ=

NOTE: ɸ = 0.10 (small effect), 0.30 (medium effect), 0.50 (large effect)
Note: If you increase sample sizes and keep proportions
the same, the chi-square statistics will increase (more likely
to reach significance), but phi-coefficients stay the same.

=
= 0.333
Measuring Effect Size for the ChiSquare Test for Independence:
Cramer’s V (Cohen, 1988)


Cramer’s V (V) is calculated for any matrix larger than 2X2
The formula is a slight modification of the phi-coefficient

V=
χ2
𝑛(𝑑𝑓∗)
where n = total sample size and
df* = the smaller of (R - 1) or (C - 1)
NOTE: if df* = 1, then interpret the
same as a 2X2 matrix for phicoefficient effect-size cutoffs
Assumptions and Restrictions for
Chi-Square Tests

Failure to meet the assumptions of a statistical test can
increase the possibility of Type I error and/or cause other
problems.

Important Assumptions/Restrictions for Chi-Square Tests

1. Independence of Observations: Each observed frequency is
generated by a different individual. Each person can only produce a
response that is categorized into one category.

2. Size of Expected Frequencies: Do not perform chi-square tests
on a matrix if one or more expected frequencies in any cell(s) is less
than 5.
Download