Tests of Goodness of Fit, Independence, and
Multiple Proportions
Non-Parametric Tests: Chi-Square Tests
• Non-parametric tests imply that the tests are not based
on the assumptions that the data is drawn from a
probability distribution defined through parameters
such as mean, proportion and standard deviation.
• A major difference between parametric and
non-parametric tests is that in a parametric test we
need only values of the parameter and the knowledge
about the distribution, whereas in case of
non-parametric test we use the entire distribution of
the data.
• Importantly, the data may not follow any parametric
distribution such as normal distribution. Also, the test
is not about the population parameter but about
characteristics of the entire distribution
Non-Parametric Tests: Chi-Square Tests
• A non-parametric method for hypothesis tests is used when one or
more of the following conditions exist in the test:
The test is not about the population parameter such as mean and standard
deviation.
The method does not require assumptions about population distribution (such
as population follows normal distribution).
Testing the Equality of Population
Proportions for Three or More Populations
Hypotheses:
•
Example: Finger Lakes Homes
Finger Lakes Homes manufactures three models of prefabricated
homes, a two-story colonial, a log cabin, and an A-frame. To help in
product-line planning, management would like to compare the
customer satisfaction with the three home styles.
p1 = proportion likely to repurchase a Colonial for the population
of Colonial owners
p2 = proportion likely to repurchase a Log Cabin for the
population of Log Cabin owners
p3 = proportion likely to repurchase an A-Frame for the
population of A-Frame owners
• We begin by taking a sample of owners from each of the three populations.
• Each sample contains categorical data indicating whether the respondents are
likely or not likely to repurchase the home.
Here are the observed frequencies (sample results)
Likely to Home owner Home Home Owner
Total
repurchase Colonial Owner Log A-frame
Yes 97 83 80 260
No 38 18 44 100
Total 135 101 124 360
Next, we determine the expected frequencies under the assumption H0 is
correct. Expected frequencies under the assumption H0 is true are calculated
using this method:
• If a significant difference exists between the observed and expected frequencies,
hypothesis H0 can be rejected, and there is evidence that not all the
population proportions are equal.
• Assume that the null hypothesis of equal population proportions is true.
•If a significant difference exists between the observed and
expected frequencies, H0 can be rejected.
The expected frequencies are:
Home Home Home
Likely to
owner Owner Owner Total
repurchase
Colonial Log A-frame
Yes 97.50 72.94 89.56 260
No 37.50 28.06 34.44 100
Total 135 101 124 360
Next, compute the value of the chi-square test statistic.
Computation of the Chi-Square Test Statistic.
Likely to Home Obs. Freq. Exp. Freq. Diff. of open Sqd. Diff. of open Sqd. Diff/ Exp. Freq. of
Repurchase Owner of f of e parenthesis f subscript parenthesis f subscript (fij – eij)2 / eij
subscript i j subscript i j i j baseline minus e i j baseline minus e Start fraction, open
baseline baseline subscript i j baseline subscript i j baseline parenthesis f subscript
Close parenthesis Close parenthesis i j baseline minus e
squared subscript i j baseline
Close parenthesis
squared, over e
subscript i j baseline
Yes Colonial 97 97.50 -0.50 0.2500 0.0026
Yes Log Cab. 83 72.94 10.06 101.1142 1.3862
Yes A-frame 80 89.56 -9.56 91.3086 1.0196
No Colonial 38 37.50 0.50 0.2500 0.00687
No Log Cab. 18 28.06 -10.06 101.1142 3.6041
No A- frame 44 34.44 9.56 91.3086 2.6509
Empty cell Total 360 360 Empty cell x squared = 8.6700
Rejection Rule:
Rejection Rule (using α = 0.05)
Conclusion using the p-value approach:
Area in upper tail .10 .05 .025 .01 .005
Chi squared (df = 2) 4.605 5.991 7.378 9.210 10.597
• We have concluded that the population proportions for the three
populations of home owners are not equal.
• To identify where the differences between population proportions
exist, we will rely on a multiple comparisons procedure.
Chi-Square Test of Independence
•
Ques:
Assume that a telecom company is interested in checking whether or not the
customer churn depends on the customer segment. Here the customers are
classified either as churned or retained.
Consider the data shown in Table which provides customer segment wise the
churned and retained customers, and this table is often called as the
contingency table.
Customer Segment Churn Retain Total
Segment 1 25 250 275
Segment 2 41 484 525
Segment 3 28 172 200
Total 94 906 1000
Chi-Square Test of Independence
In the given table(pervious slide), we have observed values for both churn
and retained customers.
We can calculate the expected frequencies for two classes (churned and
retained) for different customer segments using the basic concept of
independent events.
From basic theory of probability, we know that if two events A and B are
independent then P(A ∩ B) = P(A) P(B).
Oij = Observed number of cases in customer segment i (i = 1, 2, 3) and
classification j (1 = churned and 2 = retained)
That is, O11 is observed number of churned customers in customer segment
1 (which is 25 as per the table).
Chi-Square Test of Independence
We can calculate the expected number of cases for each of the observed
values using the following logic:
Let Eij = Expected number of cases in customer segment i (i = 1, 2 , 3) and
classification j (1 = churned and 2 = retained)
To calculate Eij, we have to first calculate P(i, j) [= P(i ∩ j)] , that is the joint
probability of (i, j). Let i = segment 1 and j = churned. Then assuming i and j
to be independent we can write
P(segment 1, churned) = P(segment 1) × P(churned) = (275/1000) ×
(94/1000)
That is, for segment = 1 and classification = 1 (churned),
E11 = n × P(segment 1) × P(churned)
= 1000 × (275/1000) × (94/1000) = (275 × 94) /1000
Chi-Square Test of Independence
Note that,
E11 = (Sum of row 1 × Sum of column 1)/Total sum
In general, the value of
Eij = (Row sum × Column sum)/Total sum
• With r rows and c columns in the table, the chi-square distribution will have
(r – 1)(c – 1) degrees of freedom.
Chi-Square Test of Independence
For the data in Table, the null and alternative hypotheses are
H0:Customer segments and customer churn are independent
HA:Customer segments and customer churn are dependent
We can calculate the expected values for each segment and churn
classification combination. The statistic for chi-square test of independence
is same as the statistic for goodness of fit test and is given by
The chi-square statistic calculation for the data is shown in below table:
Customer Class Oij Eij =
Segment
1 (i = 1) Churned (j =1) 25 25.85 0.02795
2 (i = 2) Churned (j = 1) 41 49.35 1.412817
3 (i = 3) Churned (j = 1) 28 18.8 4.502128
1 (i = 1) Retained (j = 2) 250 249.15 0.0029
2 (i = 2) Retained (j = 2) 484 475.65 0.146584
3 (i = 3) Retained (j = 2) 172 181.2 0.467108
Chi-Square Test of Independence
The chi-square statistic value is given by
The chi-square statistic value is 6.55.
area (right side) is [Link](6.55,2,true)=0.0378=p-value
P< α, 0.0378<0.05, so reject the null hypothesis , that is the customer segment and
customer churn are not independent.
The chi-statistic value is 6.55 and the critical value is 5.99 (at α = 0.05). Thus we
reject the null hypothesis, that is the customer segment and customer churn are
not independent.
Test of Independence
Example: Finger Lakes Homes (B)
Each home sold by Finger Lakes Homes can be classified according to
price and to style. Finger Lakes’ manager would like to determine if
the price of the home and the style of the home are independent
variables.
The number of homes sold for each model and price for the past two
years is shown below. For convenience, the price of the home is
listed as either less than $200,000 or more than or equal to $200,000.
Price Colonial Log Split-Level A-Frame
< $200,000 18 6 19 12
≥ $200,000 12 14 16 3
Test of Independence
Hypotheses
H0: Price of the home is independent of the style of the home that
is purchased
Ha: Price of the home is not independent of the style of the home
that is purchased
Expected Frequencies
Price Colonial Log Split-Level A-frame Total
< $200 K 18 6 19 12 55
≥ $200 K 12 14 16 3 45
Total 30 20 35 15 100
Test of Independence
• Rejection Rule
• Test Statistic
Test of Independence
Conclusion using the p-value approach
Area in .10 .05 .025 .01 .005
upper tail
χ 2 value 6.251 7.815 9.348 11.345 12.838
(df =3)
Chi-Square Goodness of Fit Tests
Goodness of fit tests are hypothesis tests that are used for comparing the
observed distribution of data with expected distribution of the data to
decide whether there is any statistically significant difference between the
observed distribution and a theoretical distribution (such as exponential,
normal, binomial, etc.) based on comparison of observed frequencies in the
data and the expected frequencies if the data follows a specified theoretical
distribution.
Chi-Square Goodness of Fit Tests
The null and alternative hypotheses in chi-square goodness of fit tests are
H 0: There is no statistically significant difference between the observed
frequencies and the expected frequencies from a hypothesized
distribution.
H A: There is a statistically significant difference between the observed
frequencies and the expected frequencies from a hypothesized
distribution.
Example
Hanuman Airlines (HA) operated daily flights to several Indian cities. One
of the problems HA faces is the food preferences by the passengers.
Captain Cook, the operations manager of HA, believes that 35% of their
passengers prefer vegetarian food, 40% prefer non-vegetarian food, 20%
low calorie food, and 5% request for diabetic food. A sample of 500
passengers was chosen to analyse the food preferences and the data is
shown in Table. Conduct a chi-square test of independence to check
whether Captain Cook’s belief is true at α = 0.05.
Food Type Vegetarian Non-Vegetarian Low Caloric Diabetic
Number of Passengers 190 185 90 35
Solution
The null and alternative hypotheses in this case are given as
H0: Probability distribution of the food preference:
P(Vegetarian) = 0.35; P(Non-Vegetarian) = 0.40; P(Low Caloric)
= 0.20, and P(Diabetic) = 0.05
HA: Probability distribution of the food preference is not as defined
in null hypothesis
Dof: k-1
Since the sample is 500, we can calculate the expected values for various food
preferences using the proportions given in the question.
Solution Continued
•Expected frequency for vegetarian= (190+185+90+35)*0.35=175
•Expected frequency for non-vegetarian= (190+185+90+35)*0.4=200
Food Type Observed Expected Frequency
Frequency (Oi) (Ei)
Vegetarian 190 175 1.285
Non-Vegetarian 185 200 1.125
Low Caloric 90 100 1
Diabetic 35 25 4
Solution Continued
The chi-square statistic value is given by
Note that this is a right-tailed test. The chi-square critical value (df = 4 – 1 = 3) for α
= 0.05 is 7.8147.
Area method: [Link](7.41,3,true)=.0599 =p-value=area based on statistics
P> α or .0599> 0.05, we retain the null hypothesis. That is, we conclude that
Captain Cook’s belief about the food preferences of HA is true.
OR
Since the calculated chi-square value is less than the critical value we retain the null
hypothesis. That is, we conclude that Captain Cook’s belief about the food
preferences of HA is true.
Below figure shows the critical values and the
chi-square statistic values.
Goodness of fit test: Normal distribution
The goodness of fit test for a normal probability distribution is also based on the
use of the chi-square distribution.
Let us demonstrate the goodness of fit test for a normal distribution by
considering the job applicant test data for Chemline, Inc.
Scores
71 60 55 82 85 65 77 61 79
66 86 63 79 80 62 54 56 84
61 70 56 76 56 90 64 63 65
70 62 68 61 69 74 80 54 73
76 53 61 76 65 56 93 73 54
58 64 79 65 71
Chemline hires approximately 400 new employees annually for its four plants
located throughout the United States. The personnel director asks whether a
normal distribution applies for the population of test scores.
Goodness of Fit Test: Multinomial
Probability Distribution
A probability distribution where each outcome belongs to one of
three or more categories. The multinomial probability distribution
extends the binomial probability from two to three or more
outcomes per trial.
Goodness of Fit Test: Multinomial Probability
Distribution
•
Multinomial Distribution Goodness of Fit Test
Finger Lakes Homes manufactures four models of
prefabricated homes, a two-story colonial, a log cabin, a
split-level, and an A-frame. To help in production planning,
management would like to determine if previous customer
purchases indicate that there is a preference in the style
selected.
The number of homes sold of each model for 100 sales over
the past two years is shown below.
Model Colonial Log Split-Level A-Frame
# Sold 30 20 35 15
Multinomial Distribution Goodness of Fit Test
Hypotheses
H0: pC = pL = pS = pA = .25
Ha: The population proportions are not pC = .25, pL = .25, pS = .25, and p
A
= .25
where:
pC = population proportion that purchase a colonial
pL = population proportion that purchase a log cabin
pS = population proportion that purchase a split-level
pA = population proportion that purchase an A-frame
Multinomial Distribution Goodness of Fit Test
Rejection Rule:
Multinomial Distribution Goodness of Fit Test
Expected Frequencies:
Test Statistic:
Multinomial Distribution Goodness of Fit Test
Conclusion using the p-value approach:
Area in Upper Tail .10 .05 .025 .01 .005
χ 2 Value (df = 3) 6.251 7.815 9.348 11.345 12.838
Chi-Square Goodness of Fit Tests
Let Z be a standard normal distribution (that is ). Then the
random variable Z2 follows a chi-square distribution with 1 degree of
freedom (since Xi is the only random variable and there are no
constraints).
If we have k random variables, namely, X1, X2, …, Xk, then a chi-square
distribution with k-degrees of freedom is given by
Chi-Square Goodness of Fit Tests
• If we replace the population mean μ with sample mean, then the degrees
of freedom will be (k − 1). Even if the population is not normally
distributed, the right-hand side of the equation will follow an approximate
χ2 distribution for a large sample.
• Consider a binomial random variable with parameter p (probability of
success) and number of trials n Then for a large sample, the standardized
random variable in Eq. follows a standard normal distribution (central limit
theorem for proportions):
Chi-Square Goodness of Fit Tests
Note that Substituting this in above eq.,we get
Z2 is given by
Let X2 = n − X1. Then [Link] equivalent to
Chi-Square Goodness of Fit Tests
Note that np and n(1 − p) are the expected values of two categories (success and
failure) of the binomial distribution. The two parts on the right-hand side of Eq.
are of form
Above equation can be generalized to distributions with multiple groups. Thus,
the chi-square statistic for goodness of fit test is given by
where Oij is the observed frequency in category (i, j) and Eij is the expected
frequency in the category (i, j).
Goodness of Fit Test: Multinomial Probability
Distribution
4. Compute the value of the test statistic.
Goodness of Fit Test: Multinomial Probability
Distribution
Rejection Rule: