You are on page 1of 39

Learning Objectives:

At the end of the discussion, the student should be able to:


 Define the Chi-square distribution.
 Describe how the shape of the Chi-square distribution changes as its degrees
of freedom increase.
 Determine the appropriate use of the chi-square statistic.
 Understand the different uses of the chi-square test.
 Test the distribution for goodness-of-fit test, using the chi-square.
Video clip on Chi-square:

https://www.youtube.com/watch?v=7_cs1YlZoug
The Chi-square Distribution
The Chi-square distribution is a continuous probability distribution. It is the distribution of a sum
of the squares of k independent standard normal random variables.
In the Chi-square distribution, as the degrees of freedom increases, the Chi-square
distribution approaches a normal distribution.
Characteristics of a Chi-square Distribution:

1. The chi-square distribution is a family of curves


based on the degrees of freedom.
2. The chi-square distributions are positively skewed.
3. All chi-square values are greater than or equal to
zero.
4. The total area under each chi-square distribution
is equal to one.
General Assumptions of a Chi-square
Distribution:
1. The sample was chosen using a random sampling
method.
2. The variables being analyzed are categorical
(nominal or ordinal).
3. All chi-square values are greater than or equal to
zero.
4. The total area under each chi-square distribution is
equal to one.
The Chi-square Distribution can be used to
 find a confidence interval for a variance or standard
deviation;
 test a hypothesis about a single variance or standard
deviation;
 test concerning frequency distributions;
 test the goodness-of-fit test;
 test for independence of two categorical variables;
 test the homogeneity of proportions;
 test the normality of the variable.
Chi-square Test:
A chi-square test (or chi-squared test), denoted by χ2 is statistical hypothesis test
▪ used to investigate whether distributions of categorical variables (at the nominal or ordinal
levels of measurement) significantly differ from one another.
▪ commonly used to compare observed data (actual value) with data we would expect (expected
value) to obtain according to a specific hypothesis.
▪ used to test information about the proportion or percentage of people or things who fit into a
category.
Types of Chi-square Tests:
Chi-square Goodness-of-Fit Test
A chi-square test,
▪ also known as the chi-square goodness-of-fit test is used if we would like to see whether the
distribution of data follows a specific pattern.
For example:
 You would like to see whether the values obtained from an actual observation on the monthly
dividend in stocks differ considerably from the expected value.
 You may want to investigate whether the fluctuation on the interest rates during Sundays is
higher than the rest of the days in a week.
Chi-square Test of Independence
A chi-square test,
▪ can be used to test the independence of two variables.
▪ Is used when we would like to see;

o whether or not two random variables take their values


independently.
o whether the value of one relates with another.
o whether one variable is associated with another.
▪ this test of hypothesis use the chi-square distribution and the contingency table.
For example,
 based on the distribution of data, you want to see whether the success of an individual in his
chosen career is independent or relates with his academic performance in college. Here, the
two variables involved are the success of an individual in his chosen career and his academic
performance in college.
 you may want to see whether the life in years of laptops is independent of brand. Here, the two
variables involved are the life in years of laptop and the brand of laptops.
 A study which involves on determining if job satisfaction can be associated with income. The two
variables are job satisfaction and income.
Chi-square Test for Homogeneity of Proportions

A chi-square test,
▪ can also be used to test the homogeneity of proportions.
▪ this is used to determine whether the proportions for a variable are equal when several samples
are selected from different populations.
▪ this also use the chi-square distribution and the contingency table.
For example,
 You would like to see if the proportions of each group of students who play online gaming are
equal based on their program of affiliation, say proportions of accountancy students,
engineering students, and architecture students who play online gaming.
 You may want to see if the proportions of employees who are in to stock market are equal based
on the nature of their profession (IT, Medicine, Accounting, Engineering).
Two main types of Chi-square Tests to be
discussed here are:
 Goodness-of-fit tests which focus
on one categorical variable.
 Tests of independence which focus on the
relationship between two categorical variables.
Thus, the contingency table (or cross tabulation
table will be used to present the data values).
To illustrate the use of chi-square test:
If, according to Mendel's laws, you expect 10 of 20 offspring to
be male and the actual observed number was 8 males, then you
might want to know about the "goodness-of-fit" between the
observed and expected data.
Were the deviations (differences between observed and expected
value) the result of chance, or were they due to other factors?
How much deviation can occur before we conclude that
something other than chance is at work, causing the observed to
differ from the expected value.
The chi-square test is always testing what scientists call the
null hypothesis, which states that there is no significant
difference between the expected and observed result.
Test for Goodness-of-Fit
Definition:
The chi-square goodness-of-fit test is used to test the
claim that an observed frequency distribution fits some
given expected frequency distribution.

Assumptions of Chi-square Goodness-of-Fit Test:


1. The data are obtained from a random sample.
2. The expected frequency for each category must be 5
or more.
Test Of Goodness-of-Fit
• If the observed frequencies are close to the
corresponding expected frequencies, the 2-value will be
small, indicating a good fit.
• If the observed frequencies differ considerably from the
expected frequencies, the 2-value will be large and the
fit is poor.
• A good fit leads to the non rejection of H0, whereas a
poor fit leads to its rejection.

Test Statistic,
2
To calculate the expected frequencies,
there are two rules to follow:
To test the null hypothesis, the following
formula will be used: 1. If all the expected frequencies are
equal, the expected frequency E can
(O − E ) 2 be calculated by using E =n/k, where n
 =
2

E is the total number of observations and


Where: O = is the observed frequency
k is the number of categories.
E = is the expected frequency 2. If all the expected frequencies are not
df = k – 1, degrees of freedom, k
is the number of
equal, then the expected frequency E
E=
n categories can be calculated by E = n●p, where n
k is the total number of observations and
n = total number of observations p is the probability for that category(or
p is the hypothesized proportion from
the null hypothesis).
Consider for example, a quality control officer of a laptop manufacturing company
would like to see if there was a difference in the life span of laptop batteries among
three categories. A sample of 45 student laptop owners is selected. The table below
shows the distribution of the life span of laptop batteries in years. If there were no
difference, you would expect 45/3 = 15 years life span of batteries for each category.
More than 4 years and
Category 4 years and below Above 10 years
below 10 years
Observed frequency 12 19 14

The observed frequencies will almost always differ from the expected frequencies due to
sampling error; that is, the values differ from sample to sample. But the question is: Are these
differences significant? (Which means, there is a difference in the life span of the batteries for
each category) or will it be due to chance only? Thus, the two opposing statements are necessary
before computing the test value, the null and alternative hypotheses. Here, the null hypothesis
indicates that there is no difference or change among the categories.
Ho: There is no difference in the life span of laptop batteries among three categories.
H1: There is difference in the life span of laptop batteries among three categories.
Summary Procedures in conducting Chi-Squared Goodness-of-Fit Test:

Step 1: State the hypothesis and identify the claim.


Step 2: Find the critical value for the chi-square table. The test is always right-
tailed.
Step 3: Compute the test value using the formula

2 = 
(O − E )2
E
Step 4: Make the decision.
Reject the null hypothesis if the test value is greater than the critical
value.
Do not reject the null hypothesis if the test value is less than the critical
value.
Step 5: Summarize the results.
Example 1:
A quality control officer of a laptop manufacturing company would like to see
if the life span of laptop batteries are equally distributed among three categories.
A sample of 45 student laptop owners is selected. The table below shows the
distribution of the life span of laptop batteries in years. At α = 0.05 can it be
considered that the lifespan of laptop batteries are equally distributed among the
three categories?

More than 4 years


Category 4 years and below Above 10 years
and below 10 years

Observed
frequency
12 19 14

