Teach yourself statistics

Chi-Square Test of Homogeneity

This lesson explains how to conduct a chi-square test of homogeneity . The test is applied to a single categorical variable from two or more different populations. It is used to determine whether frequency counts are distributed identically across different populations.

For example, in a survey of TV viewing preferences, we might ask respondents to identify their favorite program. We might ask the same question of two different populations, such as males and females. We could use a chi-square test for homogeneity to determine whether male viewing preferences differed significantly from female viewing preferences. The sample problem at the end of the lesson considers this example.

When to Use Chi-Square Test for Homogeneity

The test procedure described in this lesson is appropriate when the following conditions are met:

  • For each population, the sampling method is simple random sampling .
  • The variable under study is categorical .
  • If sample data are displayed in a contingency table (Populations x Category levels), the expected frequency count for each cell of the table is at least 5.

This approach consists of four steps: (1) state the hypotheses, (2) formulate an analysis plan, (3) analyze sample data, and (4) interpret results.

State the Hypotheses

Every hypothesis test requires the analyst to state a null hypothesis and an alternative hypothesis . The hypotheses are stated in such a way that they are mutually exclusive. That is, if one is true, the other must be false; and vice versa.

Suppose that data were sampled from r populations, and assume that the categorical variable had c levels. At any specified level of the categorical variable, the null hypothesis states that each population has the same proportion of observations. Thus,

H : P = P = . . . = P
H : P = P = . . . = P
. . .
H : P = P = . . . = P

The alternative hypothesis (H a ) is that at least one of the null hypothesis statements is false.

Formulate an Analysis Plan

The analysis plan describes how to use sample data to accept or reject the null hypothesis. The plan should specify the following elements.

  • Significance level. Often, researchers choose significance levels equal to 0.01, 0.05, or 0.10; but any value between 0 and 1 can be used.
  • Test method. Use the chi-square test for homogeneity to determine whether observed sample frequencies differ significantly from expected frequencies specified in the null hypothesis. The chi-square test for homogeneity is described in the next section.

Analyze Sample Data

Using sample data from the contingency tables, find the degrees of freedom, expected frequency counts, test statistic, and the P-value associated with the test statistic. The analysis described in this section is illustrated in the sample problem at the end of this lesson.

DF = (r - 1) * (c - 1)

E r,c = (n r * n c ) / n

Χ 2 = Σ [ (O r,c - E r,c ) 2 / E r,c ]

  • P-value. The P-value is the probability of observing a sample statistic as extreme as the test statistic. Since the test statistic is a chi-square, use the Chi-Square Distribution Calculator to assess the probability associated with the test statistic. Use the degrees of freedom computed above.

Interpret Results

If the sample findings are unlikely, given the null hypothesis, the researcher rejects the null hypothesis. Typically, this involves comparing the P-value to the significance level , and rejecting the null hypothesis when the P-value is less than the significance level.

Test Your Understanding

In a study of the television viewing habits of children, a developmental psychologist selects a random sample of 300 first graders - 100 boys and 200 girls. Each child is asked which of the following TV programs they like best: The Lone Ranger, Sesame Street, or The Simpsons. Results are shown in the contingency table below.

Viewing Preferences Total
Lone RangerLone
Ranger
Sesame StreetSesame
Street
The SimpsonsThe
Simpsons
Boys 50 30 20 100
Girls 50 80 70 200
Total 100 110 90 300

Do the boys' preferences for these TV programs differ significantly from the girls' preferences? Use a 0.05 level of significance.

The solution to this problem takes four steps: (1) state the hypotheses, (2) formulate an analysis plan, (3) analyze sample data, and (4) interpret results. We work through those steps below:

State the hypotheses. The first step is to state the null hypothesis and an alternative hypothesis.

H : P = P

H : P = P

H : P = P

  • Alternative hypothesis: At least one of the null hypothesis statements is false.
  • Formulate an analysis plan . For this analysis, the significance level is 0.05. Using sample data, we will conduct a chi-square test for homogeneity .

DF = (r - 1) * (c - 1) DF = (r - 1) * (c - 1) = (2 - 1) * (3 - 1) = 2

E r,c = (n r * n c ) / n E 1,1 = (100 * 100) / 300 = 10000/300 = 33.3 E 1,2 = (100 * 110) / 300 = 11000/300 = 36.7 E 1,3 = (100 * 90) / 300 = 9000/300 = 30.0 E 2,1 = (200 * 100) / 300 = 20000/300 = 66.7 E 2,2 = (200 * 110) / 300 = 22000/300 = 73.3 E 2,3 = (200 * 90) / 300 = 18000/300 = 60.0

Χ 2 = Σ[ (O r,c - E r,c ) 2 / E r,c ] Χ 2 = (50 - 33.3) 2 /33.3 + (30 - 36.7) 2 /36.7 + (20 - 30) 2 /30 + (50 - 66.7) 2 /66.7 + (80 - 73.3) 2 /73.3 + (70 - 60) 2 /60 Χ 2 = (16.7) 2 /33.3 + (-6.7) 2 /36.7 + (-10.0) 2 /30 + (-16.7) 2 /66.7 + (3.3) 2 /73.3 + (10) 2 /60 Χ 2 = 8.38 + 1.22 + 3.33 + 4.18 + 0.61 + 1.67 = 19.39

where DF is the degrees of freedom, r is the number of populations, c is the number of levels of the categorical variable, n r is the number of observations from population r , n c is the number of observations from level c of the categorical variable, n is the number of observations in the sample, E r,c is the expected frequency count in population r for level c , and O r,c is the observed frequency count in population r for level c .

The P-value is the probability that a chi-square statistic having 2 degrees of freedom is more extreme than 19.39. We use the Chi-Square Distribution Calculator to find P(Χ 2 > 19.39) = 0.00006.

  • Interpret results . Since the P-value (0.00006) is less than the significance level (0.05), we reject the null hypothesis.

Note: If you use this approach on an exam, you may also want to mention why this approach is appropriate. Specifically, the approach is appropriate because the sampling method was simple random sampling, the variable under study was categorical, and the expected frequency count was at least 5 in each population at each level of the categorical variable.

User Preferences

Content preview.

Arcu felis bibendum ut tristique et egestas quis:

  • Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
  • Duis aute irure dolor in reprehenderit in voluptate
  • Excepteur sint occaecat cupidatat non proident

Keyboard Shortcuts

17.1 - test for homogeneity.

As suggested in the introduction to this lesson, the test for homogeneity is a method, based on the chi-square statistic, for testing whether two or more multinomial distributions are equal. Let's start by trying to get a feel for how our data might "look" if we have two equal multinomial distributions.

Example 17-1 Section  

old main

A university admissions officer was concerned that males and females were accepted at different rates into the four different schools (business, engineering, liberal arts, and science) at her university. She collected the following data on the acceptance of 1200 males and 800 females who applied to the university:

#(Acceptances) Business Engineer Lib Arts Science (FIXED) Total
Male 300 (25%) 240 (20%) 300 (25%) 360 (30%) 1200
Female 200 (25%) 160 (20%) 200 (25%) 240 (30%) 800
Total 500 (25%) 400 (20%) 500 (25%) 600 (30%) 2000

Are males and females distributed equally among the various schools?

Let's start by focusing on the business school. We can see that, of the 1200 males who applied to the university, 300 (or 25%) were accepted into the business school. Of the 800 females who applied to the university, 200 (or 25%) were accepted into the business school. So, the business school looks to be in good shape, as an equal percentage of males and females, namely 25%, were accepted into it.

Now, for the engineering school. We can see that, of the 1200 males who applied to the university, 240 (or 20%) were accepted into the engineering school. Of the 800 females who applied to the university, 160 (or 20%) were accepted into the engineering school. So, the engineering school also looks to be in good shape, as an equal percentage of males and females, namely 20%, were accepted into it.

We probably don't have to drag this out any further. If we look at each column in the table, we see that the proportion of males accepted into each school is the same as the proportion of females accepted into each school... which therefore happens to equal the proportion of students accepted into each school, regardless of gender. Therefore, we can conclude that males and females are distributed equally among the four schools.

Example 17-2 Section  

university campus

#(Acceptances) Business Engineer Lib Arts Science (FIXED) Total
Male 240 (20%) 480 (40%) 120 (10%) 360 (30%) 1200
Female 240 (30%) 80 (10%) 320 (40%) 160 (20%) 800
Total 480 (24%) 560 (28%) 440 (22%) 520 (26%) 2000

Let's again start by focusing on the business school. In this case, of the 1200 males who applied to the university, 240 (or 20%) were accepted into the business school. And, of the 800 females who applied to the university, 240 (or 30%) were accepted into the business school. So, the business school appears to have different rates of acceptance for males and females, 20% compared to 30%.

Now, for the engineering school. We can see that, of the 1200 males who applied to the university, 480 (or 40%) were accepted into the engineering school. Of the 800 females who applied to the university, only 80 (or 10%) were accepted into the engineering school. So, the engineering school also appears to have different rates of acceptance for males and females, 40% compared to 10%.

Again, there's no need drag this out any further. If we look at each column in the table, we see that the proportion of males accepted into each school is different than the proportion of females accepted into each school... and therefore the proportion of students accepted into each school, regardless of gender, is different than the proportion of males and females accepted into each school. Therefore, we can conclude that males and females are not distributed equally among the four schools.

In the context of the two examples above, it quickly becomes apparent that if we wanted to formally test the hypothesis that males and females are distributed equally among the four schools, we'd want to test the hypotheses:

\(H_0 : p_{MB} =p_{FB} \text{ and } p_{ME} =p_{FE} \text{ and } p_{ML} =p_{FL} \text{ and } p_{MS} =p_{FS}\) \(H_A : p_{MB} \ne p_{FB} \text{ or } p_{ME} \ne p_{FE} \text{ or } p_{ML} \ne p_{FL} \text{ or } p_{MS} \ne p_{FS}\)

  • \(p_{Mj}\) is the proportion of males accepted into school j = B , E , L , or S
  • \(p_{Fj}\) is the proportion of females accepted into school j = B , E , L , or S

In conducting such a hypothesis test, we're comparing the proportions of two multinomial distributions. Before we can develop the method for conducting such a hypothesis test, that is, for comparing the proportions of two multinomial distributions, we first need to define some notation.

Notation Section  

hieroglyphics

We'll use what I think most statisticians would consider standard notation, namely that:

  • The letter i will index the h row categories, and
  • The letter j will index the k column categories

(The text reverses the use of the i index and the j index.) That said, let's use the framework of the previous examples to introduce the notation we'll use. That is, rewrite the tables above using the following generic notation:

#(Acc) Bus \(\left(j = 1 \right)\) Eng \(\left(j = 2 \right)\) L Arts \(\left(j = 3 \right)\) Sci \(\left(j = 4 \right)\) (FIXED) Total
M \(\left(i = 1 \right)\) \(y_{11} \left(\hat{p}_{11} \right)\) \(y_{12} \left(\hat{p}_{12} \right)\) \(y_{13} \left(\hat{p}_{13} \right)\) \(y_{14} \left(\hat{p}_{14} \right)\) \(n_{1}=\sum_\limits{j=1}^{k} y_{1 j}\)
F \(\left(i = 2 \right)\) \(y_{21} \left(\hat{p}_{21} \right)\) \(y_{22} \left(\hat{p}_{22} \right)\) \(y_{23} \left(\hat{p}_{23} \right)\) \(y_{24} \left(\hat{p}_{24} \right)\) \(n_{2}=\sum_\limits{j=1}^{k} y_{2 j}\)
Total \(y_{11} + y_{21} \left(\hat{p}_1 \right)\) \(y_{12} + y_{22} \left(\hat{p}_2 \right)\) \(y_{13} + y_{23} \left(\hat{p}_3 \right)\) \(y_{14} + y_{24} \left(\hat{p}_4 \right)\) \(n_1 + n_2\)
  • \(y_{ij}\) denoting the number falling into the \(j^{th}\) category of the \(i^{th}\) sample
  • \(\hat{p}_{ij}=y_{ij}/n_i\)denoting the proportion in the \(i^{th}\) sample falling into the \(j^{th}\) category
  • \(n_i=\sum_{j=1}^{k}y_{ij}\)denoting the total number in the \(i^{th}\) sample
  • \( \hat{p}_{j}=(y_{1j}+y_{2j})/(n_1+n_2) \)denoting the (overall) proportion falling into the \(j^{th}\) category

With the notation defined as such, we are now ready to formulate the chi-square test statistic for testing the equality of two multinomial distributions.

The Chi-Square Test Statistic Section  

The chi-square test statistic for testing the equality of two multinomial distributions:

\(Q=\sum_{i=1}^{2}\sum_{j=1}^{k}\frac{(y_{ij}- n_i\hat{p}_j)^2}{n_i\hat{p}_j}\)

follows an approximate chi-square distribution with k −1 degrees of freedom. Reject the null hypothesis of equal proportions if Q is large, that is, if:

\(Q \ge \chi_{\alpha, k-1}^{2}\)

For the sake of concreteness, let's again use the framework of our example above to derive the chi-square test statistic. For one of the samples, say for the males, we know that:

\(\sum_{j=1}^{k}\frac{(\text{observed }-\text{ expected})^2}{\text{expected}}=\sum_{j=1}^{k}\frac{(y_{1j}- n_1p_{1j})^2}{n_1p_{1j}} \)

follows an approximate chi-square distribution with k −1 degrees of freedom. For the other sample, that is, for the females, we know that:

\(\sum_{j=1}^{k}\frac{(\text{observed }-\text{ expected})^2}{\text{expected}}=\sum_{j=1}^{k}\frac{(y_{2j}- n_2p_{2j})^2}{n_2p_{2j}} \)

follows an approximate chi-square distribution with k −1 degrees of freedom. Therefore, by the independence of two samples, we can "add up the chi-squares," that is:

\(\sum_{i=1}^{2}\sum_{j=1}^{k}\frac{(y_{ij}- n_ip_{ij})^2}{n_ip_{ij}}\)

follows an approximate chi-square distribution with k −1+ k −1 = 2( k −1) degrees of freedom.

Oops.... but we have a problem! The \(p_{ij}\)'s are unknown to us. Of course, we know by now that the solution is to estimate the \(p_{ij}\)'s. Now just how to do that? Well, if the null hypothesis is true, the proportions are equal, that is, if:

\(p_{11}=p_{21}, p_{21}=p_{22}, ... , p_{1k}=p_{2k} \)

we would be best served by using all of the data across the sample categories. That is, the best estimate for each\(j^{th}\) category is the pooled estimate:

\(\hat{p}_j=\frac{y_{1j}+y_{2j}}{n_1+n_2}\)

We also know by now that because we are estimating some paremeters, we have to adjust the degrees of freedom. The pooled estimates \(\hat{p}_j\) estimate the true unknown proportions \(p_{1j} = p_{2j} = p_j\). Now, if we know the first k −1 estimates, that is, if we know:

\(\hat{p}_1, \hat{p}_2, ... , \hat{p}_{k-1}\)

then the \(k^{th}\) one, that is \(\hat{p}_k\), is determined because:

\(\sum_{j=1}^{k}\hat{p}_j=1\)

\(\hat{p}_k=1-(\hat{p}_1+\hat{p}_2+ ... + \hat{p}_{k-1})\)

So, we are estimating k −1 parameters, and therefore we have to subtract k −1 from the degrees of freedom. Doing so, we get that

follows an approximate chi-square distribution with 2( k −1) − ( k −1) = k − 1 degrees of freedom. As was to be proved!

Note Section  

Our only example on this page has involved \(h = 2\) samples. If there are more than two samples, that is, if \(h > 2\), then the definition of the chi-square statistic is appropriately modified. That is:

\(Q=\sum_{i=1}^{h}\sum_{j=1}^{k}\frac{(y_{ij}- n_i\hat{p}_j)^2}{n_i\hat{p}_j}\)

follows an approximate chi-square distribution with \(h(k−1) − (k−1) = (h−1)(k − 1)\) degrees of freedom.

Let's take a look at another example.

Example 17-3 Section  

surgery

The head of a surgery department at a university medical center was concerned that surgical residents in training applied unnecessary blood transfusions at a different rate than the more experienced attending physicians. Therefore, he ordered a study of the 49 Attending Physicians and 71 Residents in Training with privileges at the hospital. For each of the 120 surgeons, the number of blood transfusions prescribed unnecessarily in a one-year period was recorded. Based on the number recorded, a surgeon was identified as either prescribing unnecessary blood transfusions Frequently, Occasionally, Rarely, or Never. Here's a summary table (or " contingency table ") of the resulting data:

Physician Frequent Occasionally Rarely Never Total
Attending 2 (4.1%) 3 (6.1%) 31 (63.3%) 13 (26.5%) 49
Resident 15 (21.1%) 28 (39.4%) 23 (32.4%) 5 (7.0%) 71
Total 17 31 54 18 120

Are attending physicians and residents in training distributed equally among the various unnecessary blood transfusion categories?

We are interested in testing the null hypothesis:

\(H_0 : p_{RF} =p_{AF} \text{ and } p_{RO} =p_{AO} \text{ and } p_{RR} =p_{AR} \text{ and } p_{RN} =p_{AN}\)

against the alternative hypothesis:

\(H_A : p_{RF} \ne p_{AF} \text{ or } p_{RO} \ne p_{AO} \text{ or } p_{RR} \ne p_{AR} \text{ or } p_{RN} \ne p_{AN}\)

The observed data were given to us in the table above. So, the next thing we need to do is find the expected counts for each cell of the table:

Physician Frequent Occasionally Rarely Never Total
Attending         49
Resident         71
Total 17 31 54 18 120

It is in the calculation of the expected values that you can readily see why we have (2−1)(4−1) = 3 degrees of freedom in this case. That's because, we only have to calculate three of the cells directly.

Physician Frequent Occasionally Rarely Never Total
Attending 6.942 12.658 22.05   49
Resident         71
Total 17 31 54 18 120

Once we do that, the remaining five cells can be calculated by way of subtraction:

Physician Frequent Occasionally Rarely Never Total
Attending 6.942 12.658 22.05 7.35 49
Resident 10.058 18.342 31.95 10.65 71
Total 17 31 54 18 120

Now that we have the observed and expected counts, calculating the chi-square statistic is a straightforward exercise:

\(Q=\frac{(2-6.942)^2}{6.942}+ ... +\frac{(5-10.65)^2}{10.65} =31.88 \)

The chi-square test tells us to reject the null hypothesis, at the 0.05 level, if Q is greater than a chi-square random variable with 3 degrees of freedom, that is, if \(Q > 7.815\). Because \(Q = 31.88 > 7.815\), we reject the null hypothesis. There is sufficient evidence at the 0.05 level to conclude that the distribution of unnecessary transfusions differs among attending physicians and residents.

Minitab 18

Minitab ®

Using minitab section  .

  • Enter the data (in the inside of the frequency table only) into the columns of the worksheet
  • Select Stat >> Tables >> Chi-square test

then you'll get typical chi-square test output that looks something like this:

Chi-Square Test: Freq, Occ, Rare, Never
Expected counts are printed below observed counts
  Freq Occ Rare Never Total
1  2
6.94
3
12.66
31
22.05
13
7.35
49
2  15
10.06
28
18.34
23
31.95
5
10.65
71
Total 17 31 54 18 120

Chi- sq = 3.518 + 7.369 + 3.633 + 4.343 +

                2.428 + 5.086 + 2.507 + 2.997 = 31.881

DF = 3, P-Value = 0.000

Test of Homogeneity, Chi-Square

  • Reference work entry
  • Cite this reference work entry

null and alternative hypothesis for chi square test for homogeneity

3134 Accesses

1 Citations

A test of homogeneity compares the proportions of responses from two or more populations with regards to a dichotomous variable (e. g., male/female, yes/no) or variable with more than two outcome categories . The chi-square test of homogeneity is the nonparametric test used in a situation where the dependent variable is categorical. Data can be presented using a  contingency table in which populations and categories of the variable are the row and column labels. The null hypothesis states that all populations are homogeneous regarding the proportions of categories of categorical variable. If the null hypothesis is rejected, it is concluded that the above proportions are different in the observed populations. The chi-square test of homogeneity statistic is computed in exactly the same manner as chi-square test of independence statistic. The difference between these two tests consists of stating the null hypothesis, the underlying logic, and the sampling procedures.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

  • Get 10 units per month
  • Download Article/Chapter or Ebook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Editor information

Editors and affiliations.

Network EUROlifestyle Research Association Public Health Saxony-Saxony Anhalt e.V. Medical Faculty, University of Technology, Fiedlerstr. 27, 01307, Dresden, Germany

Wilhelm Kirch ( Professor Dr. Dr. ) ( Professor Dr. Dr. )

Rights and permissions

Reprints and permissions

Copyright information

© 2008 Springer-Verlag

About this entry

Cite this entry.

(2008). Test of Homogeneity, Chi-Square . In: Kirch, W. (eds) Encyclopedia of Public Health. Springer, Dordrecht. https://doi.org/10.1007/978-1-4020-5614-7_3475

Download citation

DOI : https://doi.org/10.1007/978-1-4020-5614-7_3475

Publisher Name : Springer, Dordrecht

Print ISBN : 978-1-4020-5613-0

Online ISBN : 978-1-4020-5614-7

eBook Packages : Medicine Reference Module Medicine

Share this entry

Anyone you share the following link with will be able to read this content:

Sorry, a shareable link is not currently available for this article.

Provided by the Springer Nature SharedIt content-sharing initiative

  • Publish with us

Policies and ethics

  • Find a journal
  • Track your research

logo

  • I'm a Teacher
  • I'm a Student
  • High School/AP Statistics Resources
  • College Statistics Resources
  • R Help Pages
  • Advanced High School Statistics
  • CK-12 Probability and Statistics
  • OpenIntro Statistics
  • Introductory Statistics with Randomization and Simulation
  • Introductory Statistics
  • Introduction to Statistics
  • Using R for Introductory Statistics
  • Introduction to Probability and Statistics Using R

Chi-Square - Test for Homogeneity

A chi-square test for homogeneity is a test to see if different distributions are similar to each other.

1. Define your hypotheses

H o : The distributions are the same among all the given populations.    

H a : The distributions differ among all the given populations.

2. Find the expected counts:

For each cell, multiply the sum of the column it is in and the sum of the row it is in, and then divide by the total in all cells, or the sample size (row total)(column total)sample size

Example Problem:

A company wants to examine the homogeneity of auto types purchased among three states. Is there sufficient evidence that the auto types purchased among the three states is different? The data is below.

 

California

Massachusetts

Georgia

Car

90

97

61

SUV

81

92

54

Define your hypotheses

Ho: The distributions of auto types purchased is the same for all three states.

HA:The distributions of auto types purchased differs among all three states.

Find expected counts

For each cell, multiply the sum of the column it is in and the sum of the row it is in, and then divide by the total in all cells (row total)(column total)sample size  

Sample Calculations:

California column subtotal: 90+81=171

Car row subtotal: 90+97+61=248 Total: 90+97+61+81+92+54=475

First cell’s expected count: (171)(248)/475=89.28 (repeat for all other columns)  

OBSERVED / EXPECTED

 

California

Massachusetts

Georgia

Row Total

Car

90 / 89.28

97 / 98.67

61 / 60.04

248

SUV

81 / 81.72

92 / 91.32

54 / 54.96

227

Column Total

171

189

115

Total: 475

*Note: do not round the number of expected counts

Check conditions

Data are counts ✓

N10n (the population size is at least 10x greater than the sample size) ✓

N10(475) → assumed

All of the expected counts are at least 5 ✓  

Find the chi-square statistic

Use 2=(observed-expected)2expected 2=(90-89.28)289.28+(97-98.67)298.67+(61-60.04)260.04+(81-81.72)281.72+(92-91.32)291.32+(54-54.96)254.96= 0.078  

Find the degrees of freedom