Note that this problem involves only one categorical variable, the life span of laptop batteries classified into
three (4 years and below, more than 4 years and below 10 years, above 10 years), so we use the
goodness-of-fit-test.
Solution:
Step 1: State the hypotheses and identify the claim.
Ho: The ages of laptop batteries are equally distributed over the three
categories. (claim)
(Which is the same as saying that, “There is no difference in
the lifespan of laptop batteries in the three categories.”)
H1: The ages of laptop batteries are NOT equally distributed.
(Which is the same as saying that, “There is difference in the
lifespan of laptop batteries in the three categories.”)
Step 2: Find the critical value. At α = 0.05 and df = 3-1 = 2, locate the
critical value from the chi-square table. Thus, the critical value
is 5.991.
Step 3: Compute the test value
To compute the test value, we solve first for the expected value E.
n 45
E= = = 15
k 3
More than 4 years and
Category 4 years and below Above 10 years
below 10 years
Observed frequency 12 19 14
Expected frequency 15 15 15

Then the test value 2 is

(O − E ) 2 (12 − 15) 2 (19 − 15) 2 (14 − 15) 2


2 = = + + = 1.73
E 15 15 15
2 = 1.73 (test value/computed value or test statistic)

Step 4: Make the decision. Do not reject the null hypothesis, since the test value
1.73 is less than the critical value 5.991 (1.73 < 5.991)

Step 5: Summarize the results. There is no difference in the ages of laptop


batteries over the three categories. The life span of laptop batteries is
equally distributed.
To illustrate the goodness-of-fit test, let us analyze the charts showing the
graphs of the observed values and the expected values of different data sets.
From the charts below, you could see whether the observed values and the
expected values are close together or far apart.
Laptop Batteries Chart Title Chart Title
20 20 25
Frequency

15 20
10
15
0 (A) 10
(B) 10 (C)
1 2 3 5 5
Categories 0 0
1 2 3 1 2 3
Observed frequency Expected frequency
Observed frequency Expected frequency Observed frequency Expected frequency

From (A), the observed From (B), the observed From (C), the observed
values and the expected values and the expected values and the expected
values are close together, values are far apart, the chi- values are far apart, the chi-
indicating that the chi- square test will be large. square test will be large.
square test will be small. Then “the null hypothesis Then “the null hypothesis
The decision will be “do not will be rejected”, hence, will be rejected”, hence,
reject the null hypothesis”, there is “not a good fit”. there is “not a good fit”.
hence, there is “a good fit”.
Example 2:
A financial analyst wants to determine whether investors have any preference on the type of
investment. A sample of 93 investors were interviewed and provided the information shown on the
table below. At 0.10 level of significance, is there a difference in investment preferences among
the investors?

Types of Investment Frequency


Stocks 35
Mutual Funds 18
Bonds 30
Index Funds 10

Note that this problem involves only one categorical variable, the types of investment classified into four
(stocks, mutual funds, bonds, index funds), so we use the goodness-of-fit-test.
Solution:
Step 1: State the hypotheses and identify the claim.
Ho: Investors show no preferences.
(Which is the same as saying that, “There is no difference in the
preferences on the type of investment among investors.”)
H1: Investors show preferences. (claim)
(Which is the same as saying that, “There is difference in the
preferences on the type of investment among investors.”)
Step 2: Find the critical value. At α = 0.10 and df = 4-1 = 3, locate the
critical value from the chi-square table. Thus, the critical value
is 6.251.
Step 3: Compute the test value
Types of Investment Observed Frequency Expected Frequency
Stocks 35 24
Mutual Funds 18 24
Bonds 30 24
Index Funds 10 24

To compute the test value, we solve first for the expected value E.
n 93
E= = = 23.25  24
k 4
Then the test value 2 is
(O − E ) 2 (35 − 24) 2 (18 − 24) 2 (30 − 24) 2 (10 − 24) 2
 =
2
= + + + = 16.21
E 24 24 24 24
2 = 16.21 (test value/computed value or test statistic)

Step 4: Make the decision. Reject the null hypothesis, since the test value 16.21
is greater than the critical value 6.251 (16.21 > 6.251).