Degrees of freedom (df) = (# of rows - 1)(# of columns - 1) (2-1)(3-1) = 2

Find the p-value

tTAB 2 CONTENT HERE

Use your calculator DISTR [8]2cdf(

TI-83: 2cdf (chi-square value, any large number, df) 2cdf (0.078, e^99, 2)   → p-value=0.95

TI-84: lower: 0.078 upper: 9999 df: 2 p-value=0.95  

Generate your conclusion

I calculated a p-value of 0.95, which is greater than the assumed significance level of 0.05. Therefore, I fail to reject the null hypothesis, and the data does not support the claim that the distribution of auto types purchased differs among all three states.

Chi Squared Test of Homogeneity 

Introduction

The Chi Squared Test of Homogeneity is very similar to the Chi Squared Test of Association except that the data comes from simple random samples taken from multiple separate populations. 

You want to determine if there is any  difference in distributions among political affiliation as it applies to gun control. You take separate samples of the Democrat population, Independent population, and Republican population. The data is shown below. 

  Democrat Independent Republican
Yes 20 20 5
No 10 18 30

Step 1 : Name Test: Chi-Squared Test of Homogeneity

Step 2 :  Define Test:

H o : There is no difference in distributions among political affiliation as it applies to gun control.

H A : There is a difference in distributions among political affiliation as it applies to gun control. 

Step 3 : Assume  H 0  is true and define its normal distribution. Then check for specific  conditions  which vary depending on the type of hypothesis test. 

1. Data from multiple independent random samples

2. N 1  > 10n 1  .... N k  > 10n k  (k = # of populations)

3. All expected counts greater than 5

Step 4 : Using the normal distribution, calculate the test statistics and p-value.

To solve for X 2  use the EXACT SAME process used to solve for the test of association!

Don't forget to state your conclusion afterward.




The is evalauting the equality of several populations of categorical data. The test asked whether 3 or more
populations are equal with respect to some characteritics.

The homogeneity chi-square test statistics is computed exactly the same as the test for independence using as 
when determining the independence of charateristics chi-square statistics.

The between the test for test is the stating of the null hypothesis:

Homogeneity tests a null hypothesis asserting that various populations are homogeneous or equal with respect to some charateristics 
of interest against an alternate hypothesis claiming that they are not.

If 

An ads agency wishes to determine if there are any differences with respect to reader recall among 3 kinds magazine ads. 
One ad is the second is quite and the third is a pictorial of competing brands. Appropriate random
sampling, response validations are taken and conducted to determine how well partiscipants remembered each ads on a national / regional 
level. Those partiscipants selecting the correct ad are labeled as and those unable to select the correct ads are labeled 
.
 

 
25 10 7
73 93 108
Early a.m. Late a.m. Early p.m. Late p.m.
Number for coffee 3 5 8 11
Number for other 52 48 51 47

Module 11: Chi-Square Tests

Test of homogeneity, learning outcomes.

  • Conduct a chi-square test of homogeneity. Interpret the conclusion in context.

We have learned the details for two chi-square tests, the goodness-of-fit test, and the test of independence. Now we focus on the third and last chi-square test that we will learn, the test for homogeneity . This test determines if two or more populations (or subgroups of a population) have the same distribution of a single categorical variable.

The test of homogeneity expands the test for a difference in two population proportions, which is the two-proportion Z-test we learned in Inference for Two Proportions . We use the two-proportion Z-test when the response variable has only two outcome categories and we are comparing two populations (or two subgroups.) We use the test of homogeneity if the response variable has two or more categories and we wish to compare two or more populations (or subgroups.)

We can answer the following research questions with a chi-square test of homogeneity:

  • Does the use of steroids in collegiate athletics differ across the three NCAA divisions?
  • Was the distribution of political views (liberal, moderate, conservative) different for last three presidential elections in the United States?

The null hypothesis states that the distribution of the categorical variable is the same for the populations (or subgroups). In other words, the proportion with a given response is the same in all of the populations, and this is true for all response categories. The alternative hypothesis says that the distributions differ.

Note: Homogeneous means the same in structure or composition. This test gets its name from the null hypothesis, where we claim that the distribution of the responses are the same (homogeneous) across groups.

To test our hypotheses, we select a random sample from each population and gather data on one categorical variable. As with all chi-square tests, the expected counts reflect the null hypothesis. We must determine what we expect to see in each sample if the distributions are identical. As before, the chi-square test statistic measures the amount that the observed counts in the samples deviate from the expected counts.

Steroid Use in Collegiate Sports

In 2006, the NCAA published a report called “Substance Use: NCAA Study of Substance Use of College Student-Athletes.” We use data from this report to investigate the following question: Does steroid use by student athletes differ for the three NCAA divisions?

The data comes from a random selection of teams in each NCAA division. The sampling plan was somewhat complex, but we can view the data as though it came from a random sample of athletes in each division. The surveys are anonymous to encourage truthful responses.

To see the NCAA report on substance use, click here .

Step 1: State the hypotheses.

In the test of homogeneity, the null hypothesis says that the distribution of a categorical response variable is the same in each population. In this example, the categorical response variable is steroid use (yes or no). The populations are the three NCAA divisions.

  • H 0 : The proportion of athletes using steroids is the same in each of the three NCAA divisions.
  • H a : The proportion of athletes using steroids is not same in each of the three NCAA divisions.

Note: These hypotheses imply that the proportion of athletes not using steroids is also the same in each of the three NCAA divisions, so we don’t need to state this explicitly. For example, if 2% of the athletes in each division are using steroids, then 98% are not.

Here is an alternative way we could state the hypotheses for a test of homogeneity.

  • H 0 : For each of the three NCAA divisions, the distribution of “yes” and “no” responses to the question about steroid use is the same.
  • H a : The distribution of responses is not the same.

Step 2: Collect and analyze the data.

We summarized the data from these three samples in a two-way table.

Admit Steroid Use
Yes No Totals
Division I 103 8,440 8,543
Division II 52 4,289 4,341
Division III 65 6,428 6,493
Totals 220 19,157 19,377

We use percentages to compare the distributions of yes and no responses in the three samples. This step is similar to our data analysis for the test of independence.

Admit Steroid Use
Yes No Totals
Division I 103/8,453 (1.206%) 8,440/8,453 (98.794%) 8,543/8,453 (100%)
Division II 52/4,341 (1.198%) 4,289/4,341 (98.802%) 4,341/4,341 (100%)
Division III 65/6,493 (1.001%) 6,428/6,493 (98.999%) 6,493/6,493 (100%)
Totals 220/19,377 (1.135%) 19,157/19,377 (98.865%) 19,377/19,377 (100%)

We can see that Division I and Division II schools have essentially the same percentage of athletes who admit steroid use (about 1.2%). Not surprisingly, the least competitive division, Division III, has a slightly lower percentage (about 1.0%). Do these results suggest that the proportion of athletes using steroids is the same for the three divisions? Or is the difference seen in the sample of Division III schools large enough to suggest differences in the divisions? After all, the sample sizes are very large. We know that for large samples, a small difference can be statistically significant. Of course, we have to conduct the test of homogeneity to find out.

Note: We decided not to use ribbon charts for visual comparison of the three distributions because the percentage admitting steroid use is too small in each sample to be visible.

Step 3: Assess the evidence.

We need to determine the expected values and the chi-square test statistic so that we can find the P-value.

Calculating Expected Values for a Test of Homogeneity

Expected counts always describe what we expect to see in a sample if the null hypothesis is true. In this situation, we expect the percentage using steroids to be the same for each division. What percentage do we use? We find the percentage using steroids in the combined samples. This calculation is the same as we did when finding expected counts for a test of independence, though the logic of the calculation is subtly different.

Admit Steroid Use
Yes No Totals
Division I 96.96 8,446.04 8,543
Division II 49.27 4,291.73 4,341
Division III 73.70 6,419.30 6,493
Totals 220 19,157 19,377

Here are the calculations for the response “yes”:

  • Percentage using steroids in combined samples: 220/19,377 = 0.01135 = 1.135%

Expected count of steroid users for Division I is 1.135% of Division I sample:

  • 0.01135(8,543) = 96.96

Expected count of steroid users for Division II is 1.135% of Division II sample:

  • 0.01135(4,341) = 49.27

Expected count of steroid users for Division III is 1.135% of Division III sample:

  • 0.01135(6,493) = 73.70

Checking Conditions

The conditions for use of the chi-square distribution are the same as we learned previously:

  • A sample is randomly selected from each population.
  • All of the expected counts are 5 or greater.

Since this data meets the conditions, we can proceed with calculating the χ 2 test statistic.

Calculating the Chi-Square Test Statistic

There are no changes in the way we calculate the chi-square test statistic.

[latex]{\chi }^{2}\text{}=\text{}∑\frac{{(\mathrm{observed}-\mathrm{expected})}^{2}}{\mathrm{expected}}[/latex]

We use technology to calculate the chi-square value. For this example, we show the calculation. There are six terms, one for each cell in the 3 × 2 table. (We ignore the totals, as always.)

Chi-squared = (130-96.96)^2/96.96 + (52-49.27)^2/49.27 + (65-73.70)^2/73.70 + (8440-8446.04)^2/8446.04 + (4289-4291.73)^2/4291.73 + (6428-6419.30)^2/6419.30 = 1.57

Finding Degrees of Freedom and the P-Value

For chi-square tests based on two-way tables (both the test of independence and the test of homogeneity), the degrees of freedom are ( r − 1)( c − 1), where r is the number of rows and c is the number of columns in the two-way table (not counting row and column totals). In this case, the degrees of freedom are (3 − 1)(2 − 1) = 2.

We use the chi-square distribution with df = 2 to find the P-value. The P-value is large (0.4561), so we fail to reject the null hypothesis.

Chi-squared distribution with 2 degrees of freedom. A value of 1.57 is marked on the x-axis, and everything to the right of that value is shaded. The p-value is 0.4561.

Step 4: Conclusion.

The data does not provide strong enough evidence to conclude that steroid use differs in the three NCAA divisions (P-value = 0.4561).

First Use of Anabolic Steroids by NCAA Athletes

The NCAA survey includes this question: “When, if ever, did you start using anabolic steroids?” The response options are: have never used, before junior high, junior high, high school, freshman year of college, after freshman year of college. We focused on those who admitted use of steroids and compared the distribution of their responses for the years 1997, 2001, and 2005. (These are the years that the NCAA conducted the survey. Counts are estimates from reported percentages and sample size.) Recall that the NCAA uses random sampling in its sampling design.

Initial Use of Anabolic Steroids
1997 2001 2005 Totals
Junior high or before 16 15 69 100
High school 15 42 156 213
During freshman year of college 12 17 65 94
After freshman year of college 18 26 107 151
Totals 61 100 397 558

Use this simulation to answer the questions below.

We now know the details for the chi-square test for homogeneity. We conclude with two activities that will give you practice recognizing when to use this test.

Gender and Politics

Consider these two situations:

  • A: Liberal, moderate, or conservative: Are there differences in political views of men and women in the United States? We survey a random sample of 100 U.S. men and 100 U.S. women.
  • B: Do you plan to vote in the next presidential election? We ask a random sample of 100 U.S. men and 100 U.S. women. We look for differences in the proportion of men and women planning to vote.

Steroid Use for Male Athletes in NCAA Sports

We plan to compare steroid use for male athletes in NCAA baseball, basketball, and football. We design two different sampling plans.

  • A: Survey distinct random samples of NCAA athletes from each sport: 500 baseball players, 400 basketball players, 900 football players.
  • B. Survey a random sample of 1,800 NCAA male athletes and categorize players by sport and admitted steroid use. Responses are anonymous.

Let’s Summarize

In “Chi-Square Tests for Two-Way Tables,” we discussed two different hypothesis tests using the chi-square test statistic:

  • Test of independence for a two-way table
  • Test of homogeneity for a two-way table

Test of Independence for a Two-Way Table

  • In the test of independence, we consider one population and two categorical variables.
  • In Probability and Probability Distribution , we learned that two events are independent if P ( A | B ) = P ( A ), but we did not pay attention to variability in the sample. With the chi-square test of independence, we have a method for deciding whether our observed P ( A | B ) is “too far” from our observed P ( A ) to infer independence in the population.
  • The null hypothesis says the two variables are independent (or not associated). The alternative hypothesis says the two variables are dependent (or associated).
  • To test our hypotheses, we select a single random sample and gather data for two different categorical variables.
  • Example: Do men and women differ in their perception of their weight? Select a random sample of adults. Ask them two questions: (1) Are you male or female? (2) Do you feel that you are overweight, underweight, or about right in weight?

Test of Homogeneity for a Two-Way Table

  • In the test of homogeneity, we consider two or more populations (or two or more subgroups of a population) and a single categorical variable.
  • The test of homogeneity expands on the test for a difference in two population proportions that we learned in Inference for Two Proportions by comparing the distribution of the categorical variable across multiple groups or populations.
  • The null hypothesis says that the distribution of proportions for all categories is the same in each group or population. The alternative hypothesis says that the distributions differ.
  • To test our hypotheses, we select a random sample from each population or subgroup independently. We gather data for one categorical variable.
  • Example: Is the rate of steroid use different for different men’s collegiate sports (baseball, basketball, football, tennis, track/field)? Randomly select a sample of athletes from each sport and ask them anonymously if they use steroids.

The difference between these two tests is subtle. They differ primarily in study design. In the test of independence, we select individuals at random from a population and record data for two categorical variables. The null hypothesis says that the variables are independent. In the test of homogeneity, we select random samples from each subgroup or population separately and collect data on a single categorical variable. The null hypothesis says that the distribution of the categorical variable is the same for each subgroup or population.

Both tests use the same chi-square test statistic.

Chi-Square Test Statistic and Distribution

For all chi-square tests, the chi-square test statistic χ 2 is the same. It measures how far the observed data are from the null hypothesis by comparing observed counts and expected counts. Expected counts are the counts we expect to see if the null hypothesis is true.

The chi-square model is a family of curves that depend on degrees of freedom. For a two-way table, the degrees of freedom equals ( r − 1)( c − 1). All chi-square curves are skewed to the right with a mean equal to the degrees of freedom.

A chi-square model is a good fit for the distribution of the chi-square test statistic only if the following conditions are met:

  • The sample is randomly selected.
  • All expected counts are 5 or greater.

If these conditions are met, we use the chi-square distribution to find the P-value. We use the same logic that we have used in all hypothesis tests to draw a conclusion based on the P-value. If the P-value is at least as small as the significance level, we reject the null hypothesis and accept the alternative hypothesis. The P-value is the likelihood that results from random samples have a χ 2 value equal to or greater than that calculated from the data if the null hypothesis is true.

Contribute!

Improve this page Learn More

  • Concepts in Statistics. Provided by : Open Learning Initiative. Located at : http://oli.cmu.edu . License : CC BY: Attribution

Footer Logo Lumen Waymaker

Study.com

In order to continue enjoying our site, we ask that you confirm your identity as a human. Thank you very much for your cooperation.

Hypothesis Testing - Chi Squared Test

Lisa Sullivan, PhD

Professor of Biostatistics

Boston University School of Public Health

Introductory word scramble

Introduction

This module will continue the discussion of hypothesis testing, where a specific statement or hypothesis is generated about a population parameter, and sample statistics are used to assess the likelihood that the hypothesis is true. The hypothesis is based on available information and the investigator's belief about the population parameters. The specific tests considered here are called chi-square tests and are appropriate when the outcome is discrete (dichotomous, ordinal or categorical). For example, in some clinical trials the outcome is a classification such as hypertensive, pre-hypertensive or normotensive. We could use the same classification in an observational study such as the Framingham Heart Study to compare men and women in terms of their blood pressure status - again using the classification of hypertensive, pre-hypertensive or normotensive status.  

The technique to analyze a discrete outcome uses what is called a chi-square test. Specifically, the test statistic follows a chi-square probability distribution. We will consider chi-square tests here with one, two and more than two independent comparison groups.

Learning Objectives

After completing this module, the student will be able to:

  • Perform chi-square tests by hand
  • Appropriately interpret results of chi-square tests
  • Identify the appropriate hypothesis testing procedure based on type of outcome variable and number of samples

Tests with One Sample, Discrete Outcome

Here we consider hypothesis testing with a discrete outcome variable in a single population. Discrete variables are variables that take on more than two distinct responses or categories and the responses can be ordered or unordered (i.e., the outcome can be ordinal or categorical). The procedure we describe here can be used for dichotomous (exactly 2 response options), ordinal or categorical discrete outcomes and the objective is to compare the distribution of responses, or the proportions of participants in each response category, to a known distribution. The known distribution is derived from another study or report and it is again important in setting up the hypotheses that the comparator distribution specified in the null hypothesis is a fair comparison. The comparator is sometimes called an external or a historical control.   

In one sample tests for a discrete outcome, we set up our hypotheses against an appropriate comparator. We select a sample and compute descriptive statistics on the sample data. Specifically, we compute the sample size (n) and the proportions of participants in each response

Test Statistic for Testing H 0 : p 1 = p 10 , p 2 = p 20 , ..., p k = p k0

We find the critical value in a table of probabilities for the chi-square distribution with degrees of freedom (df) = k-1. In the test statistic, O = observed frequency and E=expected frequency in each of the response categories. The observed frequencies are those observed in the sample and the expected frequencies are computed as described below. χ 2 (chi-square) is another probability distribution and ranges from 0 to ∞. The test above statistic formula above is appropriate for large samples, defined as expected frequencies of at least 5 in each of the response categories.  

When we conduct a χ 2 test, we compare the observed frequencies in each response category to the frequencies we would expect if the null hypothesis were true. These expected frequencies are determined by allocating the sample to the response categories according to the distribution specified in H 0 . This is done by multiplying the observed sample size (n) by the proportions specified in the null hypothesis (p 10 , p 20 , ..., p k0 ). To ensure that the sample size is appropriate for the use of the test statistic above, we need to ensure that the following: min(np 10 , n p 20 , ..., n p k0 ) > 5.  

The test of hypothesis with a discrete outcome measured in a single sample, where the goal is to assess whether the distribution of responses follows a known distribution, is called the χ 2 goodness-of-fit test. As the name indicates, the idea is to assess whether the pattern or distribution of responses in the sample "fits" a specified population (external or historical) distribution. In the next example we illustrate the test. As we work through the example, we provide additional details related to the use of this new test statistic.  

A University conducted a survey of its recent graduates to collect demographic and health information for future planning purposes as well as to assess students' satisfaction with their undergraduate experiences. The survey revealed that a substantial proportion of students were not engaging in regular exercise, many felt their nutrition was poor and a substantial number were smoking. In response to a question on regular exercise, 60% of all graduates reported getting no regular exercise, 25% reported exercising sporadically and 15% reported exercising regularly as undergraduates. The next year the University launched a health promotion campaign on campus in an attempt to increase health behaviors among undergraduates. The program included modules on exercise, nutrition and smoking cessation. To evaluate the impact of the program, the University again surveyed graduates and asked the same questions. The survey was completed by 470 graduates and the following data were collected on the exercise question:

 

Number of Students

255

125

90

470

Based on the data, is there evidence of a shift in the distribution of responses to the exercise question following the implementation of the health promotion campaign on campus? Run the test at a 5% level of significance.

In this example, we have one sample and a discrete (ordinal) outcome variable (with three response options). We specifically want to compare the distribution of responses in the sample to the distribution reported the previous year (i.e., 60%, 25%, 15% reporting no, sporadic and regular exercise, respectively). We now run the test using the five-step approach.  

  • Step 1. Set up hypotheses and determine level of significance.

The null hypothesis again represents the "no change" or "no difference" situation. If the health promotion campaign has no impact then we expect the distribution of responses to the exercise question to be the same as that measured prior to the implementation of the program.

H 0 : p 1 =0.60, p 2 =0.25, p 3 =0.15,  or equivalently H 0 : Distribution of responses is 0.60, 0.25, 0.15  

H 1 :   H 0 is false.          α =0.05

Notice that the research hypothesis is written in words rather than in symbols. The research hypothesis as stated captures any difference in the distribution of responses from that specified in the null hypothesis. We do not specify a specific alternative distribution, instead we are testing whether the sample data "fit" the distribution in H 0 or not. With the χ 2 goodness-of-fit test there is no upper or lower tailed version of the test.

  • Step 2. Select the appropriate test statistic.  

The test statistic is:

We must first assess whether the sample size is adequate. Specifically, we need to check min(np 0 , np 1, ..., n p k ) > 5. The sample size here is n=470 and the proportions specified in the null hypothesis are 0.60, 0.25 and 0.15. Thus, min( 470(0.65), 470(0.25), 470(0.15))=min(282, 117.5, 70.5)=70.5. The sample size is more than adequate so the formula can be used.

  • Step 3. Set up decision rule.  

The decision rule for the χ 2 test depends on the level of significance and the degrees of freedom, defined as degrees of freedom (df) = k-1 (where k is the number of response categories). If the null hypothesis is true, the observed and expected frequencies will be close in value and the χ 2 statistic will be close to zero. If the null hypothesis is false, then the χ 2 statistic will be large. Critical values can be found in a table of probabilities for the χ 2 distribution. Here we have df=k-1=3-1=2 and a 5% level of significance. The appropriate critical value is 5.99, and the decision rule is as follows: Reject H 0 if χ 2 > 5.99.

  • Step 4. Compute the test statistic.  

We now compute the expected frequencies using the sample size and the proportions specified in the null hypothesis. We then substitute the sample data (observed frequencies) and the expected frequencies into the formula for the test statistic identified in Step 2. The computations can be organized as follows.

   

255

125

90

470

470(0.60)

=282

470(0.25)

=117.5

470(0.15)

=70.5

470

Notice that the expected frequencies are taken to one decimal place and that the sum of the observed frequencies is equal to the sum of the expected frequencies. The test statistic is computed as follows:

  • Step 5. Conclusion.  

We reject H 0 because 8.46 > 5.99. We have statistically significant evidence at α=0.05 to show that H 0 is false, or that the distribution of responses is not 0.60, 0.25, 0.15.  The p-value is p < 0.005.  

In the χ 2 goodness-of-fit test, we conclude that either the distribution specified in H 0 is false (when we reject H 0 ) or that we do not have sufficient evidence to show that the distribution specified in H 0 is false (when we fail to reject H 0 ). Here, we reject H 0 and concluded that the distribution of responses to the exercise question following the implementation of the health promotion campaign was not the same as the distribution prior. The test itself does not provide details of how the distribution has shifted. A comparison of the observed and expected frequencies will provide some insight into the shift (when the null hypothesis is rejected). Does it appear that the health promotion campaign was effective?  

Consider the following: 

 

255

125

90

470

282

117.5

70.5

470

If the null hypothesis were true (i.e., no change from the prior year) we would have expected more students to fall in the "No Regular Exercise" category and fewer in the "Regular Exercise" categories. In the sample, 255/470 = 54% reported no regular exercise and 90/470=19% reported regular exercise. Thus, there is a shift toward more regular exercise following the implementation of the health promotion campaign. There is evidence of a statistical difference, is this a meaningful difference? Is there room for improvement?

The National Center for Health Statistics (NCHS) provided data on the distribution of weight (in categories) among Americans in 2002. The distribution was based on specific values of body mass index (BMI) computed as weight in kilograms over height in meters squared. Underweight was defined as BMI< 18.5, Normal weight as BMI between 18.5 and 24.9, overweight as BMI between 25 and 29.9 and obese as BMI of 30 or greater. Americans in 2002 were distributed as follows: 2% Underweight, 39% Normal Weight, 36% Overweight, and 23% Obese. Suppose we want to assess whether the distribution of BMI is different in the Framingham Offspring sample. Using data from the n=3,326 participants who attended the seventh examination of the Offspring in the Framingham Heart Study we created the BMI categories as defined and observed the following:

 

30

20

932

1374

1000

3326

  • Step 1.  Set up hypotheses and determine level of significance.

H 0 : p 1 =0.02, p 2 =0.39, p 3 =0.36, p 4 =0.23     or equivalently

H 0 : Distribution of responses is 0.02, 0.39, 0.36, 0.23

H 1 :   H 0 is false.        α=0.05

The formula for the test statistic is:

We must assess whether the sample size is adequate. Specifically, we need to check min(np 0 , np 1, ..., n p k ) > 5. The sample size here is n=3,326 and the proportions specified in the null hypothesis are 0.02, 0.39, 0.36 and 0.23. Thus, min( 3326(0.02), 3326(0.39), 3326(0.36), 3326(0.23))=min(66.5, 1297.1, 1197.4, 765.0)=66.5. The sample size is more than adequate, so the formula can be used.

Here we have df=k-1=4-1=3 and a 5% level of significance. The appropriate critical value is 7.81 and the decision rule is as follows: Reject H 0 if χ 2 > 7.81.

We now compute the expected frequencies using the sample size and the proportions specified in the null hypothesis. We then substitute the sample data (observed frequencies) into the formula for the test statistic identified in Step 2. We organize the computations in the following table.

 

30

20

932

1374

1000

3326

66.5

1297.1

1197.4

765.0

3326

The test statistic is computed as follows:

We reject H 0 because 233.53 > 7.81. We have statistically significant evidence at α=0.05 to show that H 0 is false or that the distribution of BMI in Framingham is different from the national data reported in 2002, p < 0.005.  

Again, the χ 2   goodness-of-fit test allows us to assess whether the distribution of responses "fits" a specified distribution. Here we show that the distribution of BMI in the Framingham Offspring Study is different from the national distribution. To understand the nature of the difference we can compare observed and expected frequencies or observed and expected proportions (or percentages). The frequencies are large because of the large sample size, the observed percentages of patients in the Framingham sample are as follows: 0.6% underweight, 28% normal weight, 41% overweight and 30% obese. In the Framingham Offspring sample there are higher percentages of overweight and obese persons (41% and 30% in Framingham as compared to 36% and 23% in the national data), and lower proportions of underweight and normal weight persons (0.6% and 28% in Framingham as compared to 2% and 39% in the national data). Are these meaningful differences?

In the module on hypothesis testing for means and proportions, we discussed hypothesis testing applications with a dichotomous outcome variable in a single population. We presented a test using a test statistic Z to test whether an observed (sample) proportion differed significantly from a historical or external comparator. The chi-square goodness-of-fit test can also be used with a dichotomous outcome and the results are mathematically equivalent.  

In the prior module, we considered the following example. Here we show the equivalence to the chi-square goodness-of-fit test.

The NCHS report indicated that in 2002, 75% of children aged 2 to 17 saw a dentist in the past year. An investigator wants to assess whether use of dental services is similar in children living in the city of Boston. A sample of 125 children aged 2 to 17 living in Boston are surveyed and 64 reported seeing a dentist over the past 12 months. Is there a significant difference in use of dental services between children living in Boston and the national data?

We presented the following approach to the test using a Z statistic. 

  • Step 1. Set up hypotheses and determine level of significance

H 0 : p = 0.75

H 1 : p ≠ 0.75                               α=0.05

We must first check that the sample size is adequate. Specifically, we need to check min(np 0 , n(1-p 0 )) = min( 125(0.75), 125(1-0.75))=min(94, 31)=31. The sample size is more than adequate so the following formula can be used

This is a two-tailed test, using a Z statistic and a 5% level of significance. Reject H 0 if Z < -1.960 or if Z > 1.960.

We now substitute the sample data into the formula for the test statistic identified in Step 2. The sample proportion is:

null and alternative hypothesis for chi square test for homogeneity

We reject H 0 because -6.15 < -1.960. We have statistically significant evidence at a =0.05 to show that there is a statistically significant difference in the use of dental service by children living in Boston as compared to the national data. (p < 0.0001).  

We now conduct the same test using the chi-square goodness-of-fit test. First, we summarize our sample data as follows:

 

Saw a Dentist

in Past 12 Months

Did Not See a Dentist

in Past 12 Months

Total

# of Participants

64

61

125

H 0 : p 1 =0.75, p 2 =0.25     or equivalently H 0 : Distribution of responses is 0.75, 0.25 

We must assess whether the sample size is adequate. Specifically, we need to check min(np 0 , np 1, ...,np k >) > 5. The sample size here is n=125 and the proportions specified in the null hypothesis are 0.75, 0.25. Thus, min( 125(0.75), 125(0.25))=min(93.75, 31.25)=31.25. The sample size is more than adequate so the formula can be used.

Here we have df=k-1=2-1=1 and a 5% level of significance. The appropriate critical value is 3.84, and the decision rule is as follows: Reject H 0 if χ 2 > 3.84. (Note that 1.96 2 = 3.84, where 1.96 was the critical value used in the Z test for proportions shown above.)

 

64

61

125

93.75

31.25

125

(Note that (-6.15) 2 = 37.8, where -6.15 was the value of the Z statistic in the test for proportions shown above.)

We reject H 0 because 37.8 > 3.84. We have statistically significant evidence at α=0.05 to show that there is a statistically significant difference in the use of dental service by children living in Boston as compared to the national data.  (p < 0.0001). This is the same conclusion we reached when we conducted the test using the Z test above. With a dichotomous outcome, Z 2 = χ 2 !   In statistics, there are often several approaches that can be used to test hypotheses. 

Tests for Two or More Independent Samples, Discrete Outcome

Here we extend that application of the chi-square test to the case with two or more independent comparison groups. Specifically, the outcome of interest is discrete with two or more responses and the responses can be ordered or unordered (i.e., the outcome can be dichotomous, ordinal or categorical). We now consider the situation where there are two or more independent comparison groups and the goal of the analysis is to compare the distribution of responses to the discrete outcome variable among several independent comparison groups.  

The test is called the χ 2 test of independence and the null hypothesis is that there is no difference in the distribution of responses to the outcome across comparison groups. This is often stated as follows: The outcome variable and the grouping variable (e.g., the comparison treatments or comparison groups) are independent (hence the name of the test). Independence here implies homogeneity in the distribution of the outcome among comparison groups.    

The null hypothesis in the χ 2 test of independence is often stated in words as: H 0 : The distribution of the outcome is independent of the groups. The alternative or research hypothesis is that there is a difference in the distribution of responses to the outcome variable among the comparison groups (i.e., that the distribution of responses "depends" on the group). In order to test the hypothesis, we measure the discrete outcome variable in each participant in each comparison group. The data of interest are the observed frequencies (or number of participants in each response category in each group). The formula for the test statistic for the χ 2 test of independence is given below.

Test Statistic for Testing H 0 : Distribution of outcome is independent of groups

and we find the critical value in a table of probabilities for the chi-square distribution with df=(r-1)*(c-1).

Here O = observed frequency, E=expected frequency in each of the response categories in each group, r = the number of rows in the two-way table and c = the number of columns in the two-way table.   r and c correspond to the number of comparison groups and the number of response options in the outcome (see below for more details). The observed frequencies are the sample data and the expected frequencies are computed as described below. The test statistic is appropriate for large samples, defined as expected frequencies of at least 5 in each of the response categories in each group.  

The data for the χ 2 test of independence are organized in a two-way table. The outcome and grouping variable are shown in the rows and columns of the table. The sample table below illustrates the data layout. The table entries (blank below) are the numbers of participants in each group responding to each response category of the outcome variable.

Table - Possible outcomes are are listed in the columns; The groups being compared are listed in rows.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

N

In the table above, the grouping variable is shown in the rows of the table; r denotes the number of independent groups. The outcome variable is shown in the columns of the table; c denotes the number of response options in the outcome variable. Each combination of a row (group) and column (response) is called a cell of the table. The table has r*c cells and is sometimes called an r x c ("r by c") table. For example, if there are 4 groups and 5 categories in the outcome variable, the data are organized in a 4 X 5 table. The row and column totals are shown along the right-hand margin and the bottom of the table, respectively. The total sample size, N, can be computed by summing the row totals or the column totals. Similar to ANOVA, N does not refer to a population size here but rather to the total sample size in the analysis. The sample data can be organized into a table like the above. The numbers of participants within each group who select each response option are shown in the cells of the table and these are the observed frequencies used in the test statistic.

The test statistic for the χ 2 test of independence involves comparing observed (sample data) and expected frequencies in each cell of the table. The expected frequencies are computed assuming that the null hypothesis is true. The null hypothesis states that the two variables (the grouping variable and the outcome) are independent. The definition of independence is as follows:

 Two events, A and B, are independent if P(A|B) = P(A), or equivalently, if P(A and B) = P(A) P(B).

The second statement indicates that if two events, A and B, are independent then the probability of their intersection can be computed by multiplying the probability of each individual event. To conduct the χ 2 test of independence, we need to compute expected frequencies in each cell of the table. Expected frequencies are computed by assuming that the grouping variable and outcome are independent (i.e., under the null hypothesis). Thus, if the null hypothesis is true, using the definition of independence:

P(Group 1 and Response Option 1) = P(Group 1) P(Response Option 1).

 The above states that the probability that an individual is in Group 1 and their outcome is Response Option 1 is computed by multiplying the probability that person is in Group 1 by the probability that a person is in Response Option 1. To conduct the χ 2 test of independence, we need expected frequencies and not expected probabilities . To convert the above probability to a frequency, we multiply by N. Consider the following small example.

 

10

8

7

25

22

15

13

50

30

28

17

75

62

51

37

150

The data shown above are measured in a sample of size N=150. The frequencies in the cells of the table are the observed frequencies. If Group and Response are independent, then we can compute the probability that a person in the sample is in Group 1 and Response category 1 using:

P(Group 1 and Response 1) = P(Group 1) P(Response 1),

P(Group 1 and Response 1) = (25/150) (62/150) = 0.069.

Thus if Group and Response are independent we would expect 6.9% of the sample to be in the top left cell of the table (Group 1 and Response 1). The expected frequency is 150(0.069) = 10.4.   We could do the same for Group 2 and Response 1:

P(Group 2 and Response 1) = P(Group 2) P(Response 1),

P(Group 2 and Response 1) = (50/150) (62/150) = 0.138.

The expected frequency in Group 2 and Response 1 is 150(0.138) = 20.7.

Thus, the formula for determining the expected cell frequencies in the χ 2 test of independence is as follows:

Expected Cell Frequency = (Row Total * Column Total)/N.

The above computes the expected frequency in one step rather than computing the expected probability first and then converting to a frequency.  

In a prior example we evaluated data from a survey of university graduates which assessed, among other things, how frequently they exercised. The survey was completed by 470 graduates. In the prior example we used the χ 2 goodness-of-fit test to assess whether there was a shift in the distribution of responses to the exercise question following the implementation of a health promotion campaign on campus. We specifically considered one sample (all students) and compared the observed distribution to the distribution of responses the prior year (a historical control). Suppose we now wish to assess whether there is a relationship between exercise on campus and students' living arrangements. As part of the same survey, graduates were asked where they lived their senior year. The response options were dormitory, on-campus apartment, off-campus apartment, and at home (i.e., commuted to and from the university). The data are shown below.

 

32

30

28

90

74

64

42

180

110

25

15

150

39

6

5

50

255

125

90

470

Based on the data, is there a relationship between exercise and student's living arrangement? Do you think where a person lives affect their exercise status? Here we have four independent comparison groups (living arrangement) and a discrete (ordinal) outcome variable with three response options. We specifically want to test whether living arrangement and exercise are independent. We will run the test using the five-step approach.  

H 0 : Living arrangement and exercise are independent

H 1 : H 0 is false.                α=0.05

The null and research hypotheses are written in words rather than in symbols. The research hypothesis is that the grouping variable (living arrangement) and the outcome variable (exercise) are dependent or related.   

  • Step 2.  Select the appropriate test statistic.  

The condition for appropriate use of the above test statistic is that each expected frequency is at least 5. In Step 4 we will compute the expected frequencies and we will ensure that the condition is met.

The decision rule depends on the level of significance and the degrees of freedom, defined as df = (r-1)(c-1), where r and c are the numbers of rows and columns in the two-way data table.   The row variable is the living arrangement and there are 4 arrangements considered, thus r=4. The column variable is exercise and 3 responses are considered, thus c=3. For this test, df=(4-1)(3-1)=3(2)=6. Again, with χ 2 tests there are no upper, lower or two-tailed tests. If the null hypothesis is true, the observed and expected frequencies will be close in value and the χ 2 statistic will be close to zero. If the null hypothesis is false, then the χ 2 statistic will be large. The rejection region for the χ 2 test of independence is always in the upper (right-hand) tail of the distribution. For df=6 and a 5% level of significance, the appropriate critical value is 12.59 and the decision rule is as follows: Reject H 0 if c 2 > 12.59.

We now compute the expected frequencies using the formula,

Expected Frequency = (Row Total * Column Total)/N.

The computations can be organized in a two-way table. The top number in each cell of the table is the observed frequency and the bottom number is the expected frequency.   The expected frequencies are shown in parentheses.

 

32

(48.8)

30

(23.9)

28

(17.2)

90

74

(97.7)

64

(47.9)

42

(34.5)

180

110

(81.4)

25

(39.9)

15

(28.7)

150

39

(27.1)

6

(13.3)

5

(9.6)

50

255

125

90

470

Notice that the expected frequencies are taken to one decimal place and that the sums of the observed frequencies are equal to the sums of the expected frequencies in each row and column of the table.  

Recall in Step 2 a condition for the appropriate use of the test statistic was that each expected frequency is at least 5. This is true for this sample (the smallest expected frequency is 9.6) and therefore it is appropriate to use the test statistic.

We reject H 0 because 60.5 > 12.59. We have statistically significant evidence at a =0.05 to show that H 0 is false or that living arrangement and exercise are not independent (i.e., they are dependent or related), p < 0.005.  

Again, the χ 2 test of independence is used to test whether the distribution of the outcome variable is similar across the comparison groups. Here we rejected H 0 and concluded that the distribution of exercise is not independent of living arrangement, or that there is a relationship between living arrangement and exercise. The test provides an overall assessment of statistical significance. When the null hypothesis is rejected, it is important to review the sample data to understand the nature of the relationship. Consider again the sample data. 

Because there are different numbers of students in each living situation, it makes the comparisons of exercise patterns difficult on the basis of the frequencies alone. The following table displays the percentages of students in each exercise category by living arrangement. The percentages sum to 100% in each row of the table. For comparison purposes, percentages are also shown for the total sample along the bottom row of the table.

36%

33%

31%

41%

36%

23%

73%

17%

10%

78%

12%

10%

54%

27%

19%

From the above, it is clear that higher percentages of students living in dormitories and in on-campus apartments reported regular exercise (31% and 23%) as compared to students living in off-campus apartments and at home (10% each).  

Test Yourself

 Pancreaticoduodenectomy (PD) is a procedure that is associated with considerable morbidity. A study was recently conducted on 553 patients who had a successful PD between January 2000 and December 2010 to determine whether their Surgical Apgar Score (SAS) is related to 30-day perioperative morbidity and mortality. The table below gives the number of patients experiencing no, minor, or major morbidity by SAS category.  

0-4

21

20

16

5-6

135

71

35

7-10

158

62

35

Question: What would be an appropriate statistical test to examine whether there is an association between Surgical Apgar Score and patient outcome? Using 14.13 as the value of the test statistic for these data, carry out the appropriate test at a 5% level of significance. Show all parts of your test.

In the module on hypothesis testing for means and proportions, we discussed hypothesis testing applications with a dichotomous outcome variable and two independent comparison groups. We presented a test using a test statistic Z to test for equality of independent proportions. The chi-square test of independence can also be used with a dichotomous outcome and the results are mathematically equivalent.  

In the prior module, we considered the following example. Here we show the equivalence to the chi-square test of independence.

A randomized trial is designed to evaluate the effectiveness of a newly developed pain reliever designed to reduce pain in patients following joint replacement surgery. The trial compares the new pain reliever to the pain reliever currently in use (called the standard of care). A total of 100 patients undergoing joint replacement surgery agreed to participate in the trial. Patients were randomly assigned to receive either the new pain reliever or the standard pain reliever following surgery and were blind to the treatment assignment. Before receiving the assigned treatment, patients were asked to rate their pain on a scale of 0-10 with higher scores indicative of more pain. Each patient was then given the assigned treatment and after 30 minutes was again asked to rate their pain on the same scale. The primary outcome was a reduction in pain of 3 or more scale points (defined by clinicians as a clinically meaningful reduction). The following data were observed in the trial.

50

23

0.46

50

11

0.22

We tested whether there was a significant difference in the proportions of patients reporting a meaningful reduction (i.e., a reduction of 3 or more scale points) using a Z statistic, as follows. 

H 0 : p 1 = p 2    

H 1 : p 1 ≠ p 2                             α=0.05

Here the new or experimental pain reliever is group 1 and the standard pain reliever is group 2.

We must first check that the sample size is adequate. Specifically, we need to ensure that we have at least 5 successes and 5 failures in each comparison group or that:

In this example, we have

Therefore, the sample size is adequate, so the following formula can be used:

Reject H 0 if Z < -1.960 or if Z > 1.960.

We now substitute the sample data into the formula for the test statistic identified in Step 2. We first compute the overall proportion of successes:

We now substitute to compute the test statistic.

  • Step 5.  Conclusion.  

We now conduct the same test using the chi-square test of independence.  

H 0 : Treatment and outcome (meaningful reduction in pain) are independent

H 1 :   H 0 is false.         α=0.05

The formula for the test statistic is:  

For this test, df=(2-1)(2-1)=1. At a 5% level of significance, the appropriate critical value is 3.84 and the decision rule is as follows: Reject H0 if χ 2 > 3.84. (Note that 1.96 2 = 3.84, where 1.96 was the critical value used in the Z test for proportions shown above.)

We now compute the expected frequencies using:

The computations can be organized in a two-way table. The top number in each cell of the table is the observed frequency and the bottom number is the expected frequency. The expected frequencies are shown in parentheses.

23

(17.0)

27

(33.0)

50

11

(17.0)

39

(33.0)

50

34

66

100

A condition for the appropriate use of the test statistic was that each expected frequency is at least 5. This is true for this sample (the smallest expected frequency is 22.0) and therefore it is appropriate to use the test statistic.

(Note that (2.53) 2 = 6.4, where 2.53 was the value of the Z statistic in the test for proportions shown above.)

Chi-Squared Tests in R

The video below by Mike Marin demonstrates how to perform chi-squared tests in the R programming language.

Answer to Problem on Pancreaticoduodenectomy and Surgical Apgar Scores

We have 3 independent comparison groups (Surgical Apgar Score) and a categorical outcome variable (morbidity/mortality). We can run a Chi-Squared test of independence.

H 0 : Apgar scores and patient outcome are independent of one another.

H A : Apgar scores and patient outcome are not independent.

Chi-squared = 14.3

Since 14.3 is greater than 9.49, we reject H 0.

There is an association between Apgar scores and patient outcome. The lowest Apgar score group (0 to 4) experienced the highest percentage of major morbidity or mortality (16 out of 57=28%) compared to the other Apgar score groups.

Have a language expert improve your writing

Run a free plagiarism check in 10 minutes, generate accurate citations for free.

  • Knowledge Base
  • Chi-Square (Χ²) Tests | Types, Formula & Examples

Chi-Square (Χ²) Tests | Types, Formula & Examples

Published on May 23, 2022 by Shaun Turney . Revised on June 22, 2023.

A Pearson’s chi-square test is a statistical test for categorical data. It is used to determine whether your data are significantly different from what you expected. There are two types of Pearson’s chi-square tests:

  • The chi-square goodness of fit test is used to test whether the frequency distribution of a categorical variable is different from your expectations.
  • The chi-square test of independence is used to test whether two categorical variables are related to each other.

Table of contents

What is a chi-square test, the chi-square formula, when to use a chi-square test, types of chi-square tests, how to perform a chi-square test, how to report a chi-square test, practice questions, other interesting articles, frequently asked questions about chi-square tests.

Pearson’s chi-square (Χ 2 ) tests, often referred to simply as chi-square tests, are among the most common nonparametric tests . Nonparametric tests are used for data that don’t follow the assumptions of parametric tests , especially the assumption of a normal distribution .

If you want to test a hypothesis about the distribution of a categorical variable you’ll need to use a chi-square test or another nonparametric test. Categorical variables can be nominal or ordinal and represent groupings such as species or nationalities. Because they can only have a few specific values, they can’t have a normal distribution.

Test hypotheses about frequency distributions

There are two types of Pearson’s chi-square tests, but they both test whether the observed frequency distribution of a categorical variable is significantly different from its expected frequency distribution. A frequency distribution describes how observations are distributed between different groups.

Frequency distributions are often displayed using frequency distribution tables . A frequency distribution table shows the number of observations in each group. When there are two categorical variables, you can use a specific type of frequency distribution table called a contingency table to show the number of observations in each combination of groups.

Frequency of visits by bird species at a bird feeder during a 24-hour period
Bird species Frequency
House sparrow 15
House finch 12
Black-capped chickadee 9
Common grackle 8
European starling 8
Mourning dove 6
Contingency table of the handedness of a sample of Americans and Canadians
Right-handed Left-handed
American 236 19
Canadian 157 16

Receive feedback on language, structure, and formatting

Professional editors proofread and edit your paper by focusing on:

  • Academic style
  • Vague sentences
  • Style consistency

See an example

null and alternative hypothesis for chi square test for homogeneity

Both of Pearson’s chi-square tests use the same formula to calculate the test statistic , chi-square (Χ 2 ):

\begin{equation*} X^2=\sum{\frac{(O-E)^2}{E}} \end{equation*}

  • Χ 2 is the chi-square test statistic
  • Σ is the summation operator (it means “take the sum of”)
  • O is the observed frequency
  • E is the expected frequency

The larger the difference between the observations and the expectations ( O − E in the equation), the bigger the chi-square will be. To decide whether the difference is big enough to be statistically significant , you compare the chi-square value to a critical value.

A Pearson’s chi-square test may be an appropriate option for your data if all of the following are true:

  • You want to test a hypothesis about one or more categorical variables . If one or more of your variables is quantitative, you should use a different statistical test . Alternatively, you could convert the quantitative variable into a categorical variable by separating the observations into intervals.
  • The sample was randomly selected from the population .
  • There are a minimum of five observations expected in each group or combination of groups.

The two types of Pearson’s chi-square tests are:

Chi-square goodness of fit test

Chi-square test of independence.

Mathematically, these are actually the same test. However, we often think of them as different tests because they’re used for different purposes.

You can use a chi-square goodness of fit test when you have one categorical variable. It allows you to test whether the frequency distribution of the categorical variable is significantly different from your expectations. Often, but not always, the expectation is that the categories will have equal proportions.

  • Null hypothesis ( H 0 ): The bird species visit the bird feeder in equal proportions.
  • Alternative hypothesis ( H A ): The bird species visit the bird feeder in different proportions.

Expectation of different proportions

  • Null hypothesis ( H 0 ): The bird species visit the bird feeder in the same proportions as the average over the past five years.
  • Alternative hypothesis ( H A ): The bird species visit the bird feeder in different proportions from the average over the past five years.

You can use a chi-square test of independence when you have two categorical variables. It allows you to test whether the two variables are related to each other. If two variables are independent (unrelated), the probability of belonging to a certain group of one variable isn’t affected by the other variable .

  • Null hypothesis ( H 0 ): The proportion of people who are left-handed is the same for Americans and Canadians.
  • Alternative hypothesis ( H A ): The proportion of people who are left-handed differs between nationalities.

Other types of chi-square tests

Some consider the chi-square test of homogeneity to be another variety of Pearson’s chi-square test. It tests whether two populations come from the same distribution by determining whether the two populations have the same proportions as each other. You can consider it simply a different way of thinking about the chi-square test of independence.

McNemar’s test is a test that uses the chi-square test statistic. It isn’t a variety of Pearson’s chi-square test, but it’s closely related. You can conduct this test when you have a related pair of categorical variables that each have two groups. It allows you to determine whether the proportions of the variables are equal.

Contingency table of ice cream flavor preference
Like chocolate Dislike chocolate
Like vanilla 47 32
Dislike vanilla 8 13
  • Null hypothesis ( H 0 ): The proportion of people who like chocolate is the same as the proportion of people who like vanilla.
  • Alternative hypothesis ( H A ): The proportion of people who like chocolate is different from the proportion of people who like vanilla.

There are several other types of chi-square tests that are not Pearson’s chi-square tests, including the test of a single variance and the likelihood ratio chi-square test .

Here's why students love Scribbr's proofreading services

Discover proofreading & editing

The exact procedure for performing a Pearson’s chi-square test depends on which test you’re using, but it generally follows these steps:

  • Create a table of the observed and expected frequencies. This can sometimes be the most difficult step because you will need to carefully consider which expected values are most appropriate for your null hypothesis.
  • Calculate the chi-square value from your observed and expected frequencies using the chi-square formula.
  • Find the critical chi-square value in a chi-square critical value table or using statistical software.
  • Compare the chi-square value to the critical value to determine which is larger.
  • Decide whether to reject the null hypothesis. You should reject the null hypothesis if the chi-square value is greater than the critical value. If you reject the null hypothesis, you can conclude that your data are significantly different from what you expected.

If you decide to include a Pearson’s chi-square test in your research paper , dissertation or thesis , you should report it in your results section . You can follow these rules if you want to report statistics in APA Style :

  • You don’t need to provide a reference or formula since the chi-square test is a commonly used statistic.
  • Refer to chi-square using its Greek symbol, Χ 2 . Although the symbol looks very similar to an “X” from the Latin alphabet, it’s actually a different symbol. Greek symbols should not be italicized.
  • Include a space on either side of the equal sign.
  • If your chi-square is less than zero, you should include a leading zero (a zero before the decimal point) since the chi-square can be greater than zero.
  • Provide two significant digits after the decimal point.
  • Report the chi-square alongside its degrees of freedom , sample size, and p value , following this format: Χ 2 (degrees of freedom, N = sample size) = chi-square value, p = p value).

If you want to know more about statistics , methodology , or research bias , make sure to check out some of our other articles with explanations and examples.

  • Chi square test of independence
  • Statistical power
  • Descriptive statistics
  • Degrees of freedom
  • Pearson correlation
  • Null hypothesis

Methodology

  • Double-blind study
  • Case-control study
  • Research ethics
  • Data collection
  • Hypothesis testing
  • Structured interviews

Research bias

  • Hawthorne effect
  • Unconscious bias
  • Recall bias
  • Halo effect
  • Self-serving bias
  • Information bias

The two main chi-square tests are the chi-square goodness of fit test and the chi-square test of independence .

Both chi-square tests and t tests can test for differences between two groups. However, a t test is used when you have a dependent quantitative variable and an independent categorical variable (with two groups). A chi-square test of independence is used when you have two categorical variables.

Both correlations and chi-square tests can test for relationships between two variables. However, a correlation is used when you have two quantitative variables and a chi-square test of independence is used when you have two categorical variables.

Quantitative variables are any variables where the data represent amounts (e.g. height, weight, or age).

Categorical variables are any variables where the data represent groups. This includes rankings (e.g. finishing places in a race), classifications (e.g. brands of cereal), and binary outcomes (e.g. coin flips).

You need to know what type of variables you are working with to choose the right statistical test for your data and interpret your results .

Cite this Scribbr article

If you want to cite this source, you can copy and paste the citation or click the “Cite this Scribbr article” button to automatically add the citation to our free Citation Generator.

Turney, S. (2023, June 22). Chi-Square (Χ²) Tests | Types, Formula & Examples. Scribbr. Retrieved June 25, 2024, from https://www.scribbr.com/statistics/chi-square-tests/

Is this article helpful?

Shaun Turney

Shaun Turney

Other students also liked, chi-square test of independence | formula, guide & examples, chi-square goodness of fit test | formula, guide & examples, chi-square (χ²) distributions | definition & examples, what is your plagiarism score.

Logo for Open Library Publishing Platform

Want to create or adapt books like this? Learn more about how Pressbooks supports open publishing practices.

Chapter 11.5: Test for Homogeneity

The goodness–of–fit test can be used to decide whether a population fits a given distribution, but it will not suffice to decide whether two populations follow the same unknown distribution. A different test, called the test for homogeneity , can be used to draw a conclusion about whether two populations have the same distribution. To calculate the test statistic for a test for homogeneity, follow the same procedure as with the test of independence.

The expected value for each cell needs to be at least five in order for you to use this test.

Hypotheses H 0 : The distributions of the two populations are the same. H a : The distributions of the two populations are not the same.

{\chi }^{2}

Degrees of Freedom ( df ) df = number of columns – 1

Requirements All values in the table must be greater than or equal to five.

Common Uses Comparing two populations. For example: men vs. women, before vs. after, east vs. west. The variable is categorical with more than two possible response values.

Do male and female college students have the same distribution of living arrangements? Use a level of significance of 0.05. Suppose that 250 randomly selected male college students and 300 randomly selected female college students were asked about their living arrangements: dormitory, apartment, with parents, other. The results are shown in (Figure) . Do male and female college students have the same distribution of living arrangements?

Distribution of Living Arragements for College Males and College Females
72 84 49 45
91 86 88 35

{\chi }_{3}^{2}

Press the MATRX key and arrow over to EDIT . Press 1:[A] . Press 2 ENTER 4 ENTER . Enter the table values by row. Press ENTER after each. Press 2nd QUIT . Press STAT and arrow over to TESTS . Arrow down to C:χ2-TEST . Press ENTER . You should see Observed:[A] and Expected:[B] . Arrow down to Calculate . Press ENTER . The test statistic is 10.1287 and the p -value = 0.0175. Do the procedure a second time but arrow down to Draw instead of calculate .

Compare α and the p -value: Since no α is given, assume α = 0.05. p -value = 0.0175. α > p -value. Make a decision: Since α > p -value, reject H 0 . This means that the distributions are not the same. Conclusion: At a 5% level of significance, from the data, there is sufficient evidence to conclude that the distributions of living arrangements for male and female college students are not the same. Notice that the conclusion is only that the distributions are not the same. We cannot use the test for homogeneity to draw any conclusions about how they differ.

Do families and singles have the same distribution of cars? Use a level of significance of 0.05. Suppose that 100 randomly selected families and 200 randomly selected singles were asked what type of car they drove: sport, sedan, hatchback, truck, van/SUV. The results are shown in (Figure) . Do families and singles have the same distribution of cars? Test at a level of significance of 0.05.

Sport Sedan Hatchback Truck Van/SUV
Family 5 15 35 17 28
Single 45 65 37 46 7

Both before and after a recent earthquake, surveys were conducted asking voters which of the three candidates they planned on voting for in the upcoming city council election. Has there been a change since the earthquake? Use a level of significance of 0.05. (Figure) shows the results of the survey. Has there been a change in the distribution of voter preferences since the earthquake?

167 128 135
214 197 225

{\chi }_{2}^{2}

Calculate the test statistic : χ 2 = 3.2603 (calculator or computer)

Probability statement: p -value= P ( χ 2 > 3.2603) = 0.1959

Press the MATRX key and arrow over to EDIT . Press 1:[A] . Press 2 ENTER 3 ENTER . Enter the table values by row. Press ENTER after each. Press 2nd QUIT . Press STAT and arrow over to TESTS . Arrow down to C:χ2-TEST . Press ENTER . You should see Observed:[A] and Expected:[B] . Arrow down to Calculate . Press ENTER . The test statistic is 3.2603 and the p -value = 0.1959. Do the procedure a second time but arrow down to Draw instead of calculate .

Compare α and the p -value: α = 0.05 and the p -value = 0.1959. α < p -value.

Make a decision: Since α < p -value, do not reject H o .

Conclusion: At a 5% level of significance, from the data, there is insufficient evidence to conclude that the distribution of voter preferences was not the same before and after the earthquake.

Ivy League schools receive many applications, but only some can be accepted. At the schools listed in (Figure) , two types of applications are accepted: regular and early decision.

Application Type Accepted Brown Columbia Cornell Dartmouth Penn Yale
Regular 2,115 1,792 5,306 1,734 2,685 1,245
Early Decision 577 627 1,228 444 1,195 761

We want to know if the number of regular applications accepted follows the same distribution as the number of early applications accepted. State the null and alternative hypotheses, the degrees of freedom and the test statistic, sketch the graph of the p -value, and draw a conclusion about the test of homogeneity.

Data from the Insurance Institute for Highway Safety, 2013. Available online at www.iihs.org/iihs/ratings (accessed May 24, 2013).

“Energy use (kg of oil equivalent per capita).” The World Bank, 2013. Available online at http://data.worldbank.org/indicator/EG.USE.PCAP.KG.OE/countries (accessed May 24, 2013).

“Parent and Family Involvement Survey of 2007 National Household Education Survey Program (NHES),” U.S. Department of Education, National Center for Education Statistics. Available online at http://nces.ed.gov/pubsearch/pubsinfo.asp?pubid=2009030 (accessed May 24, 2013).

“Parent and Family Involvement Survey of 2007 National Household Education Survey Program (NHES),” U.S. Department of Education, National Center for Education Statistics. Available online at http://nces.ed.gov/pubs2009/2009030_sup.pdf (accessed May 24, 2013).

Chapter Review

To assess whether two data sets are derived from the same distribution—which need not be known, you can apply the test for homogeneity that uses the chi-square distribution. The null hypothesis for this test states that the populations of the two data sets come from the same distribution. The test compares the observed values against the expected values if the two populations followed the same distribution. The test is right-tailed. Each observation or cell category must have an expected value of at least five.

Formula Review

\sum _{i\cdot j}\frac{{\left(O-E\right)}^{2}}{E}

df = ( i −1)( j −1) Degrees of freedom

A math teacher wants to see if two of her classes have the same distribution of test scores. What test should she use?

test for homogeneity

What are the null and alternative hypotheses for (Figure) ?

A market researcher wants to see if two different stores have the same distribution of sales throughout the year. What type of test should he use?

A meteorologist wants to know if East and West Australia have the same distribution of storms. What type of test should she use?

What condition must be met to use the test for homogeneity?

All values in the table must be greater than or equal to five.

Use the following information to answer the next five exercises: Do private practice doctors and hospital doctors have the same distribution of working hours? Suppose that a sample of 100 private practice doctors and 150 hospital doctors are selected at random and asked about the number of hours a week they work. The results are shown in (Figure) .

20–30 30–40 40–50 50–60
Private Practice 16 40 38 6
Hospital 8 44 59 39

State the null and alternative hypotheses.

df = _______

What is the test statistic?

What is the p -value?

What can you conclude at the 5% significance level?

For each word problem, use a solution sheet to solve the hypothesis test problem. Go to (Figure) for the chi-square solution sheet. Round expected frequency to two decimal places.

1) A psychologist is interested in testing whether there is a difference in the distribution of personality types for business majors and social science majors. The results of the study are shown in (Figure) . Conduct a test of homogeneity. Test at a 5% level of significance.

41 52 46 61 58
72 75 63 80 65

2) Do men and women select different breakfasts? The breakfasts ordered by randomly selected men and women at a popular breakfast place is shown in (Figure) . Conduct a test for homogeneity at a 5% level of significance.

47 35 28 53
65 59 55 60

3) A fisherman is interested in whether the distribution of fish caught in Green Valley Lake is the same as the distribution of fish caught in Echo Lake. Of the 191 randomly selected fish caught in Green Valley Lake, 105 were rainbow trout, 27 were other trout, 35 were bass, and 24 were catfish. Of the 293 randomly selected fish caught in Echo Lake, 115 were rainbow trout, 58 were other trout, 67 were bass, and 53 were catfish. Perform a test for homogeneity at a 5% level of significance.

4) In 2007, the United States had 1.5 million homeschooled students, according to the U.S. National Center for Education Statistics. In (Figure) you can see that parents decide to homeschool their children for different reasons, and some reasons are ranked by parents as more important than others. According to the survey results shown in the table, is the distribution of applicable reasons the same as the distribution of the most important reason? Provide your assessment at the 5% significance level. Did you expect the result you obtained?

Reasons for Homeschooling Applicable Reason (in thousands of respondents) Most Important Reason (in thousands of respondents) Row Total
Concern about the environment of other schools 1,321 309 1,630
Dissatisfaction with academic instruction at other schools 1,096 258 1,354
To provide religious or moral instruction 1,257 540 1,797
Child has special needs, other than physical or mental 315 55 370
Nontraditional approach to child’s education 984 99 1,083
Other reasons (e.g., finances, travel, family time, etc.) 485 216 701
Column Total 5,458 1,477 6,935