Step 5: Summarize the results. There is difference in the preferences on the type
of investment among investors. The investors in fact show preferences.
Example 3:
An article shows statistics of orders made online on a
particular product with different online stores within city. The
data is based on the last six months of the previous year as Number of Orders
Months
follows, July 17%, August 11%, September 8%, October 14%, made with CECT store

November 27%, and December 23%. The CECT online store July 27
manager wants to compare the orders made with his store with August 17
that of the data revealed by the article. The manager listed September 22
the number of orders in his store on the same product stated in October 45
the article. The table on the right shows the data collected by
November 30
the manager for the last six months in the previous year.
December 59
At 0.01 level of significance, can we support the claim that
the proportions of orders with CECT online store is the same as
the rest of the online stores within city?

Note that this problem involves only one categorical variable, months covered in a year, so we use the
goodness-of-fit-test.
Solution:
Step 1: State the hypotheses and identify the claim.
Ho: The orders made on a particular product in different online
stores within the city for the last six months of the year is
distributed as follows: July 17%, August 11%, September 8%,
October 14%, November 27%, and December 23%.
(or “There is no difference between the orders made with the
CECT online stores with the rest of the online stores within
the city”.(claim)
H1: The distribution is not the same as stated in the null hypothesis.
(or “There is difference between the orders made with the
CECT online stores with the rest of the online stores within
the city”.)
Step 2: Find the critical value. At α = 0.01 and df = 6-1 = 5, locate
the critical value from the chi-square table. Thus, the critical
Step 3: Compute the test value
Number of Orders made with CECT
Months store (O)
P E = np

July 27 17% (200)(0.17) = 34


August 17 11% (200)(0.11) = 22
September 22 8% (200)(0.08) = 16
October 45 14% (200)(0.14) = 28
November 30 27% (200)(0.27) = 54
December 59 23% (200)(0.23) = 46
Then the test value 2 is
(O − E ) 2 ( 27 − 34) 2 (17 − 22) 2 ( 22 − 16) 2 ( 45 − 28) 2
 =
2
= + + + +
E 34 22 16 28
(30 − 54) 2 (59 − 46) 2
+ = 29.49
54 46
2 = 29.49 (test value/computed value or test statistic)

Step 4: Make the decision. Reject the null hypothesis, since the test value 29.49 is
greater than the critical value 15.086 (29.49 > 15.086).

α = 0.01

15.086
Step 5: Summarize the results. There is significant difference between the orders
made with the CECT online stores with the rest of the online stores
within the city.
Exercise 1:

A chef of a fine dining restaurant wants to determine whether


customers have any preference among five flavors of ice cream
as toppings in their special dessert. A sample of 100 people
provided the following data. At 0.10 level of significance, is there
a difference in the flavor preferences among the customers?
Exercise 2:

An operations manager would like to see whether the production


of the different parts (A, B, C, D) of a certain electronic
equipment in different machines: laser designing machine for
part A, laser engraving machine of part B, solid filling machine of
part C, and pressing machine of part D is in the ratio 2:2:5:1 per
day. A randomly selected day is inspected to see if the
production of these parts is in the ratio 2:2:5:1. The manager has
recorded that a total of 900 pieces of these parts was found to have 200
pieces of part A, 165 pieces of part B, 468 pieces of part C, and 67 pieces
of part D. At the 0.01 level of significance, test the hypothesis that the
machines has produced these parts in the ratio 2:2:5:1.
References:
 Statistical Analysis with Software Applications, Philippines. Mc Graw Hill Education (2019)
 Bluman, G. (2010). Elementary Statistics : A Step by Step Approach, A Brief Version, 5th
Edition. New York: McGraw- Hill Companies
 https://tophat.com/marketplace/science-&-math/statistics/full-course/statistics-for-social-
science-stephen-hayward/211/34398/
 http://onlinestatbook.com/2/chi_square/distribution.html
 https://www.youtube.com/watch?v=7_cs1YlZoug
 http://www.z-table.com/chi-square-table.html

You might also like