5) When looking at energy consumption, we are often interested in detecting trends over time and how they correlate among different countries. The information in (Figure) shows the average energy use (in units of kg of oil equivalent per capita) in the USA and the joint European Union countries (EU) for the six-year period 2005 to 2010. Do the energy use values in these two areas come from the same distribution? Perform the analysis at the 5% significance level.

Year European Union United States Row Total
2010 3,413 7,164 10,557
2009 3,302 7,057 10,359
2008 3,505 7,488 10,993
2007 3,537 7,758 11,295
2006 3,595 7,697 11,292
2005 3,613 7,847 11,460
Column Total 20,965 45,011 65,976

6) The Insurance Institute for Highway Safety collects safety information about all types of cars every year, and publishes a report of Top Safety Picks among all cars, makes, and models. (Figure) presents the number of Top Safety Picks in six car categories for the two years 2009 and 2013. Analyze the table data to conclude whether the distribution of cars that earned the Top Safety Picks safety award has remained the same between 2009 and 2013. Derive your results at the 5% significance level.

Year \ Car Type Small Mid-Size Large Small SUV Mid-Size SUV Large SUV Row Total
2009 12 22 10 10 27 6 87
2013 31 30 19 11 29 4 124
43 52 29 21 56 10 211

Answers to odd questions

  • H 0 : The distribution for personality types is the same for both majors
  • H a : The distribution for personality types is not the same for both majors
  • chi-square with df = 4
  • test statistic = 3.01
  • p -value = 0.5568
  • Check student’s solution.
  • Alpha: 0.05
  • Decision: Do not reject the null hypothesis.
  • Reason for decision: p -value > alpha
  • Conclusion: There is insufficient evidence to conclude that the distribution of personality types is different for business and social science majors.
  • H 0 : The distribution for fish caught is the same in Green Valley Lake and in Echo Lake.
  • H a : The distribution for fish caught is not the same in Green Valley Lake and in Echo Lake.
  • chi-square with df = 3
  • p -value = 0.0083
  • Decision: Reject the null hypothesis.
  • Reason for decision: p -value < alpha
  • Conclusion: There is evidence to conclude that the distribution of fish caught is different in Green Valley Lake and in Echo Lake
  • H 0 : The distribution of average energy use in the USA is the same as in Europe between 2005 and 2010.
  • H a : The distribution of average energy use in the USA is not the same as in Europe between 2005 and 2010.
  • test statistic = 2.7434
  • p -value = 0.7395
  • Conclusion: At the 5% significance level, there is insufficient evidence to conclude that the average energy use values in the US and EU are not derived from different distributions for the period from 2005 to 2010.

College Statistics Copyright © 2022 by St. Clair College is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License , except where otherwise noted.

Share This Book

Algor Cards

Cosa ne pensi di noi?

Il tuo nome

La tua email

null and alternative hypothesis for chi square test for homogeneity

Chi-square Test for Homogeneity

Mappa concettuale.

null and alternative hypothesis for chi square test for homogeneity

The Chi-square test for homogeneity is a statistical method used to compare the distribution of a categorical variable across different groups. It checks for significant differences in attributes like preferences or behaviors among distinct populations. The test involves setting hypotheses, calculating expected frequencies, and computing a test statistic to determine if distributions differ significantly. It's a vital tool in research fields such as healthcare, where it can assess treatment effectiveness across locations.

Mostra di più

Definition and Purpose

Statistical procedure.

The Chi-square test for homogeneity is a statistical procedure used to determine if there are significant differences in the distribution of a categorical variable across multiple populations

Comparison of Attributes

This test is essential when comparing attributes such as preferences, behaviors, or characteristics among distinct groups

For instance, researchers might use it to evaluate whether dietary habits vary by age group

Prerequisites

Data requirements.

Several prerequisites must be satisfied to conduct a Chi-square test for homogeneity effectively, including categorical data and independent groups with no overlap

Expected Frequencies

Each expected frequency in the contingency table should ideally be five or more to validate the test's assumptions

Sampling Method

The sampling method should ensure that each observation is independent, typically achieved by random sampling

Hypotheses and Statistical Analysis

Setting up hypotheses.

The Chi-square test for homogeneity involves setting up two hypotheses, the null hypothesis and the alternative hypothesis, to guide the statistical analysis

Calculation of Test Statistic

To perform the Chi-square test, expected frequencies for each category within each group are calculated, and the Chi-square statistic is computed to quantify the divergence of the observed data from the expected distribution

Degrees of Freedom and Critical Value

The degrees of freedom (df) are calculated to determine the critical value from the Chi-square distribution, which is then compared to the test statistic

Interpretation and Applications

Interpreting results.

The interpretation of the Chi-square test for homogeneity involves comparing the calculated test statistic to the critical value and the p-value

Distinction from Chi-square Test for Independence

It is crucial to distinguish between the Chi-square test for homogeneity and the Chi-square test for independence, as they address different research questions and are applied in different contexts

Applications

The Chi-square test for homogeneity is widely used in various research fields, such as healthcare, to investigate the consistency of distributions across multiple populations

Vuoi creare mappe dal tuo materiale?

Inserisci un testo, carica una foto o un audio su Algor. In pochi secondi Algorino lo trasformerà per te in mappa concettuale, riassunto e tanto altro!

Impara con le flashcards di Algor Education

Clicca sulla singola scheda per saperne di più sull'argomento.

null and alternative hypothesis for chi square test for homogeneity

Chi-square test for homogeneity: Data Type

Used for categorical variables across multiple populations.

null and alternative hypothesis for chi square test for homogeneity

Chi-square test for homogeneity: Sample Requirement

Requires random samples from each population.

null and alternative hypothesis for chi square test for homogeneity

Chi-square test for homogeneity: Comparison Basis

Compares observed frequencies to expected frequencies assuming no difference.

null and alternative hypothesis for chi square test for homogeneity

For a ______ test for homogeneity to be effective, the data should be in the form of ______, not percentages.

Chi-square frequency counts

null and alternative hypothesis for chi square test for homogeneity

Purpose of Chi-square test for homogeneity

To determine if different groups have identical distributions for a categorical variable.

Baseline assumption in Chi-square test for homogeneity

Null hypothesis assumes no difference in distribution across groups for the categorical variable.

The ______ test involves calculating expected frequencies using the ______ of the contingency table.

Chi-square marginal totals

Purpose of Chi-square test critical value

Determines threshold for rejecting null hypothesis based on df and significance level

Significance level in Chi-square test

Probability threshold for type I error, commonly set at 0.05

Consequence of Chi-square test statistic > critical value

Indicates significant difference, leads to rejection of null hypothesis

A ______ lower than the significance level indicates strong evidence against the null hypothesis in a Chi-square test.

Chi-square test for homogeneity: variable and populations?

Compares one categorical variable across multiple populations.

Chi-square test for independence: variables within a population?

Examines relationship between two categorical variables within one population.

In analyzing categorical data, the Chi-square test for ______ can reveal critical insights into whether distributions are similar or different across ______.

homogeneity multiple populations

Ecco un elenco delle domande più frequenti su questo argomento

What is the purpose of the chi-square test for homogeneity, what conditions must be met to perform a chi-square test for homogeneity, what are the null and alternative hypotheses in a chi-square test for homogeneity, how is the chi-square statistic calculated in the test for homogeneity, how are degrees of freedom determined in the chi-square test, how does one interpret the results of a chi-square test for homogeneity, how does the chi-square test for homogeneity differ from the test for independence, can you give an example of how the chi-square test for homogeneity is used in research, contenuti simili, esplora altre mappe su argomenti simili.

Glass flask in the shape of a Gauss curve with blue gradient liquid on wooden surface, illuminated on the left, with blurred glassware in the gray background.

Standard Normal Distribution

Series of glass jars on a reflective surface with colored marbles: full blue, 3/4 red, half green, 1/4 yellow, a few purple.

Dispersion in Statistics

Five light wooden podiums increasing in height with silver metal human figures above, blue-white gradient background, soft shadows.

Ordinal Regression

Two hands, one light and one dark, hold the ends of a transparent, flexible ruler on a table, creating a light bow.

Hypothesis Testing for Correlation

Hands holding colored transparent acrylic bars in descending order on reflective surface, from red to purple.

Statistical Data Presentation

Scatter chart with blue dots indicating a positive trend on a white background, two people analyze the data in the background.

Correlation and Its Importance in Research

Tidy desk with glass beaker and clear liquid, gloved hands hold steel pen, clean blackboard in background, warm environment.

Statistical Testing in Empirical Research

null and alternative hypothesis for chi square test for homogeneity

Non trovi quello che cercavi?

Cerca un argomento inserendo una frase o una parola chiave

Exploring the Chi-Square Test for Homogeneity

Close-up of a hand in a white coat holding a transparent flask full of colorful marbles on a neutral background.

Prerequisites for the Chi-Square Test for Homogeneity

Hypothesis development in the chi-square test for homogeneity, computing expected frequencies and the chi-square statistic, degrees of freedom and critical values in the chi-square test, interpreting chi-square test results and the p-value, differentiating homogeneity from independence in chi-square tests, practical applications of the chi-square test for homogeneity.

Modifica disponibile

Find Study Materials for

  • Explanations
  • Business Studies
  • Combined Science
  • Engineering
  • English Literature
  • Environmental Science
  • Human Geography
  • Macroeconomics
  • Microeconomics
  • Social Studies
  • Browse all subjects
  • Read our Magazine

Create Study Materials

  • Flashcards Create and find the best flashcards.
  • Notes Create notes faster than ever before.
  • Study Sets Everything you need for your studies in one place.
  • Study Plans Stop procrastinating with our smart planner features.
  • Chi Square Test for Homogeneity

Everyone's been in the situation before: you and your significant other can't agree on what to watch for date night! While the two of you are debating over which movie to watch, a question arises in the back of your mind; do different types of people (for instance, men vs. women) have different movie preferences? The answer to this question, and others like it, can be found using a specific Chi-square test – the Chi-square test for homogeneity .

Chi Square Test for Homogeneity

Create learning materials about Chi Square Test for Homogeneity with our free learning app!

  • Instand access to millions of learning materials
  • Flashcards, notes, mock-exams and more
  • Everything you need to ace your exams
  • Applied Mathematics
  • Decision Maths
  • Discrete Mathematics
  • Logic and Functions
  • Mechanics Maths
  • Probability and Statistics
  • Bayesian Statistics
  • Bias in Experiments
  • Binomial Distribution
  • Binomial Hypothesis Test
  • Biostatistics
  • Bivariate Data
  • Categorical Data Analysis
  • Categorical Variables
  • Causal Inference
  • Central Limit Theorem
  • Chi Square Test for Goodness of Fit
  • Chi Square Test for Independence
  • Chi-Square Distribution
  • Cluster Analysis
  • Combining Random Variables
  • Comparing Data
  • Comparing Two Means Hypothesis Testing
  • Conditional Probability
  • Conducting A Study
  • Conducting a Survey
  • Conducting an Experiment
  • Confidence Interval for Population Mean
  • Confidence Interval for Population Proportion
  • Confidence Interval for Slope of Regression Line
  • Confidence Interval for the Difference of Two Means
  • Confidence Intervals
  • Correlation Math
  • Cox Regression
  • Cumulative Distribution Function
  • Cumulative Frequency
  • Data Analysis
  • Data Interpretation
  • Decision Theory
  • Degrees of Freedom
  • Discrete Random Variable
  • Discriminant Analysis
  • Distributions
  • Empirical Bayes Methods
  • Empirical Rule
  • Errors In Hypothesis Testing
  • Estimation Theory
  • Estimator Bias
  • Events (Probability)
  • Experimental Design
  • Factor Analysis
  • Frequency Polygons
  • Generalization and Conclusions
  • Geometric Distribution
  • Geostatistics
  • Hierarchical Modeling
  • Hypothesis Test for Correlation
  • Hypothesis Test for Regression Slope
  • Hypothesis Test of Two Population Proportions
  • Hypothesis Testing
  • Inference For Distributions Of Categorical Data
  • Inferences in Statistics
  • Item Response Theory
  • Kaplan-Meier Estimate
  • Kernel Density Estimation
  • Large Data Set
  • Lasso Regression
  • Latent Variable Models
  • Least Squares Linear Regression
  • Linear Interpolation
  • Linear Regression
  • Logistic Regression
  • Machine Learning
  • Mann-Whitney Test
  • Markov Chains
  • Mean and Variance of Poisson Distributions
  • Measures of Central Tendency
  • Methods of Data Collection
  • Mixed Models
  • Multilevel Modeling
  • Multivariate Analysis
  • Neyman-Pearson Lemma
  • Non-parametric Methods
  • Normal Distribution
  • Normal Distribution Hypothesis Test
  • Normal Distribution Percentile
  • Ordinal Regression
  • Paired T-Test
  • Parametric Methods
  • Path Analysis
  • Point Estimation
  • Poisson Regression
  • Principle Components Analysis
  • Probability
  • Probability Calculations
  • Probability Density Function
  • Probability Distribution
  • Probability Generating Function
  • Product Moment Correlation Coefficient
  • Quantile Regression
  • Quantitative Variables
  • Random Effects Model
  • Random Variables
  • Randomized Block Design
  • Regression Analysis
  • Residual Sum of Squares
  • Robust Statistics
  • Sample Mean
  • Sample Proportion
  • Sampling Distribution
  • Sampling Theory
  • Scatter Graphs
  • Sequential Analysis
  • Single Variable Data
  • Spearman's Rank Correlation
  • Spearman's Rank Correlation Coefficient
  • Standard Deviation
  • Standard Error
  • Standard Normal Distribution
  • Statistical Graphs
  • Statistical Inference
  • Statistical Measures
  • Stem and Leaf Graph
  • Stochastic Processes
  • Structural Equation Modeling
  • Sum of Independent Random Variables
  • Survey Bias
  • Survival Analysis
  • Survivor Function
  • T-distribution
  • The Power Function
  • Time Series Analysis
  • Transforming Random Variables
  • Tree Diagram
  • Two Categorical Variables
  • Two Quantitative Variables
  • Type I Error
  • Type II Error
  • Types of Data in Statistics
  • Variance for Binomial Distribution
  • Venn Diagrams
  • Wilcoxon Test
  • Zero-Inflated Models
  • Theoretical and Mathematical Physics

Chi-Square Test for Homogeneity Definition

When you want to know if two categorical variables follow the same probability distribution (like in the movie preference question above), you can use a Chi-square test for homogeneity .

A Chi-square \( (\chi^{2}) \) test for homogeneity is a non-parametric Pearson Chi-square test that you apply to a single categorical variable from two or more different populations to determine whether they have the same distribution.

In this test, you randomly collect data from a population to determine if there is a significant association between \(2\) or more categorical variables .

Conditions for a Chi-Square Test for Homogeneity

All the Pearson Chi-square tests share the same basic conditions. The main difference is how the conditions apply in practice. A Chi-square test for homogeneity requires a categorical variable from at least two populations, and the data needs to be the raw count of members of each category. This test is used to check if the two variables follow the same distribution.

To be able to use this test, the conditions for a Chi-square test of homogeneity are:

The variables must be categorical .

Because you are testing the sameness of the variables, they have to have the same groups. This Chi-square test uses cross-tabulation, counting observations that fall in each category.

Reference the study: “Out-of-Hospital Cardiac Arrest in High-Rise Buildings: Delays to Patient Care and Effect on Survival” 1 – which was published in the Canadian Medical Association Journal (CMAJ) on April \(5, 2016\).

This study compared how adults live (house or townhouse, \(1^{st}\) or \(2^{nd}\) floor apartment, and \(3^{rd}\) or higher floor apartment) with their survival rate of a heart attack (survived or did not survive).

Your goal is to learn if there is a difference in the survival category proportions (i.e., are you more likely to survive a heart attack depending on where you live?) for the \(3\) populations:

  • heart attack victims who live in either a house or a townhouse,
  • heart attack victims who live on the \(1^{st}\) or \(2^{nd}\) floor of an apartment building, and
  • heart attack victims who live on the \(3^{rd}\) or higher floor of an apartment building.

Groups must be mutually exclusive; i.e., the sample is randomly selected .

Each observation is only allowed to be in one group. A person can live in a house or an apartment, but they cannot live in both.

Contingency Table
Living ArrangementSurvivedDid Not SurviveRow Totals
House or Townhouse21753145531
1 or 2 Floor Apartment35632667
3 or Higher Floor Apartment4616501696
Column Totals2987596\(n =\) 7894

Table 1. Table of contingency, Chi-Square test for homogeneity.

  • Expected counts must be at least \(5\).

This means the sample size must be large enough , but how large is difficult to determine beforehand. In general, making sure there are more than \(5\) in each category should be fine.

  • Observations must be independent.

This assumption is all about how you collect the data. If you use simple random sampling, that will almost always be statistically valid.

Chi-Square Test for Homogeneity: Null Hypothesis and Alternative Hypothesis

The question underlying this hypothesis test is: Do these two variables follow the same distribution?

The hypotheses are formed to answer that question.

  • The null hypothesis is that the two variables are from the same distribution.\[ \begin{align}H_{0}: p_{1,1} &= p_{2,1} \text{ AND } \\p_{1,2} &= p_{2,2} \text{ AND } \ldots \text{ AND } \\p_{1,n} &= p_{2,n}\end{align} \]

The null hypothesis requires every single category to have the same probability between the two variables.

The alternative hypothesis is that the two variables are not from the same distribution, i.e., at least one of the null hypotheses is false.\[ \begin{align}H_{a}: p_{1,1} &\neq p_{2,1} \text{ OR } \\p_{1,2} &\neq p_{2,2} \text{ OR } \ldots \text{ OR } \\p_{1,n} &\neq p_{2,n}\end{align} \]

If even one category is different from one variable to the other, then the test will return a significant result and provide evidence to reject the null hypothesis.

The null and alternative hypotheses in the heart attack survival study are:

The population is people who live in houses, townhouses, or apartments and who have had a heart attack.

  • Null Hypothesis \( H_{0}: \) The proportions in each survival category are the same for all \(3\) groups of people.
  • Alternative Hypothesis \( H_{a}: \) The proportions in each survival category are not the same for all \(3\) groups of people.

Expected Frequencies for a Chi-Square Test for Homogeneity

You must calculate the expected frequencies for a Chi-square test for homogeneity individually for each population at each level of the categorical variable, as given by the formula:

\[ E_{r,c} = \frac{n_{r} \cdot n_{c}}{n} \]

\(E_{r,c}\) is the expected frequency for population \(r\) at level \(c\) of the categorical variable,

\(r\) is the number of populations, which is also the number of rows in a contingency table,

\(c\) is the number of levels of the categorical variable, which is also the number of columns in a contingency table,

\(n_{r}\) is the number of observations from population \(r\),

\(n_{c}\) is the number of observations from level \(c\) of the categorical variable, and

\(n\) is the total sample size.

Continuing with the heart attack survival study:

Next, you calculate the expected frequencies using the formula above and the contingency table, putting your results into a modified contingency table to keep your data organized.

  • \( E_{1,1} = \frac{5531 \cdot 298}{7894} = 208.795 \)
  • \( E_{1,2} = \frac{5531 \cdot 7596}{7894} = 5322.205 \)
  • \( E_{2,1} = \frac{667 \cdot 298}{7894} = 25.179 \)
  • \( E_{2,2} = \frac{667 \cdot 7596}{7894} = 641.821 \)
  • \( E_{3,1} = \frac{1696 \cdot 298}{7894} = 64.024 \)
  • \( E_{3,2} = \frac{1696 \cdot 7596}{7894} = 1631.976 \)

Table 2. Table of contingency with observed frequencies, Chi-Square test for homogeneity.

Contingency Table with Observed (O) Frequencies and Expected (E) Frequencies
Living ArrangementSurvivedDid Not SurviveRow Totals
House or TownhouseO : 217E : 208.795O : 5314E : 5322.2055531
1 or 2 Floor ApartmentO : 35E : 25.179O : 632E : 641.821667
3 or Higher Floor ApartmentO : 46E : 64.024O : 1650E : 1631.9761696
Column Totals2987596\(n =\) 7894

Decimals in the table are rounded to \(3\) digits.

Degrees of Freedom for a Chi-Square Test for Homogeneity

There are two variables in a Chi-square test for homogeneity. Therefore, you are comparing two variables and need the contingency table to add up in both dimensions .

Since you need the rows to add up and the columns to add up, the degrees of freedom is calculated by:

\[ k = (r - 1) (c - 1) \]

\(k\) is the degrees of freedom,

\(r\) is the number of populations, which is also the number of rows in a contingency table, and

\(c\) is the number of levels of the categorical variable, which is also the number of columns in a contingency table.

Chi-Square Test for Homogeneity: Formula

The formula (also called a test statistic ) of a Chi-square test for homogeneity is:

\[ \chi^{2} = \sum \frac{(O_{r,c} - E_{r,c})^{2}}{E_{r,c}} \]

\(O_{r,c}\) is the observed frequency for population \(r\) at level \(c\), and

\(E_{r,c}\) is the expected frequency for population \(r\) at level \(c\).

How to Calculate the Test Statistic for a Chi-Square Test for Homogeneity

Step \(1\): Create a Table

Starting with your contingency table, remove the “Row Totals” column and the “Column Totals” row. Then, separate your observed and expected frequencies into two columns, like so:

Table 3. Table of observed and expected frequencies, Chi-Square test for homogeneity.

Table of Observed and Expected Frequencies
Living ArrangementStatusObserved FrequencyExpected Frequency
House or TownhouseSurvived217208.795
Did Not Survive53145322.205
1 or 2 Floor ApartmentSurvived3525.179
Did Not Survive632641.821
3 or Higher Floor ApartmentSurvived4664.024
Did Not Survive16501631.976

Decimals in this table are rounded to \(3\) digits.

Step \(2\): Subtract Expected Frequencies from Observed Frequencies

Add a new column to your table called “O – E”. In this column, put the result of subtracting the expected frequency from the observed frequency:

Table 4. Table of observed and expected frequencies, Chi-Square test for homogeneity.

Table of Observed, Expected, and O – E Frequencies
Living ArrangementStatusObserved FrequencyExpected FrequencyO – E
House or TownhouseSurvived217208.7958.205
Did Not Survive53145322.205-8.205
1 or 2 Floor ApartmentSurvived3525.1799.821
Did Not Survive632641.821-9.821
3 or Higher Floor ApartmentSurvived4664.024-18.024
Did Not Survive16501631.97618.024

Step \(3\): Square the Results from Step \(2\) Add another new column to your table called “(O – E) 2 ”. In this column, put the result of squaring the results from the previous column:

Table 5. Table of observed and expected frequencies, Chi-Square test for homogeneity.

Table of Observed, Expected, O – E, and (O – E) Frequencies
Living ArrangementStatusObserved FrequencyExpected FrequencyO – E(O – E)
House or TownhouseSurvived217208.7958.20567.322
Did Not Survive53145322.205-8.20567.322
1 or 2 Floor ApartmentSurvived3525.1799.82196.452
Did Not Survive632641.821-9.82196.452
3 or Higher Floor ApartmentSurvived4664.024-18.024324.865
Did Not Survive16501631.97618.024324.865

Step \(4\): Divide the Results from Step \(3\) by the Expected Frequencies Add a final new column to your table called “(O – E) 2 /E”. In this column, put the result of dividing the results from the previous column by their expected frequencies:

Table 6. Table of observed and expected frequencies, Chi-Square test for homogeneity.

Table of Observed, Expected, O – E, (O – E) , and (O – E) /E Frequencies
Living ArrangementStatusObserved FrequencyExpected FrequencyO – E(O – E) (O – E) /E
House or TownhouseSurvived217208.7958.20567.3220.322
Did Not Survive53145322.205-8.20567.3220.013
1 or 2 Floor ApartmentSurvived3525.1799.82196.4523.831
Did Not Survive632641.821-9.82196.4520.150
3 or Higher Floor ApartmentSurvived4664.024-18.024324.8655.074
Did Not Survive16501631.97618.024324.8650.199

Step \(5\): Sum the Results from Step \(4\) to get the Chi-Square Test Statistic Finally, add up all the values in the last column of your table to calculate your Chi-square test statistic:

\[ \begin{align}\chi^{2} &= \sum \frac{(O_{r,c} - E_{r,c})^{2}}{E_{r,c}} \\&= 0.322 + 0.013 + 3.831 + 0.150 + 5.074 + 0.199 \\&= 9.589.\end{align} \]

The Chi-square test statistic for the Chi-square test for homogeneity in the heart attack survival study is :

\[ \chi^{2} = 9.589. \]

Steps to Perform a Chi-Square Test for Homogeneity

To determine whether the test statistic is large enough to reject the null hypothesis, you compare the test statistic to a critical value from a Chi-square distribution table. This act of comparison is the heart of the Chi-square test of homogeneity.

Follow the \(6\) steps below to perform a Chi-square test of homogeneity.

Steps \(1, 2\) and \(3\) are outlined in detail in the previous sections: “Chi-Square Test for Homogeneity: Null Hypothesis and Alternative Hypothesis”, “Expected Frequencies for a Chi-Square Test for Homogeneity”, and “How to Calculate the Test Statistic for a Chi-Square Test for Homogeneity”.

Step \(1\): State the Hypotheses

Step \(2\): Calculate the Expected Frequencies

Reference your contingency table to calculate the expected frequencies using the formula:

Step \(3\): Calculate the Chi-Square Test Statistic

Use the formula for a Chi-square test for homogeneity to calculate the Chi-square test statistic:

Step \(4\): Find the Critical Chi-Square Value

To find the critical Chi-square value, you can either:

use a Chi-square distribution table, or

use a critical value calculator.

No matter which method you choose, you need \(2\) pieces of information:

the degrees of freedom, \(k\), given by the formula:

and the significance level, \(\alpha\), which is usually \(0.05\).

Find the critical value of the heart attack survival study.

To find the critical value:

  • Using the contingency table, notice that there are \(3\) rows and \(2\) columns of raw data. Therefore, the degrees of freedom are:\[ \begin{align}k &= (r - 1) (c - 1) \\&= (3-1) (2-1) \\&= 2 \text{ degrees of freedom}\end{align} \]
  • Generally, unless otherwise specified, the significance level of \( \alpha = 0.05 \) is what you want to use. This study also used that significance level.
  • According to the Chi-square distribution table below, for \( k = 2 \) and \( \alpha = 0.05 \), the critical value is:\[ \chi^{2} \text{ critical value} = 5.99. \]

Table 7. Table of percentage points, Chi-Square test for homogeneity.

Percentage Points of the Chi-Square Distribution
Degrees of Freedom ( )Probability of a Larger Value of X ; Significance Level (α)
0.990.950.900.750.500.250.100.050.01
10.0000.0040.0160.1020.4551.322.713.846.63
20.0200.1030.2110.5751.3862.774.615.999.21
30.1150.3520.5841.2122.3664.116.257.8111.34

Step \(5\): Compare the Chi-Square Test Statistic to the Critical Chi-Square Value

Is your test statistic large enough to reject the null hypothesis? To find out, compare it to the critical value.

Compare your test statistic to the critical value in the heart attack survival study:

The Chi-square test statistic is: \( \chi^{2} = 9.589 \)

The critical Chi-square value is: \( 5.99 \)

The Chi-square test statistic is greater than the critical value .

Step \(6\): Decide Whether to Reject the Null Hypothesis

Finally, decide if you can reject the null hypothesis.

If the Chi-square value is less than the critical value , then you have an insignificant difference between the observed and expected frequencies; i.e., \( p > \alpha \).

This means you do not reject the null hypothesis .

If the Chi-square value is greater than the critical value , then you have a significant difference between the observed and expected frequencies; i.e., \( p < \alpha \).

This means you have sufficient evidence to reject the null hypothesis .

Now you can decide whether to reject the null hypothesis for the heart attack survival study:

The Chi-square test statistic is greater than the critical value; i.e., the \(p\)-value is less than the significance level.

  • So, you have strong evidence to support that the proportions in the survival categories are not the same for the \(3\) groups.

You conclude that there is a smaller chance of survival for those who suffer a heart attack and live on the third or higher floor of an apartment, and therefore reject the null hypothesis .

P-Value of a Chi-Square Test for Homogeneity

The \(p\) -value of a Chi-square test for homogeneity is the probability that the test statistic, with \(k\) degrees of freedom, is more extreme than its calculated value. You can use a Chi-square distribution calculator to find the \(p\)-value of a test statistic. Alternatively, you can use a chi-square distribution table to determine if the value of your chi-square test statistic is above a certain significance level.

Chi-Square Test for Homogeneity VS Independence

At this point, you might ask yourself, what is the difference between a Chi-square test for homogeneity and a Chi-square test for independence?

You use the Chi-square test for homogeneity when you have only \(1\) categorical variable from \(2\) (or more) populations.

In this test, you randomly collect data from a population to determine if there is a significant association between \(2\) categorical variables .

When surveying students in a school, you might ask them for their favorite subject. You ask the same question to \(2\) different populations of students:

  • freshmen and

You use a Chi-square test for homogeneity to determine if the freshmen's preferences differed significantly from the seniors' preferences.

You use the Chi-square test for independence when you have \(2\) categorical variables from the same population.

  • In this test, you randomly collect data from each subgroup separately to determine if the frequency count differed significantly across different populations.

In a school, students could be classified by:

  • their handedness (left- or right-handed) or by
  • their field of study (math, physics, economics, etc.).

You use a Chi-square test for independence to determine if handedness is related to choice of study.

Chi-Square Test for Homogeneity Example

Continuing from the example in the introduction, you decide to find an answer to the question: do men and women have different movie preferences?

You select a random sample of \(400\) college freshmen: \(200\) men and \(300\) women. Each person is asked which of the following movies they like best: The Terminator; The Princess Bride; or The Lego Movie. The results are shown in the contingency table below.

Table 8. Contigency table, Chi-Square test for homogeneity.

Contingency Table
MovieMenWomenRow Totals
The Terminator12050170
The Princess Bride20140160
The Lego Movie60110170
Column Totals200300\(n =\) 500

Step \(1\): State the Hypotheses .

  • Null hypothesis : the proportion of men who prefer each movie is equal to the proportion of women who prefer each movie. So,\[ \begin{align}H_{0}: p_{\text{men like The Terminator}} &= p_{\text{women like The Terminator}} \text{ AND} \\H_{0}: p_{\text{men like The Princess Bride}} &= p_{\text{women like The Princess Bride}} \text{ AND} \\H_{0}: p_{\text{men like The Lego Movie}} &= p_{\text{women like The Lego Movie}}\end{align} \]
  • Alternative hypothesis : At least one of the null hypotheses is false. So,\[ \begin{align}H_{a}: p_{\text{men like The Terminator}} &\neq p_{\text{women like The Terminator}} \text{ OR} \\H_{a}: p_{\text{men like The Princess Bride}} &\neq p_{\text{women like The Princess Bride}} \text{ OR} \\H_{a}: p_{\text{men like The Lego Movie}} &\neq p_{\text{women like The Lego Movie}}\end{align} \]

Step \(2\): Calculate Expected Frequencies .

  • Using the above contingency table and the formula for expected frequencies:\[ E_{r,c} = \frac{n_{r} \cdot n_{c}}{n}, \]create a table of expected frequencies.

Table 9. Table of data for movies, Chi-Square test for homogeneity.

MovieMenWomenRow Totals
The Terminator68102170
The Princess Bride6496160
The Lego Movie68102170
Column Totals200300\(n =\) 500

Step \(3\): Calculate the Chi-Square Test Statistic .

  • Create a table to hold your calculated values and use the formula:\[ \chi^{2} = \sum \frac{(O_{r,c} - E_{r,c})^{2}}{E_{r,c}} \]to calculate your test statistic.

Table 10. Table of data for movies, Chi-Square test for homogeneity.

MoviePersonObserved FrequencyExpected FrequencyO-E(O-E) (O-E) /E
TerminatorMen1206852270439.767
Women50102-52270426.510
Princess BrideMen2064-44193630.250
Women1409644193620.167
Lego MovieMen6068-8640.941
Women1101028640.627

The formula here uses the non-rounded numbers from the table above to get a more accurate answer.

  • The Chi-square test statistic is:\[ \chi^{2} = 118.2598039. \]

Step \(4\): Find the Critical Chi-Square Value and the \(P\)-Value .

  • Calculate the degrees of freedom.\[ \begin{align}k &= (r - 1) (c - 1) \\&= (3 - 1) (2 - 1) \\&= 2\end{align} \]
  • Using a Chi-square distribution table, look at the row for \(2\) degrees of freedom and the column for \(0.05\) significance to find the critical value of \(5.99\).
  • Input the degrees of freedom and the Chi-square critical value into the calculator to get:\[ P(\chi^{2} > 118.2598039) = 0. \]

Step \(5\): Compare the Chi-Square Test Statistic to the Critical Chi-Square Value .

  • The test statistic of \(118.2598039\) is significantly larger than the critical value of \(5.99\).
  • The \(p\) -value is also much less than the significance level .

Step \(6\): Decide Whether to Reject the Null Hypothesis .

  • Because the test statistic is larger than the critical value and the \(p\)-value is less than the significance level,

you have sufficient evidence to reject the null hypothesis .

Chi-Square Test for Homogeneity – Key takeaways

  • A Chi-square test for homogeneity is a Chi-square test that is applied to a single categorical variable from two or more different populations to determine whether they have the same distribution.
  • The variables must be categorical.
  • Groups must be mutually exclusive.
  • The null hypothesis is that the variables are from the same distribution.
  • The alternative hypothesis is that the variables are not from the same distribution.
  • The degrees of freedom for a Chi-square test for homogeneity is given by the formula:\[ k = (r - 1) (c - 1) \]
  • The expected frequency for row \(r\) and column \(c\) of a Chi-square test for homogeneity is given by the formula:\[ E_{r,c} = \frac{n_{r} \cdot n_{c}}{n} \]
  • The formula (or test statistic ) for a Chi-square test for homogeneity is given by the formula:\[ \chi^{2} = \sum \frac{(O_{r,c} - E_{r,c})^{2}}{E_{r,c}} \]
  • https://pubmed.ncbi.nlm.nih.gov/26783332/

Flashcards in Chi Square Test for Homogeneity 15

What is a Chi-square test for homogeneity used for?

A C hi-square test for homogeneity is a Chi-square test that is applied to a single categorical variable from two or more different populations to determine whether they have the same distribution.

A Chi-square test for homogeneity has the same basic assumptions as any other Pearson Chi-square test:

The approach to use a Chi-square test for homogeneity has six basic steps:

State the hypotheses.

Calculate the expected frequencies.

Calculate the Chi-square test statistic.

Find the critical Chi-square value.

Compare the Chi-square test statistic to the Chi-square critical value.

Decide whether to reject the null hypothesis.

What is the null hypothesis of a Chi-square test for homogeneity?

The null hypothesis is that the two variables are from the same distribution.

\[ \begin{align} H_{0}: p_{1,1} &= p_{2,1} \text{ AND } \\ p_{1,2} &= p_{2,2} \text{ AND } \ldots \text{ AND } \\ p_{1,n} &= p_{2,n} \end{align} \].

What is the alternative hypothesis of a Chi-square test for homogeneity?

The alternative hypothesis is that the two variables are not from the same distribution, i.e., at least one of the null hypotheses is false.

\[ \begin{align} H_{a}: p_{1,1} &\neq p_{2,1} \text{ OR } \\ p_{1,2} &\neq p_{2,2} \text{ OR } \ldots \text{ OR } \\ p_{1,n} &\neq p_{2,n} \end{align} \].

As with any statistical test, your analysis plan when doing a Chi-square test for homogeneity describes how you will use the sample data to either accept or reject the null hypothesis. Your plan should specify the following:

Significance level.

Chi Square Test for Homogeneity

Learn with 15 Chi Square Test for Homogeneity flashcards in the free StudySmarter app

We have 14,000 flashcards about Dynamic Landscapes.

Already have an account? Log in

Frequently Asked Questions about Chi Square Test for Homogeneity

What is chi square test for homogeneity?

A chi-square test for homogeneity is a chi-square test that is applied to a single categorical variable from two or more different populations to determine whether they have the same distribution.

When to use chi square test for homogeneity?

A chi-square test for homogeneity requires a categorical variable from at least two populations, and the data needs to be the raw count of members of each category. This test is used to check if the two variables follow the same distribution.

What is the difference between a chi-square test of homogeneity and independence?

You use the chi-square test of homogeneity when you have only 1 categorical variable from 2 (or more) populations.

  • In this test, you randomly collect data from a population to determine if there is a significant association between 2 categorical variables.

You use the chi-square test of independence when you have 2 categorical variables from the same population.

What condition must be met to use the test for homogeneity?

This test has the same basic conditions as any other Pearson chi-square test:

  • Expected counts must be at least 5.

What is the difference between a t-test and Chi-square?

You use a T-Test to compare the mean of 2 given samples. When you don't know the mean and standard deviation of a population, you use a T-Test. You use a Chi-Square test to compare categorical variables.

Test your knowledge with multiple choice flashcards

When doing a Chi-square test for homogeneity, you use the sample data from your contingency table to find:

Chi Square Test for Homogeneity

Join the StudySmarter App and learn efficiently with millions of flashcards and more!

Keep learning, you are doing great.

Discover learning materials with the free StudySmarter app

1

About StudySmarter

StudySmarter is a globally recognized educational technology company, offering a holistic learning platform designed for students of all ages and educational levels. Our platform provides learning support for a wide range of subjects, including STEM, Social Sciences, and Languages and also helps students to successfully master various tests and exams worldwide, such as GCSE, A Level, SAT, ACT, Abitur, and more. We offer an extensive library of learning materials, including interactive flashcards, comprehensive textbook solutions, and detailed explanations. The cutting-edge technology and tools we provide help students create their own learning materials. StudySmarter’s content is not only expert-verified but also regularly updated to ensure accuracy and relevance.

Chi Square Test for Homogeneity

StudySmarter Editorial Team

Team Math Teachers

  • 19 minutes reading time
  • Checked by StudySmarter Editorial Team

Study anywhere. Anytime.Across all devices.

Create a free account to save this explanation..

Save explanations to your personalised space and access them anytime, anywhere!

By signing up, you agree to the Terms and Conditions and the Privacy Policy of StudySmarter.

Sign up to highlight and take notes. It’s 100% free.

Join over 22 million students in learning with our StudySmarter App

The first learning app that truly has everything you need to ace your exams in one place

  • Flashcards & Quizzes
  • AI Study Assistant
  • Study Planner
  • Smart Note-Taking

Join over 22 million students in learning with our StudySmarter App

Get unlimited access with a free StudySmarter account.

  • Instant access to millions of learning materials.
  • Flashcards, notes, mock-exams, AI tools and more.
  • Everything you need to ace your exams.

Second Popup Banner

Statology

Statistics Made Easy

Chi-Square Test of Independence: Definition, Formula, and Example

A Chi-Square Test of Independence  is used to determine whether or not there is a significant association between two categorical variables.

This tutorial explains the following:

  • The motivation for performing a Chi-Square Test of Independence.
  • The formula to perform a Chi-Square Test of Independence.
  • An example of how to perform a Chi-Square Test of Independence.

Chi-Square Test of Independence: Motivation

A Chi-Square test of independence can be used to determine if there is an association between two categorical variables in a many different settings. Here are a few examples:

  • We want to know if gender is associated with political party preference so we survey 500 voters and record their gender and political party preference.
  • We want to know if a person’s favorite color is associated with their favorite sport so we survey 100 people and ask them about their preferences for both.
  • We want to know if education level and marital status are associated so we collect data about these two variables on a simple random sample of 50 people.

In each of these scenarios we want to know if two categorical variables are associated with each other. In each scenario, we can use a Chi-Square test of independence to determine if there is a statistically significant association between the variables. 

Chi-Square Test of Independence: Formula

A Chi-Square test of independence uses the following null and alternative hypotheses:

  • H 0 : (null hypothesis)  The two variables are independent.
  • H 1 : (alternative hypothesis)  The two variables are not independent. (i.e. they are associated)

We use the following formula to calculate the Chi-Square test statistic X 2 :

X 2 = Σ(O-E) 2  / E

  • Σ:  is a fancy symbol that means “sum”
  • O:  observed value
  • E:  expected value

If the p-value that corresponds to the test statistic X 2  with (#rows-1)*(#columns-1) degrees of freedom is less than your chosen significance level then you can reject the null hypothesis.

Chi-Square Test of Independence: Example

Suppose we want to know whether or not gender is associated with political party preference. We take a simple random sample of 500 voters and survey them on their political party preference. The following table shows the results of the survey:

 
120 90 40 250
110 95 45 250
230 185 85 500

Use the following steps to perform a Chi-Square test of independence to determine if gender is associated with political party preference.

Step 1: Define the hypotheses.

We will perform the Chi-Square test of independence using the following hypotheses:

  • H 0 :  Gender and political party preference are independent.
  • H 1 : Gender and political party preference are  not independent.

Step 2: Calculate the expected values.

Next, we will calculate the expected values for each cell in the contingency table using the following formula:

Expected value = (row sum * column sum) / table sum.

For example, the expected value for Male Republicans is: (230*250) / 500 =  115 .

We can repeat this formula to obtain the expected value for each cell in the table:

 
115 92.5 42.5 250
115 92.5 42.5 250
230 185 85 500

Step 3: Calculate (O-E) 2  / E for each cell in the table.

Next we will calculate  (O-E) 2  / E  for each cell in the table  where:

For example, Male Republicans would have a value of: (120-115) 2 /115 =  0.2174 .

We can repeat this formula for each cell in the table:

 
0.2174 0.0676 0.1471
0.2174 0.0676 0.1471

Step 4: Calculate the test statistic X 2  and the corresponding p-value.

X 2  = Σ(O-E) 2  / E = 0.2174 + 0.2174 + 0.0676 + 0.0676 + 0.1471 + 0.1471 =  0.8642

According to the Chi-Square Score to P Value Calculator , the p-value associated with X 2  = 0.8642 and (2-1)*(3-1) = 2 degrees of freedom is  0.649198 .

Step 5: Draw a conclusion.

Since this p-value is not less than 0.05, we fail to reject the null hypothesis. This means we do not have sufficient evidence to say that there is an association between gender and political party preference.

Note:  You can also perform this entire test by simply using the Chi-Square Test of Independence Calculator .

Additional Resources

The following tutorials explain how to perform a Chi-Square test of independence using different statistical programs:

How to Perform a Chi-Square Test of Independence in Stata How to Perform a Chi-Square Test of Independence in Excel How to Perform a Chi-Square Test of Independence in SPSS How to Perform a Chi-Square Test of Independence in Python How to Perform a Chi-Square Test of Independence in R Chi-Square Test of Independence on a TI-84 Calculator Chi-Square Test of Independence Calculator

Featured Posts

null and alternative hypothesis for chi square test for homogeneity

Hey there. My name is Zach Bobbitt. I have a Masters of Science degree in Applied Statistics and I’ve worked on machine learning algorithms for professional businesses in both healthcare and retail. I’m passionate about statistics, machine learning, and data visualization and I created Statology to be a resource for both students and teachers alike.  My goal with this site is to help you learn statistics through using simple terms, plenty of real-world examples, and helpful illustrations.

One Reply to “Chi-Square Test of Independence: Definition, Formula, and Example”

what test do I use if there are 2 categorical variables and one categorical DV? as in I want to test political attitudes and beliefs in conspiracies and how they affect Covid conspiracy thinking

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Join the Statology Community

Sign up to receive Statology's exclusive study resource: 100 practice problems with step-by-step solutions. Plus, get our latest insights, tutorials, and data analysis tips straight to your inbox!

By subscribing you accept Statology's Privacy Policy.

null and alternative hypothesis for chi square test for homogeneity

Snapsolve any problem by taking a picture. Try it in the Numerade app?

COMMENTS

  1. 11.5: Test for Homogeneity

    To calculate the test statistic for a test for homogeneity, follow the same procedure as with the test of independence. The expected value for each cell needs to be at least five in order for you to use this test. Hypotheses. H0 H 0: The distributions of the two populations are the same. Ha H a: The distributions of the two populations are not ...

  2. Chi-Square Homogeneity Test

    This lesson describes when and how to conduct a chi-square test of homogeneity. Key points are illustrated by a sample problem with solution. Stat Trek. ... The first step is to state the null hypothesis and an alternative hypothesis. Null hypothesis: The null hypothesis states that the proportion of boys who prefer the Lone Ranger is identical ...

  3. 11.9: Test of Homogeneity

    For all chi-square tests, the chi-square test statistic χ 2 is the same. It measures how far the observed data are from the null hypothesis by comparing observed counts and expected counts. Expected counts are the counts we expect to see if the null hypothesis is true. The chi-square model is a family of curves that depend on degrees of freedom.

  4. 17.1

    follows an approximate chi-square distribution with k−1 degrees of freedom. Reject the null hypothesis of equal proportions if Q is large, that is, if: \(Q \ge \chi_{\alpha, k-1}^{2}\) Proof. For the sake of concreteness, let's again use the framework of our example above to derive the chi-square test statistic.

  5. 5.2: Homogeneity test hypotheses

    To make this concrete, consider what the proportions could look like if they satisfied the null hypothesis for the Arthritis example, as displayed in Figure 5.4. Stacked bar charts provide a natural way to visualize the null hypothesis (equal distributions) to compare to the observed proportions in the observed data.

  6. Chi-Square Test of Homogeneity

    Conduct a chi-square test of homogeneity and interpret the conclusion in context. The goodness-of-fit test can be used to decide whether a population fits a given distribution, but it will not suffice to decide whether two populations follow the same unknown distribution. A different test, called the test for homogeneity, can be used to ...

  7. Introduction to the chi-square test for homogeneity

    5 years ago. The first difference is that Chi-Square Tests are used for CATEGORICAL variables rather than Z and T which use QUANTITATIVE Variables. Another difference is that Chi-Square homogeneity is used to compare how data compares to the true KNOWN value and basic (observed-expected)^2/expected is used based on CELL COUNTS not means. On the ...

  8. Test of Homogeneity, Chi-Square

    The chi-square test of homogeneity is the nonparametric test used in a situation where the dependent variable is categorical. Data can be presented using a contingency table in which populations and categories of the variable are the row and column labels. The null hypothesis states that all populations are homogeneous regarding the proportions ...

  9. Chi-Square

    A chi-square test for homogeneity is a test to see if different distributions are similar to each other. Steps: 1. Define your hypotheses. Ho: The distributions are the same among all the given populations. Ha: The distributions differ among all the given populations. 2. Find the expected counts: For each cell, multiply the sum of the column it ...

  10. Chi-Square Test for Homogeneity

    Step 6 Perform test chi-square test: , Since , i.e. 19.0221 > 5.99, Then we assume that the null hypothesis of equaly proportions must be rejected Make Conclusion or inference: We conclude that the three ads are not equally easy to remembered. So H a (alternate hypothesis) is favored by this test. 3.

  11. Test of Homogeneity

    In the test of homogeneity, we select random samples from each subgroup or population separately and collect data on a single categorical variable. The null hypothesis says that the distribution of the categorical variable is the same for each subgroup or population. Both tests use the same chi-square test statistic.

  12. Identifying the Hypotheses for a Chi-Square Test of Homogeneity

    Alternative Hypothesis: The alternative hypothesis for a chi-square test of homogeneity is that the populations are nonhomogeneous with respect to the given variable. That is, the alternative ...

  13. Hypothesis Testing

    We then determine the appropriate test statistic for the hypothesis test. The formula for the test statistic is given below. Test Statistic for Testing H0: p1 = p 10 , p2 = p 20 , ..., pk = p k0. We find the critical value in a table of probabilities for the chi-square distribution with degrees of freedom (df) = k-1.

  14. 11.6: Test for Homogeneity

    The graph of the Chi-square shows the distribution and marks the critical value with three degrees of freedom at 95% level of confidence, \(\alpha = 0.05\), 7.815. The graph also marks the calculated \(\chi^2\) test statistic of 10.129. Comparing the test statistic with the critical value, as we have done with all other hypothesis tests, we ...

  15. Chi-Square (Χ²) Tests

    Example: Chi-square test of independence. Null hypothesis (H 0): The proportion of people who are left-handed is the same for Americans and Canadians. Alternative hypothesis (H A): The proportion of people who are left-handed differs between nationalities. Other types of chi-square tests

  16. Chapter 11.5: Test for Homogeneity

    State the null and alternative hypotheses, ... you can apply the test for homogeneity that uses the chi-square distribution. The null hypothesis for this test states that the populations of the two data sets come from the same distribution. The test compares the observed values against the expected values if the two populations followed the ...

  17. Chi-square Test for Homogeneity

    The Chi-square test for homogeneity involves setting up two hypotheses, the null hypothesis and the alternative hypothesis, to guide the statistical analysis Calculation of Test Statistic To perform the Chi-square test, expected frequencies for each category within each group are calculated, and the Chi-square statistic is computed to quantify ...

  18. Chi Square Test for Homogeneity: Examples

    A Chi-square test for homogeneity is a Chi-square test that is applied to a single categorical variable from two or more different populations to determine whether they have the same distribution. This test has the same basic conditions as any other Pearson Chi-square test; The variables must be categorical. Groups must be mutually exclusive.

  19. Chi-Squared Test: Revealing Hidden Patterns in Your Data

    There are two types of chi-squared tests, the chi-squared goodness-of-fit test and the chi-squared test of a contingency table. Each of these types has a different purpose when tackling the hypothesis test. In parallel with the theoretical approach of each test, I'll show you how to demonstrate those two tests in practical examples.

  20. Chi-Square Test of Independence: Definition, Formula, and Example

    A Chi-Square test of independence uses the following null and alternative hypotheses: H0: (null hypothesis) The two variables are independent. H1: (alternative hypothesis) The two variables are not independent. (i.e. they are associated) We use the following formula to calculate the Chi-Square test statistic X2: X2 = Σ (O-E)2 / E.

  21. 12.3: A Test of Independence or Homogeneity

    In a test of independence, we state the null and alternative hypotheses in words. Since the contingency table consists of two factors, the null hypothesis states that the factors are independent and the alternative hypothesis states that they are not independent (dependent). If we do a test of independence using the example, then the null ...

  22. State the null and alternative hypotheses for a chi-square homogeneity test

    The alternative hypothesis is a statement that the observed difference in data is due to a relationship in the population and not due to chance alone. Step 2/4 Step 2: For a chi-square homogeneity test, the null hypothesis and alternative hypothesis are defined in terms of the distribution of a designated variable across different populations ...

  23. Diego uses a chi-square test of independence to test whether ...

    Formulate the null hypothesis (\(H_0\)). The null hypothesis for a chi-square test of independence states that there is no association between the two categorical variables. In other words, the distribution of one variable is independent of the distribution of the other variable. Step 4/6 Express the null hypothesis in the context of the study.

  24. 11.3: Test of a Single Variance

    The null and alternative hypotheses are thus: H0:σ2=0.04𝐻0:𝜎2=0.04. H0:σ2≠0.04𝐻0:𝜎2≠0.04. The test is set up as a two-tailed test because Professor Hadley has shown concern with too much variation in filling as well as too little: his dislike of a surprise is any level of filling outside the expected average of 0.04 cups.