LEARN STATISTICS EASILY

LEARN STATISTICS EASILY

Learn Data Analysis Now!

LEARN STATISTICS EASILY LOGO 2

Understanding the Null Hypothesis in Chi-Square

The null hypothesis in chi square testing suggests no significant difference between a study’s observed and expected frequencies. It assumes any observed difference is due to chance and not because of a meaningful statistical relationship.

Introduction

The chi-square test is a valuable tool in statistical analysis. It’s a non-parametric test applied when the data are qualitative or categorical. This test helps to establish whether there is a significant association between 2 categorical variables in a sample population.

Central to any chi-square test is the concept of the null hypothesis. In the context of chi-square, the null hypothesis assumes no significant difference exists between the categories’ observed and expected frequencies. Any difference seen is likely due to chance or random error rather than a meaningful statistical difference.

  • The chi-square null hypothesis assumes no significant difference between observed and expected frequencies.
  • Failing to reject the null hypothesis doesn’t prove it true, only that data lacks strong evidence against it.
  • A p-value < the significance level indicates a significant association between variables.

 width=

Ad description. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Understanding the Concept of Null Hypothesis in Chi Square

The null hypothesis in chi-square tests is essentially a statement of no effect or no relationship. When it comes to categorical data, it indicates that the distribution of categories for one variable is not affected by the distribution of categories of the other variable.

For example, if we compare the preference for different types of fruit among men and women, the null hypothesis would state that the preference is independent of gender. The alternative hypothesis, on the other hand, would suggest a dependency between the two.

Steps to Formulate the Null Hypothesis in Chi-Square Tests

Formulating the null hypothesis is a critical step in any chi-square test. First, identify the variables being tested. Then, once the variables are determined, the null hypothesis can be formulated to state no association between them.

Next, collect your data. This data must be frequencies or counts of categories, not percentages or averages. Once the data is collected, you can calculate the expected frequency for each category under the null hypothesis.

Finally, use the chi-square formula to calculate the chi-square statistic. This will help determine whether to reject or fail to reject the null hypothesis.

Step Description
1. Identify Variables Determine the variables being tested in your study.
2. State the Null Hypothesis Formulate the null hypothesis to state that there is no association between the variables.
3. Collect Data Gather your data. Remember, this must be frequencies or counts of categories, not percentages or averages.
4. Calculate Expected Frequencies Under the null hypothesis, calculate the expected frequency for each category.
5. Compute Chi Square Statistic Use the chi square formula to calculate the chi square statistic. This will help determine whether to reject or fail to reject the null hypothesis.

Practical Example and Case Study

Consider a study evaluating whether smoking status is independent of a lung cancer diagnosis. The null hypothesis would state that smoking status (smoker or non-smoker) is independent of cancer diagnosis (yes or no).

If we find a p-value less than our significance level (typically 0.05) after conducting the chi-square test, we would reject the null hypothesis and conclude that smoking status is not independent of lung cancer diagnosis, suggesting a significant association between the two.

Observed Table

Smoking Status Cancer Diagnosis No Cancer Diagnosis
Smoker 70 30
Non-Smoker 20 80

Expected Table

Smoking Status Cancer Diagnosis No Cancer Diagnosis
Smoker 50 50
Non-Smoker 40 60

Common Misunderstandings and Pitfalls

One common misunderstanding is the interpretation of failing to reject the null hypothesis. It’s important to remember that failing to reject the null does not prove it true. Instead, it merely suggests that our data do not provide strong enough evidence against it.

Another pitfall is applying the chi-square test to inappropriate data. The chi-square test requires categorical or nominal data. Applying it to ordinal or continuous data without proper binning or categorization can lead to incorrect results.

The null hypothesis in chi-square testing is a powerful tool in statistical analysis. It provides a means to differentiate between observed variations due to random chance versus those that may signify a significant effect or relationship. As we continue to generate more data in various fields, the importance of understanding and correctly applying chi-square tests and the concept of the null hypothesis grows.

Recommended Articles

Interested in diving deeper into statistics? Explore our range of statistical analysis and data science articles to broaden your understanding. Visit our blog now!

  • Simple Null Hypothesis – an overview (External Link)
  • Chi-Square Calculator: Enhance Your Data Analysis Skills
  • Effect Size for Chi-Square Tests: Unveiling its Significance
  • What is the Difference Between the T-Test vs. Chi-Square Test?
  • Understanding the Assumptions for Chi-Square Test of Independence
  • How to Report Chi-Square Test Results in APA Style: A Step-By-Step Guide

Frequently Asked Questions (FAQs)

It’s a statistical test used to determine if there’s a significant association between two categorical variables.

The null hypothesis suggests no significant difference between observed and expected frequencies exists. The alternative hypothesis suggests a significant difference.

No, we never “accept” the null hypothesis. We only fail to reject it if the data doesn’t provide strong evidence against it.

Rejecting the null hypothesis implies a significant difference between observed and expected frequencies, suggesting an association between variables.

Chi-Square tests are appropriate for categorical or nominal data.

The significance level, often 0.05, is the probability threshold below which the null hypothesis can be rejected.

A p-value < the significance level indicates a significant association between variables, leading to rejecting the null hypothesis.

Using the Chi-Square test for improper data, like ordinal or continuous data, without proper categorization can lead to incorrect results.

Identify the variables, state their independence, collect data, calculate expected frequencies, and apply the Chi-Square formula.

Understanding the null hypothesis is essential for correctly interpreting and applying Chi-Square tests, helping to make informed decisions based on data.

Similar Posts

random sampling on excel

Random Sampling on Excel: An In-depth Analysis

Unlock the potential of random sampling on Excel. Discover the key to efficient, reliable data analysis and actionable statistical insights.

sampling error

Understanding Sampling Error: A Foundation in Statistical Analysis

Understand the concept of sampling error, its impacts, and strategies to mitigate it in statistical analysis and data science.

types of logistic regression

What Are The 3 Types of Logistic Regression?

Discover the three types of logistic regression: Binary, Ordinal, and Multinomial. Understand their unique applications in statistical analysis and data science.

goodness-of-fit

What is Goodness-of-Fit? A Comprehensive Guide

Learn about goodness-of-fit, its importance in assessing statistical models, various tests, and how to apply them for accurate predictions and inferences.

statistics and fake news

Statistics And Fake News: A Deeper Look

Statistics And Fake News: Understand Why The [Mis]Use Of Statistics Can Significantly Impact The Acceptance As Truth Of Fake News.

selection bias

Selection Bias in Data Analysis: Understanding the Intricacies

Discover the intricacies of selection bias in data analysis, its real-world implications, detection methods, and mitigation strategies.

Leave a Reply Cancel reply

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

Save my name, email, and website in this browser for the next time I comment.

when is null hypothesis rejected chi square

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:

when is null hypothesis rejected chi square

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.

Header Logo

Unlocking the Power of Chi-Square Test : Accept or Reject Null Hypothesis

thumbnail image for chi square test blog , from BigDataElearning

Are you curious about this mysterious Chi-Square test in Data Science?

Scratching your head about how to make sense of Chi Square results in machine learning ?  

when is null hypothesis rejected chi square

So, if you're wondering what this Chi-Square test in Data Science is all about and how to make sense of its results, put on your detective hat & read the below article In this article we will look into the following

What is the “Chi Square Test”?

Step - 1 : formula behind the chi-square test, step - 2 : decoding the chi-square table, step - 3 : rejecting the null hypothesis with confidence using chi square test.

“Data Science Made Simple: Learn It All Through 20 Engaging Infographics (Completely Free)"

  "Chi Square Test in Data Science helps you to evaluate whether a null hypothesis (or) assumption made is valid (or) is it something that can be rejected?"

Imagine you own a restaurant, and you have an assumption on the occupancy of your restaurant You have a suspicion that certain days might have more customers compared to others. Based on that you assume the number of customers will be more on Thursday & Friday and you have laid out the expected occupancy numbers over monday through saturday as below. Note in below table where Thu & Fri has “40” & “60” expected count, higher than other days

when is null hypothesis rejected chi square

To investigate further on this, you decide to conduct a study over a week and record the number of customers who actually visit your restaurant each day. 

You have recorded/observed values as below to the table.

when is null hypothesis rejected chi square

Note that the observed count (20) is lesser than the expected count (30) on Monday.   Based on the above expected & observed count recorded on a table, chi-square test in data science will help you to determine whether your assumption holds good or not. So in this case, the null hypothesis and alternative hypothesis are as below.

  • Null hypothesis (H₀) : There is no significant difference between the expected and observed occupancies. This means your assumption holds good.
  • Alternative hypothesis (H₁) : There is a significant difference between the expected and observed occupancies. This means your assumption does not hold good.  

Check hypothesis vs null hypothesis blog to read more about this

3-Step “Chi Square Test”Process

Now, let's consider the Chi-Square test in machine learning as a tool that helps you determine whether there is a significant difference between what you expected and what you observed. Before using the Chi square tool, you need to know that it contains 3 steps.

Step -1 : Formula behind the Chi Square test : Calculate the statistical value using a Chi Square formula.

Step -2 : Decoding the Chi Square Table : Get the value from the Chi square distribution table

Step -3 : Rejecting the Null Hypothesis : Compare above 2 values (calculated statistical value & value from chi square distribution table) to determine whether to reject null hypothesis or not.

The formula for the chi-square test statistic in this case is:

χ² = Σ((Oᵢ - Eᵢ)² / Eᵢ)

  • χ² is the chi-square test statistic
  • Oᵢ is the observed frequency for each category
  • Eᵢ is the expected frequency for each category (based on the theoretical distribution)

when is null hypothesis rejected chi square

In your restaurant occupancy test, you should use the above formula to determine whether to reject the null hypothesis or not. In this case, the observed frequencies are: 20, 20, 30, 40, 60, 30.  The expected frequencies are 30, 20, 30, 40, 60, 30.  Plugging in the values from your data, the calculations would look like this:

  χ² = ((20 - 30)² / 30) + ((20 - 20)² / 20) + ((30 - 30)² / 30) + ((40 - 40)² / 40) + ((60 - 60)² / 60) + ((30 - 30)² / 30)

  Simplifying further:

  χ² = ((-10)² / 30) + (0² / 20) + (0² / 30) + (0² / 40) + (0² / 60) + (0² / 30)

  χ² = 100/30 + 0 + 0 + 0 + 0 + 0

  χ² = 3.333 Now using the chi square calculation formula in data science, you have calculated the chi square statistic value as 3.333 for the above restaurant occupancy study.

Now that you have calculated the chi square statistical value, let’s look at how you can get the value from the chi square distribution table. The actual Chi-square distribution table shown below, contains values for a wider range of “ level of significance ” and “degrees of freedom”. In the table, the rows represent “degrees of freedom”, and each column represents the “level of significance”. 

The degrees of freedom for a chi-square test in machine learning are calculated as (number of categories - 1). In your case, there are 6 categories or 6 days (Mon - Sat), so df = 6 - 1 = 5. If you notice in the below image,  the Chi square statistic value for a test, with “0.05” level of significance & with degrees of freedom “5” is 11.070

Note this value 11.070

when is null hypothesis rejected chi square

Image source: https://statisticsbyjim.com/hypothesis-testing/chi-square-table/

Now that you have calculated the chi square statistic value as 3.333 and retrieved the value from the chi square distribution table as 11.070, let’s see how you can determine whether to reject the null hypothesis or not using it.

This is very simple.  If the calculated chi square statistic is greater than the critical value from the distribution table then you can reject the null hypothesis. If not, you fail to reject the null hypothesis.

In this scenario, when comparing the calculated chi-square test statistic (3.333) with the critical value (11.070), what do you arrive at? 

You can see that the calculated value is smaller than the critical value, right?

when is null hypothesis rejected chi square

Therefore, you would fail to reject the null hypothesis, indicating that there is no significant difference between the expected and observed occupancies at a significance level of 0.05 and degrees of freedom of 5. If you fail to reject the null hypothesis, it means that the null hypothesis/your assumption holds good 🙂. This means that expected occupancy is in sync with the observed occupancy. This means what you assumed/expected to be the occupancy of your restaurant is correct with a significance level of 0.05.

Let's review the main points about Chi-Square testing:

  • Chi Square's Role:  We looked at the "chi square test" as a tool in statistics. It helps decide if the null hypothesis is true, which is important in data science.
  • Three-Step Process:  We discussed three steps for using Chi-Square. This includes calculating with the Chi-Square formula, checking the Chi-Square table, and comparing values to validate hypotheses.
  • Null Hypothesis Validation:  We gave an example where the calculated value was lower than the critical value. This led to accepting the null hypothesis.
  • Confirmation of Assumptions:  Lastly, we checked if the assumed occupancy for the restaurant was valid. This supported the null hypothesis.

Get INSTANT ACCESS to This Proven Roadmap To Become a Data Scientist in 90 Days,

Even Without Prior Data Science Experience - Guaranteed.

Question For You

The observed frequencies of a categorical variable in a study are as follows: 

category A (45), category B (60), category C (35). 

The expected frequencies based on the null hypothesis are: category A (50), category B (50), category C (50). 

Tell me in the comments whether we can reject the null hypothesis or not using a significance level of 0.05?

Stay connected with weekly strategy emails!

Join our mailing list & be the first to receive blogs like this to your inbox & much more.

Don't worry, your information will not be shared.

Stay Connected!

Choose your course.

Learn the free courses that preps you to a rewarding Data Science career

Search Topics

when is null hypothesis rejected chi square

The Data Science Aspirant's 

90-day proven roadmap, get instant access to this proven  roadmap to become a data scientist in 90 days ,  even without  prior data science experience - guaranteed..

when is null hypothesis rejected chi square

What is in the Roadmap?

"join 10,243 data scientists who aced their data science interview by following this roadmap".

⬇️  Enter your email below and click "Send Me My FREE Roadmap" button

when is null hypothesis rejected chi square

Join 10,243 subscribers & get weekly article like this.

Don’t worry. We don’t share your email with anyone else. We hate spam too. One click unsubscribe

Library homepage

  • school Campus Bookshelves
  • menu_book Bookshelves
  • perm_media Learning Objects
  • login Login
  • how_to_reg Request Instructor Account
  • hub Instructor Commons

Margin Size

  • Download Page (PDF)
  • Download Full Book (PDF)
  • Periodic Table
  • Physics Constants
  • Scientific Calculator
  • Reference & Cite
  • Tools expand_more
  • Readability

selected template will load here

This action is not available.

Statistics LibreTexts

11.1: Chi-Square Tests for Independence

  • Last updated
  • Save as PDF
  • Page ID 513

\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

\( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)

( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)

\( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

\( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)

\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

\( \newcommand{\Span}{\mathrm{span}}\)

\( \newcommand{\id}{\mathrm{id}}\)

\( \newcommand{\kernel}{\mathrm{null}\,}\)

\( \newcommand{\range}{\mathrm{range}\,}\)

\( \newcommand{\RealPart}{\mathrm{Re}}\)

\( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

\( \newcommand{\Argument}{\mathrm{Arg}}\)

\( \newcommand{\norm}[1]{\| #1 \|}\)

\( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)

\( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

\( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

\( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

\( \newcommand{\vectorC}[1]{\textbf{#1}} \)

\( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

\( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

\( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

Learning Objectives

  • To understand what chi-square distributions are.
  • To understand how to use a chi-square test to judge whether two factors are independent.

Chi-Square Distributions

As you know, there is a whole family of \(t\)-distributions, each one specified by a parameter called the degrees of freedom, denoted \(df\). Similarly, all the chi-square distributions form a family, and each of its members is also specified by a parameter \(df\), the number of degrees of freedom. Chi is a Greek letter denoted by the symbol \(\chi\) and chi-square is often denoted by \(\chi^2\).

5a0c7bbacb4242555e8a85c9767c03ee.jpg

Figure \(\PageIndex{1}\) shows several \(\chi\)-square distributions for different degrees of freedom. A chi-square random variable is a random variable that assumes only positive values and follows a \(\chi\)-square distribution.

Definition: critical value

The value of the chi-square random variable \(\chi^2\) with \(df=k\) that cuts off a right tail of area \(c\) is denoted \(\chi_c^2\) and is called a critical value (Figure \(\PageIndex{2}\)).

(\chi_c^2\) Illustrated

Figure \(\PageIndex{3}\) below gives values of \(\chi_c^2\) for various values of \(c\) and under several chi-square distributions with various degrees of freedom.

chi-square distribution.jpg

Tests for Independence

Hypotheses tests encountered earlier in the book had to do with how the numerical values of two population parameters compared. In this subsection we will investigate hypotheses that have to do with whether or not two random variables take their values independently, or whether the value of one has a relation to the value of the other. Thus the hypotheses will be expressed in words, not mathematical symbols. We build the discussion around the following example.

There is a theory that the gender of a baby in the womb is related to the baby’s heart rate: baby girls tend to have higher heart rates. Suppose we wish to test this theory. We examine the heart rate records of \(40\) babies taken during their mothers’ last prenatal checkups before delivery, and to each of these \(40\) randomly selected records we compute the values of two random measures: 1) gender and 2) heart rate. In this context these two random measures are often called factors. Since the burden of proof is that heart rate and gender are related, not that they are unrelated, the problem of testing the theory on baby gender and heart rate can be formulated as a test of the following hypotheses:

\[H_0: \text{Baby gender and baby heart rate are independent}\\ vs. \\ H_a: \text{Baby gender and baby heart rate are not independent} \nonumber \]

The factor gender has two natural categories or levels: boy and girl. We divide the second factor, heart rate, into two levels, low and high, by choosing some heart rate, say \(145\) beats per minute, as the cutoff between them. A heart rate below \(145\) beats per minute will be considered low and \(145\) and above considered high. The \(40\) records give rise to a \(2\times 2\) contingency table . By adjoining row totals, column totals, and a grand total we obtain the table shown as Table \(\PageIndex{1}\). The four entries in boldface type are counts of observations from the sample of \(n = 40\). There were \(11\) girls with low heart rate, \(17\) boys with low heart rate, and so on. They form the core of the expanded table.

Table \(\PageIndex{1}\): Baby Gender and Heart Rate
Heart Rate
\(\text{Low}\) \(\text{High}\) \(\text{Row Total}\)
\(\text{Gender}\) \(\text{Girl}\) \(11\) \(7\) \(18\)
\(\text{Boy}\) \(17\) \(5\) \(22\)
\(\text{Column Total}\) \(28\) \(12\) \(\text{Total}=40\)

In analogy with the fact that the probability of independent events is the product of the probabilities of each event, if heart rate and gender were independent then we would expect the number in each core cell to be close to the product of the row total \(R\) and column total \(C\) of the row and column containing it, divided by the sample size \(n\). Denoting such an expected number of observations \(E\), these four expected values are:

  • 1 st row and 1 st column: \(E=(R\times C)/n = 18\times 28 /40 = 12.6\)
  • 1 st row and 2 nd column: \(E=(R\times C)/n = 18\times 12 /40 = 5.4\)
  • 2 nd row and 1 st column: \(E=(R\times C)/n = 22\times 28 /40 = 15.4\)
  • 2 nd row and 2 nd column: \(E=(R\times C)/n = 22\times 12 /40 = 6.6\)

We update Table \(\PageIndex{1}\) by placing each expected value in its corresponding core cell, right under the observed value in the cell. This gives the updated table Table \(\PageIndex{2}\).

Table \(\PageIndex{2}\): Updated Baby Gender and Heart Rate
\(\text{Heart Rate}\)
\(\text{Low}\) \(\text{High}\) \(\text{Row Total}\)
\(\text{Gender}\) \(\text{Girl}\)

\(O=11\)

\(E=12.6\)

\(O=7\)

\(E=5.4\)

\(R = 18\)
\(\text{Boy}\)

\(O=17\)

\(E=15.4\)

\(O=5\)

\(E=6.6\)

\(R = 22\)
\(\text{Column Total}\) \(C = 28\) \(C = 12\) \(n = 40\)

A measure of how much the data deviate from what we would expect to see if the factors really were independent is the sum of the squares of the difference of the numbers in each core cell, or, standardizing by dividing each square by the expected number in the cell, the sum \(\sum (O-E)^2 / E\). We would reject the null hypothesis that the factors are independent only if this number is large, so the test is right-tailed. In this example the random variable \(\sum (O-E)^2 / E\) has the chi-square distribution with one degree of freedom. If we had decided at the outset to test at the \(10\%\) level of significance, the critical value defining the rejection region would be, reading from Figure \(\PageIndex{3}\), \(\chi _{\alpha }^{2}=\chi _{0.10 }^{2}=2.706\), so that the rejection region would be the interval \([2.706,\infty )\). When we compute the value of the standardized test statistic we obtain

\[\sum \frac{(O-E)^2}{E}=\frac{(11-12.6)^2}{12.6}+\frac{(7-5.4)^2}{5.4}+\frac{(17-15.4)^2}{15.4}+\frac{(5-6.6)^2}{6.6}=1.231 \nonumber \]

Since \(1.231 < 2.706\), the decision is not to reject \(H_0\). See Figure \(\PageIndex{4}\). The data do not provide sufficient evidence, at the \(10\%\) level of significance, to conclude that heart rate and gender are related.

alt

Fig ure \(\PageIndex{4}\) : Baby Gender Prediction

H 0 vs .   H a : : Baby   gender   and   baby   heart   rate   are   independent Baby   gender   and   baby   heart   rate   are   n o t   independent H 0 vs .   H a : : Baby   gender   and   baby   heart   rate   are   independent Baby   gender   and   baby   heart   rate   are   n o t   independent

With this specific example in mind, now turn to the general situation. In the general setting of testing the independence of two factors, call them Factor \(1\) and Factor \(2\), the hypotheses to be tested are

\[H_0: \text{The two factors are independent}\\ vs. \\ H_a: \text{The two factors are not independent} \nonumber \]

As in the example each factor is divided into a number of categories or levels. These could arise naturally, as in the boy-girl division of gender, or somewhat arbitrarily, as in the high-low division of heart rate. Suppose Factor \(1\) has \(I\) levels and Factor \(2\) has \(J\) levels. Then the information from a random sample gives rise to a general \(I\times J\) contingency table, which with row totals, column totals, and a grand total would appear as shown in Table \(\PageIndex{3}\). Each cell may be labeled by a pair of indices \((i,j)\). \(O_{ij}\) stands for the observed count of observations in the cell in row \(i\) and column \(j\), \(R_i\) for the \(i^{th}\) row total and \(C_j\) for the \(j^{th}\) column total. To simplify the notation we will drop the indices so Table \(\PageIndex{3}\) becomes Table \(\PageIndex{4}\). Nevertheless it is important to keep in mind that the \(Os\), the \(Rs\) and the \(Cs\), though denoted by the same symbols, are in fact different numbers.

Table \(\PageIndex{3}\): General Contingency Table
\(\text{Factor 2 Levels}\)
\(1\)  ⋅ ⋅ ⋅  \(j\)  ⋅ ⋅ ⋅  \(J\) \(\text{Row Total}\)
\(\text{Factor 1 Levels}\) \(1\) \(O_{11}\)  ⋅ ⋅ ⋅  \(O_{1j}\)  ⋅ ⋅ ⋅  \(O_{1J}\) \(R_1\)
\(i\) \(O_{i1}\)  ⋅ ⋅ ⋅  \(O_{ij}\)  ⋅ ⋅ ⋅  \(O_{iJ}\) \(R_i\)
\(I\) \(O_{I1}\)  ⋅ ⋅ ⋅  \(O_{Ij}\)  ⋅ ⋅ ⋅  \(O_{IJ}\) \(R_I\)
\(\text{Column Total}\) \(C_1\)  ⋅ ⋅ ⋅  \(C_j\)  ⋅ ⋅ ⋅  \(C_J\) \(n\)
Table \(\PageIndex{4}\): Simplified General Contingency Table
\(\text{Factor 2 Levels}\)
\(1\)  ⋅ ⋅ ⋅  \(j\)  ⋅ ⋅ ⋅  \(J\) \(\text{Row Total}\)

\(\text{Factor 1 Levels}\)

\(1\) \(O\)  ⋅ ⋅ ⋅  \(O\)  ⋅ ⋅ ⋅  \(O\) \(R\)
\(i\) \(O\)  ⋅ ⋅ ⋅  \(O\)  ⋅ ⋅ ⋅  \(O\) \(R\)
\(I\) \(O\)  ⋅ ⋅ ⋅  \(O\)  ⋅ ⋅ ⋅  \(O\) \(R\)
\(\text{Column Total}\) \(C\)  ⋅ ⋅ ⋅  \(C\)  ⋅ ⋅ ⋅  \(C\) \(n\)

As in the example, for each core cell in the table we compute what would be the expected number \(E\) of observations if the two factors were independent. \(E\) is computed for each core cell (each cell with an \(O\) in it) of Table \(\PageIndex{4}\) by the rule applied in the example:

\[E=R×Cn \nonumber \]

where \(R\) is the row total and \(C\) is the column total corresponding to the cell, and \(n\) is the sample size

Table \(\PageIndex{5}\) Updated General Contingency Table
\(\text{Factor 2 Levels}\)
\(1\)  ⋅ ⋅ ⋅  \(j\)  ⋅ ⋅ ⋅  \(J\) \(\text{Row Total}\)

\(\text{Factor 1 Levels}\)

\(1\)

\(O\)

\(E\)

 ⋅ ⋅ ⋅ 

\(O\)

\(E\)

 ⋅ ⋅ ⋅ 

\(O\)

\(E\)

\(R\)

\(i\)

\(O\)

\(E\)

 ⋅ ⋅ ⋅ 

\(O\)

\(E\)

 ⋅ ⋅ ⋅ 

\(O\)

\(E\)

\(R\)

\(I\)

\(O\)

\(E\)

 ⋅ ⋅ ⋅ 

\(O\)

\(E\)

 ⋅ ⋅ ⋅ 

\(O\)

\(E\)

\(R\)

\(\text{Column Total}\) \(C\)  ⋅ ⋅ ⋅  \(C\)  ⋅ ⋅ ⋅  \(C\) \(n\)

Here is the test statistic for the general hypothesis based on Table \(\PageIndex{5}\), together with the conditions that it follow a chi-square distribution.

Test Statistic for Testing the Independence of Two Factors

\[\chi^2=\sum (O−E)^2E \nonumber \]

where the sum is over all core cells of the table.

  • the two study factors are independent, and
  • the observed count \(O\) of each cell in Table \(\PageIndex{5}\) is at least \(5\),

then \(\chi ^2\) approximately follows a chi-square distribution with \(df=(I-1)\times (J-1)\) degrees of freedom.

The same five-step procedures, either the critical value approach or the \(p\)-value approach, that were introduced in Section 8.1 and Section 8.3 are used to perform the test, which is always right-tailed.

Example \(\PageIndex{1}\)

A researcher wishes to investigate whether students’ scores on a college entrance examination (\(CEE\)) have any indicative power for future college performance as measured by \(GPA\). In other words, he wishes to investigate whether the factors \(CEE\) and \(GPA\) are independent or not. He randomly selects \(n = 100\) students in a college and notes each student’s score on the entrance examination and his grade point average at the end of the sophomore year. He divides entrance exam scores into two levels and grade point averages into three levels. Sorting the data according to these divisions, he forms the contingency table shown as Table \(\PageIndex{6}\), in which the row and column totals have already been computed.

Table \(\PageIndex{6}\):
\(GPA\)
\(<2.7\) \(2.7\; \; \text{to}\; \; 3.2\) \(>3.2\) \(\text{Row Total}\)
\(CEE\) \(<1800\) \(35\) \(12\) \(5\) \(52\)
\(\geq 1800\) \(6\) \(24\) \(18\) \(48\)
\(\text{Column Total}\) \(41\) \(36\) \(23\) \(\text{Total}=100\)

Test, at the \(1\%\) level of significance, whether these data provide sufficient evidence to conclude that \(CEE\) scores indicate future performance levels of incoming college freshmen as measured by \(GPA\).

We perform the test using the critical value approach, following the usual five-step method outlined at the end of Section 8.1.

  • Step 1 . The hypotheses are \[H_0:\text{CEE and GPA are independent factors}\\ vs.\\ H_a:\text{CEE and GPA are not independent factors} \nonumber \]
  • Step 2 . The distribution is chi-square.
  • 1 st row and 1 st column: \(E=(R\times C)/n=41\times 52/100=21.32\)
  • 1 st row and 2 nd column: \(E=(R\times C)/n=36\times 52/100=18.72\)
  • 1 st row and 3 rd column: \(E=(R\times C)/n=23\times 52/100=11.96\)
  • 2 nd row and 1 st column: \(E=(R\times C)/n=41\times 48/100=19.68\)
  • 2 nd row and 2 nd column: \(E=(R\times C)/n=36\times 48/100=17.28\)
  • 2 nd row and 3 rd column: \(E=(R\times C)/n=23\times 48/100=11.04\)

Table \(\PageIndex{6}\) is updated to Table \(\PageIndex{6}\).

Table \(\PageIndex{7}\): Updated CEE versus GPA Contingency Table
\(GPA\)
\(<2.7\) \(2.7\; \; \text{to}\; \; 3.2\) \(>3.2\) \(\text{Row Total}\)
\(CEE\) \(<1800\)

\(O=35\)

\(E=21.32\)

\(O=12\)

\(E=18.72\)

\(O=5\)

\(E=11.96\)

\(R = 52\)
\(\geq 1800\)

\(O=6\)

\(E=19.68\)

\(O=24\)

\(E=17.28\)

\(O=18\)

\(E=11.04\)

\(R = 48\)
\(\text{Column Total}\) \(C = 41\) \(C = 36\) \(C = 23\) \(n = 100\)

The test statistic is

\[\begin{align*} \chi^2 &= \sum \frac{(O-E)^2}{E}\\ &= \frac{(35-21.32)^2}{21.32}+\frac{(12-18.72)^2}{18.72}+\frac{(5-11.96)^2}{11.96}+\frac{(6-19.68)^2}{19.68}+\frac{(24-17.28)^2}{17.28}+\frac{(18-11.04)^2}{11.04}\\ &= 31.75 \end{align*} \nonumber \]

  • Step 4 . Since the \(CEE\) factor has two levels and the \(GPA\) factor has three, \(I = 2\) and \(J = 3\). Thus the test statistic follows the chi-square distribution with \(df=(2-1)\times (3-1)=2\) degrees of freedom.

Since the test is right-tailed, the critical value is \(\chi _{0.01}^{2}\). Reading from Figure 7.1.6 "Critical Values of Chi-Square Distributions", \(\chi _{0.01}^{2}=9.210\), so the rejection region is \([9.210,\infty )\).

  • Step 5 . Since \(31.75 > 9.21\) the decision is to reject the null hypothesis. See Figure \(\PageIndex{5}\). The data provide sufficient evidence, at the \(1\%\) level of significance, to conclude that \(CEE\) score and \(GPA\) are not independent: the entrance exam score has predictive power.

alt

Key Takeaway

  • Critical values of a chi-square distribution with degrees of freedom df are found in Figure 7.1.6.
  • A chi-square test can be used to evaluate the hypothesis that two random variables or factors are independent.
  • Collections & Categories

Step 5 - Interpreting The Results

We are now ready for the final step, interpreting the results of our chi-square calculation. For this we will need to consult a Chi-Square Distribution Table. This is a probability table of selected values of X 2  (Table 3). 

when is null hypothesis rejected chi square

Table 3: Chi-Square Distribution Table.

Statisticians calculate certain possibilities of occurrence (P values) for a X 2  value depending on  degrees of freedom . Degrees of freedom is simply the number of classes that can vary independently minus one, (n-1). In this case the degrees of freedom = 1 because we have 2 phenotype classes: resistant and susceptible.

The calculated value of X 2  from our results can be compared to the values in the table aligned with the specific degrees of freedom we have. This will tell us the probability that the deviations (between what we  expected  to see and what we actually saw) are due to chance alone and our hypothesis or model can be supported.

In our example, the X 2  value of 1.2335 and degrees of freedom of 1 are associated with a P value of less than 0.50, but greater than 0.25 (follow blue dotted line and arrows in Fig. 5). This means that a  chi-square  value this large or larger (or differences between expected and  observed  numbers this great or greater) would occur simply by chance between 25% and 50% of the time.  By convention biologists often use the 5.0% value (p<0.05) to determine if observed deviations are significant. Any deviations greater than this level would cause us to reject our hypothesis and assume something other than chance was at play  (see red circle on Fig. 5). If your chi-square calculated value is greater than the chi-square critical value, then you reject your null hypothesis. If your chi-square calculated value is less than the chi-square critical value, then you "fail to reject" your null hypothesis. 

when is null hypothesis rejected chi square

Figure 5.  Finding the probability value for a chi-square of 1.2335 with 1 degree of freedom . First read down column 1 to find the 1 degree of freedom row and then go to the right to where 1.2335 would occur. This corresponds to a probability of less than 0.5 but greater than 0.25, as indicated by the blue arrows.

Therefore in our tomato breeding example, we failed to reject our hypothesis that resistance to bacterial spot in this set of crosses is due to a single dominantly inherited gene (Rx-4). We can assume that the deviations we saw between what we expected and actually observed in terms of the number of resistant and susceptible plants could be due to mere chance. We can continue working with our current hypothesis. Remember, we have not “proven” our hypothesis at this point. Further testing in other crosses and populations will be used to provide additional evidence that our hypothesis accurately explains the mode of inheritance for Rx-4.

Launch the video tutorial below showing how to use a chi-square distribution chart, using this tomato breeding example.

Next we will go through a genotyping example, or you skip ahead in this lesson to a discussion about computer programs available when you have extensive data, as well as the strengths and weaknesses of the chi-square test.

In a BC 2 S 4  IBC population (inbred backcross) with 197 tomato lines, you observed the following phenotypic data with regards to bacterial spot disease. Calculate a chi-square value for the hypothesis that resistance is dominantly inherited. Would you reject or fail to reject this hypothesis?

  • 169 susceptible to bacterial spot
  • 6 resistant to bacterial spot

What is The Null Hypothesis & When Do You Reject The Null Hypothesis

Julia Simkus

Editor at Simply Psychology

BA (Hons) Psychology, Princeton University

Julia Simkus is a graduate of Princeton University with a Bachelor of Arts in Psychology. She is currently studying for a Master's Degree in Counseling for Mental Health and Wellness in September 2023. Julia's research has been published in peer reviewed journals.

Learn about our Editorial Process

Saul McLeod, PhD

Editor-in-Chief for Simply Psychology

BSc (Hons) Psychology, MRes, PhD, University of Manchester

Saul McLeod, PhD., is a qualified psychology teacher with over 18 years of experience in further and higher education. He has been published in peer-reviewed journals, including the Journal of Clinical Psychology.

Olivia Guy-Evans, MSc

Associate Editor for Simply Psychology

BSc (Hons) Psychology, MSc Psychology of Education

Olivia Guy-Evans is a writer and associate editor for Simply Psychology. She has previously worked in healthcare and educational sectors.

On This Page:

A null hypothesis is a statistical concept suggesting no significant difference or relationship between measured variables. It’s the default assumption unless empirical evidence proves otherwise.

The null hypothesis states no relationship exists between the two variables being studied (i.e., one variable does not affect the other).

The null hypothesis is the statement that a researcher or an investigator wants to disprove.

Testing the null hypothesis can tell you whether your results are due to the effects of manipulating ​ the dependent variable or due to random chance. 

How to Write a Null Hypothesis

Null hypotheses (H0) start as research questions that the investigator rephrases as statements indicating no effect or relationship between the independent and dependent variables.

It is a default position that your research aims to challenge or confirm.

For example, if studying the impact of exercise on weight loss, your null hypothesis might be:

There is no significant difference in weight loss between individuals who exercise daily and those who do not.

Examples of Null Hypotheses

Research QuestionNull Hypothesis
Do teenagers use cell phones more than adults?Teenagers and adults use cell phones the same amount.
Do tomato plants exhibit a higher rate of growth when planted in compost rather than in soil?Tomato plants show no difference in growth rates when planted in compost rather than soil.
Does daily meditation decrease the incidence of depression?Daily meditation does not decrease the incidence of depression.
Does daily exercise increase test performance?There is no relationship between daily exercise time and test performance.
Does the new vaccine prevent infections?The vaccine does not affect the infection rate.
Does flossing your teeth affect the number of cavities?Flossing your teeth has no effect on the number of cavities.

When Do We Reject The Null Hypothesis? 

We reject the null hypothesis when the data provide strong enough evidence to conclude that it is likely incorrect. This often occurs when the p-value (probability of observing the data given the null hypothesis is true) is below a predetermined significance level.

If the collected data does not meet the expectation of the null hypothesis, a researcher can conclude that the data lacks sufficient evidence to back up the null hypothesis, and thus the null hypothesis is rejected. 

Rejecting the null hypothesis means that a relationship does exist between a set of variables and the effect is statistically significant ( p > 0.05).

If the data collected from the random sample is not statistically significance , then the null hypothesis will be accepted, and the researchers can conclude that there is no relationship between the variables. 

You need to perform a statistical test on your data in order to evaluate how consistent it is with the null hypothesis. A p-value is one statistical measurement used to validate a hypothesis against observed data.

Calculating the p-value is a critical part of null-hypothesis significance testing because it quantifies how strongly the sample data contradicts the null hypothesis.

The level of statistical significance is often expressed as a  p  -value between 0 and 1. The smaller the p-value, the stronger the evidence that you should reject the null hypothesis.

Probability and statistical significance in ab testing. Statistical significance in a b experiments

Usually, a researcher uses a confidence level of 95% or 99% (p-value of 0.05 or 0.01) as general guidelines to decide if you should reject or keep the null.

When your p-value is less than or equal to your significance level, you reject the null hypothesis.

In other words, smaller p-values are taken as stronger evidence against the null hypothesis. Conversely, when the p-value is greater than your significance level, you fail to reject the null hypothesis.

In this case, the sample data provides insufficient data to conclude that the effect exists in the population.

Because you can never know with complete certainty whether there is an effect in the population, your inferences about a population will sometimes be incorrect.

When you incorrectly reject the null hypothesis, it’s called a type I error. When you incorrectly fail to reject it, it’s called a type II error.

Why Do We Never Accept The Null Hypothesis?

The reason we do not say “accept the null” is because we are always assuming the null hypothesis is true and then conducting a study to see if there is evidence against it. And, even if we don’t find evidence against it, a null hypothesis is not accepted.

A lack of evidence only means that you haven’t proven that something exists. It does not prove that something doesn’t exist. 

It is risky to conclude that the null hypothesis is true merely because we did not find evidence to reject it. It is always possible that researchers elsewhere have disproved the null hypothesis, so we cannot accept it as true, but instead, we state that we failed to reject the null. 

One can either reject the null hypothesis, or fail to reject it, but can never accept it.

Why Do We Use The Null Hypothesis?

We can never prove with 100% certainty that a hypothesis is true; We can only collect evidence that supports a theory. However, testing a hypothesis can set the stage for rejecting or accepting this hypothesis within a certain confidence level.

The null hypothesis is useful because it can tell us whether the results of our study are due to random chance or the manipulation of a variable (with a certain level of confidence).

A null hypothesis is rejected if the measured data is significantly unlikely to have occurred and a null hypothesis is accepted if the observed outcome is consistent with the position held by the null hypothesis.

Rejecting the null hypothesis sets the stage for further experimentation to see if a relationship between two variables exists. 

Hypothesis testing is a critical part of the scientific method as it helps decide whether the results of a research study support a particular theory about a given population. Hypothesis testing is a systematic way of backing up researchers’ predictions with statistical analysis.

It helps provide sufficient statistical evidence that either favors or rejects a certain hypothesis about the population parameter. 

Purpose of a Null Hypothesis 

  • The primary purpose of the null hypothesis is to disprove an assumption. 
  • Whether rejected or accepted, the null hypothesis can help further progress a theory in many scientific cases.
  • A null hypothesis can be used to ascertain how consistent the outcomes of multiple studies are.

Do you always need both a Null Hypothesis and an Alternative Hypothesis?

The null (H0) and alternative (Ha or H1) hypotheses are two competing claims that describe the effect of the independent variable on the dependent variable. They are mutually exclusive, which means that only one of the two hypotheses can be true. 

While the null hypothesis states that there is no effect in the population, an alternative hypothesis states that there is statistical significance between two variables. 

The goal of hypothesis testing is to make inferences about a population based on a sample. In order to undertake hypothesis testing, you must express your research hypothesis as a null and alternative hypothesis. Both hypotheses are required to cover every possible outcome of the study. 

What is the difference between a null hypothesis and an alternative hypothesis?

The alternative hypothesis is the complement to the null hypothesis. The null hypothesis states that there is no effect or no relationship between variables, while the alternative hypothesis claims that there is an effect or relationship in the population.

It is the claim that you expect or hope will be true. The null hypothesis and the alternative hypothesis are always mutually exclusive, meaning that only one can be true at a time.

What are some problems with the null hypothesis?

One major problem with the null hypothesis is that researchers typically will assume that accepting the null is a failure of the experiment. However, accepting or rejecting any hypothesis is a positive result. Even if the null is not refuted, the researchers will still learn something new.

Why can a null hypothesis not be accepted?

We can either reject or fail to reject a null hypothesis, but never accept it. If your test fails to detect an effect, this is not proof that the effect doesn’t exist. It just means that your sample did not have enough evidence to conclude that it exists.

We can’t accept a null hypothesis because a lack of evidence does not prove something that does not exist. Instead, we fail to reject it.

Failing to reject the null indicates that the sample did not provide sufficient enough evidence to conclude that an effect exists.

If the p-value is greater than the significance level, then you fail to reject the null hypothesis.

Is a null hypothesis directional or non-directional?

A hypothesis test can either contain an alternative directional hypothesis or a non-directional alternative hypothesis. A directional hypothesis is one that contains the less than (“<“) or greater than (“>”) sign.

A nondirectional hypothesis contains the not equal sign (“≠”).  However, a null hypothesis is neither directional nor non-directional.

A null hypothesis is a prediction that there will be no change, relationship, or difference between two variables.

The directional hypothesis or nondirectional hypothesis would then be considered alternative hypotheses to the null hypothesis.

Gill, J. (1999). The insignificance of null hypothesis significance testing.  Political research quarterly ,  52 (3), 647-674.

Krueger, J. (2001). Null hypothesis significance testing: On the survival of a flawed method.  American Psychologist ,  56 (1), 16.

Masson, M. E. (2011). A tutorial on a practical Bayesian alternative to null-hypothesis significance testing.  Behavior research methods ,  43 , 679-690.

Nickerson, R. S. (2000). Null hypothesis significance testing: a review of an old and continuing controversy.  Psychological methods ,  5 (2), 241.

Rozeboom, W. W. (1960). The fallacy of the null-hypothesis significance test.  Psychological bulletin ,  57 (5), 416.

Print Friendly, PDF & Email

If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

To log in and use all the features of Khan Academy, please enable JavaScript in your browser.

Statistics and probability

Course: statistics and probability   >   unit 14.

  • Chi-square distribution introduction

Pearson's chi square test (goodness of fit)

  • Chi-square statistic for hypothesis testing
  • Chi-square goodness-of-fit example
  • Expected counts in a goodness-of-fit test
  • Conditions for a goodness-of-fit test
  • Test statistic and P-value in a goodness-of-fit test
  • Conclusions in a goodness-of-fit test

when is null hypothesis rejected chi square

Want to join the conversation?

  • Upvote Button navigates to signup page
  • Downvote Button navigates to signup page
  • Flag Button navigates to signup page

Video transcript

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

6.2 - chi-square test statistic.

To better understand what these expected counts represent, first recall that the expected counts table is designed to reflect what the sample data counts would be if the two variables were independent (the null hypothesis). In other words, under the null hypothesis we expect the proportions of observations to be similar in each cell. For example, if we ONLY considered the Northeast, and look at the expected counts for the Northeast across the two level of entrepreneurialism, under the null hypothesis we should have 50% in each level of entrepreneurialism. With actual values observed of 300 and 460 we can begin to suspect levels of entrepreneurialism may not be "independent" of location.

You may be looking at the expected counts for the Northeast and wondering why they aren't exactly 50/50. This is because the expected value is calculated as a function of both the ROWS and the COLUMNS! The great thing is, that our software will do the calculations for you, but again, it is helpful to have a conceptual understanding of expected values.

  Low Entrepreneurialism High Entrepreneurialism All
Northeast 300 460 760
377.9 382.1  
Midwest 249 95 344
171.1 172.9  
All 549 555 1104

The statistical question becomes, "Are the observed counts so different from the expected counts that we can conclude a relationship exists between the two variables?" To conduct this test we compute a Chi-square test statistic where we compare each cell's observed count to its respective expected count.

In a summary table, we have \(r\times c=rc\) cells. Let \(O_1, O_2, …, O_{rc}\) denote the observed counts for each cell and \(E_1, E_2, …, E_{rc}\) denote the respective expected counts for each cell.

The Chi-square test statistic is calculated as follows:

\(\chi^{2*}=\displaystyle\sum\limits_{i=1}^{rc} \dfrac{(O_i-E_i)^2}{E_i}\)

Under the null hypothesis and certain conditions (discussed below), the test statistic follows a Chi-square distribution with degrees of freedom equal to \((r-1)(c-1)\), where \(r\) is the number of rows and \(c\) is the number of columns. We leave out the mathematical details to show why this test statistic is used and why it follows a Chi-square distribution.

As we have done with other statistical tests, we make our decision by either comparing the value of the test statistic by finding the probability of getting this test statistic value or one more extreme. The p-value is found by \(P(\chi^2>\chi^{2*})\) with degrees of freedom =\((r - 1)(c - 1)\).

So for Donna’s data, we compute the chi-square statistics

  Chi-Square DF P-Value
Pearson 102.596 1 0.000
Likelihood 105.357 1 0.000

The resulting chi-square statistic is  102.596 with a p-value of .000.  The 2X2 table also includes the expected values.  Remember the chi-square statistic is comparing the expected values to the observed values from Donna’s study.  The results of the chi-square indicate this difference (observed – expected is large).  Thus, Donna can reject the null hypothesis that entrepreneurialism and geographic location are independent and she can conclude that Entrepreneurialism levels depend on geographic location.

Conditions for Using the Chi-Square Test Section  

Exercise caution when there are small expected counts. Minitab will give a count of the number of cells that have expected frequencies less than five. Some statisticians hesitate to use the chi-square test if more than 20% of the cells have expected frequencies below five, especially if the p-value is small and these cells give a large contribution to the total chi-square value.

Caution! Section  

Sometimes researchers will categorize quantitative data (e.g., take height measurements and categorize as 'below average,' 'average,' and 'above average.'') Doing so results in a loss of information - one cannot do the reverse of taking the categories and reproducing the raw quantitative measurements. Instead of categorizing, the data should be analyzed using quantitative methods.

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Level of significance and acceptance and rejection of null hypothesis

Why do we reject null hypothesis of a Goodness of test when the Chi square statistic is more than the tabulated value of chi-square at say 5% level of significance and accept when it is less?

What does it mean to have a Chi-square value more or less than the value assigned to a certain level of significance?

  • chi-squared-test

Tyto alba's user avatar

  • $\begingroup$ The null hypothesis is usually set up as the uninteresting hypothesis. So we attempt to reject it. If we can't reject at a particular significance level that does not mean that we should accept it. $\endgroup$ –  Michael R. Chernick Commented Feb 8, 2017 at 18:37
  • $\begingroup$ I didn't say that. My question is why accept when more and reject when less? May be you should consider rereading the query, my main question is the second one. $\endgroup$ –  Tyto alba Commented Feb 8, 2017 at 18:55
  • $\begingroup$ What level of Type I error you will tolerate is a subjective economic decision. $\endgroup$ –  Michael Hardy Commented Feb 8, 2017 at 19:42

To have a chi-squared value more than the value at a certain significance level means that under the null hypothesis the observed chi-squared value is more unlikely than your desired level of significance. A smaller chi squared value means the observed values are more likely under the null hypothesis. As the chi squared value gets higher , the likelihood of seeing your observations under the null hypothesis decreases , so rejecting the null becomes more and more attractive

Conrad De Peuter's user avatar

  • $\begingroup$ Is this consistent with any type of test statistic, like goodness of fit and test for homogeinity of chi-square? $\endgroup$ –  Tyto alba Commented Feb 9, 2017 at 5:00
  • 1 $\begingroup$ Not sure if you are specifically discussing chi-squared type tests or other tests, but this is generally how things go. Your test statistic increases as the observations become less likely under the null hypothesis. $\endgroup$ –  Conrad De Peuter Commented Feb 9, 2017 at 16:13

Your Answer

Sign up or log in, post as a guest.

Required, but never shown

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy .

Not the answer you're looking for? Browse other questions tagged chi-squared-test or ask your own question .

  • Featured on Meta
  • Introducing an accessibility dashboard and some upcoming changes to display...
  • We've made changes to our Terms of Service & Privacy Policy - July 2024
  • Announcing a change to the data-dump process

Hot Network Questions

  • What type of concept is "mad scientist"?
  • Why do most published papers hit the maximum page limit exactly?
  • If KCI allows MitM attacks, how are ephemeral exchanges an effective mitigation?
  • "Seagulls are gulling away."
  • How do Driftgloom Coyote and Sugar Coat interact?
  • Can a wizard learn a spell from a cleric or druid?
  • What is the anti-trust argument made by X Corp's recent lawsuit against advertisers that boycotted X/Twitter
  • How to interpret the "As much as" in "As much as I like her, I can't agree with her on this."
  • How can I append comma except lastline?
  • Reference for the proof that Möbius transformations extend to isometries of hyperbolic 3-space
  • Pass ethernet directly to VM and use WiFi for OS
  • Elastic Banach spaces without C[0,1]
  • How does "regina" derive from "rex"?
  • What are those small notes below other ones?
  • If a planet or star is composed of gas, the center of mass will have zero gravity but immense pressure? I'm trying to understand fusion in stars
  • Safe(r) / Easier Pointer Allocation Interface in C (ISO C11)
  • Pure emphasis use of 那個?
  • How bright would nights be if the moon were terraformed?
  • Adjust circle radius by spline parameter
  • Iterative mixing problem
  • Statistically, which is more of a severe penalty on a d20 roll, Disadvantage or a -10 penalty?
  • English equilvant to this hindi proverb "A washerman's dog belongs neither at home nor at the riverbank."?
  • Reportedly there are German-made infantry fighting vehicles in Russia's Kursk region. Has this provoked any backlash in Germany?
  • What is an external IDE 37 DBI pin device?

when is null hypothesis rejected chi square

Statology

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

when is null hypothesis rejected chi square

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.

Have a language expert improve your writing

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

  • Knowledge Base
  • Chi-Square Test of Independence | Formula, Guide & Examples

Chi-Square Test of Independence | Formula, Guide & Examples

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

A chi-square (Χ 2 ) test of independence is a nonparametric hypothesis test . You can use it to test whether two categorical variables are related to each other.

The city decides to test two interventions: an educational flyer (pamphlet) or a phone call. They randomly select 300 households and randomly assign them to the flyer, phone call, or control group (no intervention). They’ll use the results of their experiment to decide which intervention to use for the whole city.

Table of contents

What is the chi-square test of independence, chi-square test of independence hypotheses, when to use the chi-square test of independence, how to calculate the test statistic (formula), how to perform the chi-square test of independence, when to use a different test, practice questions, other interesting articles, frequently asked questions about the chi-square test of independence.

A chi-square (Χ 2 ) test of independence is a type of Pearson’s chi-square test . Pearson’s chi-square tests are nonparametric tests for categorical variables. They’re used to determine whether your data are significantly different from what you expected.

You can use a chi-square test of independence, also known as a chi-square test of association, to determine whether two categorical variables are related. If two variables are related, the probability of one variable having a certain value is dependent on the value of the other variable.

The chi-square test of independence calculations are based on the observed frequencies, which are the numbers of observations in each combined group.

The test compares the observed frequencies to the frequencies you would expect if the two variables are unrelated. When the variables are unrelated, the observed and expected frequencies will be similar.

Contingency tables

When you want to perform a chi-square test of independence, the best way to organize your data is a type of frequency distribution table called a contingency table .

A contingency table, also known as a cross tabulation or crosstab, shows the number of observations in each combination of groups. It also usually includes row and column totals.

Household address Intervention Outcome
25 Elm Street Flyer Recycles
100 Cedar Street Control Recycles
3 Maple Street Control Does not recycle
123 Oak Street Phone call Recycles

They reorganize the data into a contingency table:

Intervention Recycles Does not recycle Row totals
Flyer (pamphlet) 89 9 98
Phone call 84 8 92
Control 86 24 110
Column totals 259 41 = 300

They also visualize their data in a bar graph:

Contingency-table-bar-graph

Here's why students love Scribbr's proofreading services

Discover proofreading & editing

The chi-square test of independence is an inferential statistical test, meaning that it allows you to draw conclusions about a population based on a sample . Specifically, it allows you to conclude whether two variables are related in the population.

Like all hypothesis tests, the chi-square test of independence evaluates a null and alternative hypothesis. The hypotheses are two competing answers to the question “Are variable 1 and variable 2 related?”

  • Null hypothesis ( H 0 ): Variable 1 and variable 2 are not related in the population; The proportions of variable 1 are the same for different values of variable 2.
  • Alternative hypothesis ( H a ): Variable 1 and  variable 2 are related in the population; The proportions of variable 1 are not the same for different values of  variable 2.

You can use the above sentences as templates. Replace variable 1 and variable 2 with the names of your variables.

  • Null hypothesis ( H 0 ): Whether a household recycles and the type of intervention they receive are not related in the population; The proportion of households that recycle is the same for all interventions.
  • Alternative hypothesis ( H a ):  Whether a household recycles and the type of intervention they receive are related in the population; The proportion of households that recycle is not the same for all interventions.

Expected values

A chi-square test of independence works by comparing the observed and the expected frequencies. The expected frequencies are such that the proportions of one variable are the same for all values of the other variable.

You can calculate the expected frequencies using the contingency table. The expected frequency for row r and column c is:

\begin{equation*}\dfrac{(\textup{Row}\,\, r \,\,\textup{total}\,\, \times \textup{Column}\,\, c \,\,\textup{total})}{N}\end{equation*}

Observed and expected frequencies (observed above, expected below)
Intervention Recycles Does not recycle Row totals
Flyer (pamphlet)
Phone call
Control
Column totals

Expected-values-bar-graph

The following conditions are necessary if you want to perform a chi-square goodness of fit test:

  • Chi-square tests of independence are usually performed on binary or nominal variables. They are sometimes performed on ordinal variables, although generally only on ordinal variables with fewer than five groups.
  • The sample was random l y selected from the population .
  • There are a minimum of five observations expected in each combined group.
  • They want to test a hypothesis about the relationships between two categorical variables: whether a household recycles and the type of intervention.
  • They recruited a random sample of 300 households.
  • There are a minimum of five observations expected in each combined group. The smallest expected frequency is 12.57.

Pearson’s chi-square (Χ 2 ) is the test statistic for the chi-square test of independence:

\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 chi-square test statistic measures how much your observed frequencies differ from the frequencies you would expect if the two variables are unrelated. It is large when there’s a big difference between the observed and expected frequencies ( O − E in the equation).

Follow these five steps to calculate the test statistic:

Step 1: Create a table

Create a table with the observed and expected frequencies in two columns.

Intervention Outcome Observed Expected
Flyer Recycles 89 84.61
Does not recycle 9 13.39
Phone call Recycles 84 79.43
Does not recycle 8 12.57
Control Recycles 86 94.97
Does not recycle 24 15.03

Step 2: Calculate O − E

In a new column called “ O −   E ”, subtract the expected frequencies from the observed frequencies.

Intervention Outcome Observed Expected
Flyer Recycles 89 84.61 4.39
Does not recycle 9 13.39 -4.39
Phone call Recycles 84 79.43 4.57
Does not recycle 8 12.57 -4.57
Control Recycles 86 94.97 -8.97
Does not recycle 24 15.03 8.97

Step 3: Calculate ( O – E ) 2

In a new column called “( O −   E ) 2 ”, square the values in the previous column.

Intervention Outcome Observed Expected ( )
Flyer Recycles 89 84.61 4.39 19.27
Does not recycle 9 13.39 -4.39 19.27
Phone call Recycles 84 79.43 4.57 20.88
Does not recycle 8 12.57 -4.57 20.88
Control Recycles 86 94.97 -8.97 80.46
Does not recycle 24 15.03 8.97 80.46

Step 4: Calculate ( O − E ) 2 / E

In a final column called “(O − E) 2 / E”, divide the previous column by the expected frequencies.

Intervention Outcome Observed Expected ( ) ( ) /
flyer Recycles 89 84.61 4.39 19.27 0.23
Does not recycle 9 13.39 -4.39 19.27 1.44
Phone call Recycles 84 79.43 4.57 20.88 0.26
Does not recycle 8 12.57 -4.57 20.88 1.66
Control Recycles 86 94.97 -8.97 80.46 0.85
Does not recycle 24 15.03 8.97 80.46 5.35

Step 5: Calculate Χ 2

Finally, add up the values of the previous column to calculate the chi-square test statistic (Χ2).

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

when is null hypothesis rejected chi square

If the test statistic is big enough then you should conclude that the observed frequencies are not what you’d expect if the variables are unrelated. But what counts as big enough?

We compare the test statistic to a critical value from a chi-square distribution to decide whether it’s big enough to reject the null hypothesis that the two variables are unrelated. This procedure is called the chi-square test of independence.

Follow these steps to perform a chi-square test of independence (the first two steps have already been completed for the recycling example):

Step 1: Calculate the expected frequencies

Use the contingency table to calculate the expected frequencies following the formula:

\begin{equation*}\dfrac{(\textup{Row}\,\, r \,\,\textup{total}\,\, \times \textup{Column}\,\, c \,\,\textup{total})}{\textup{Grand}\,\, \textup{total}}\end{equation*}

Step 2: Calculate chi-square

Use the Pearson’s chi-square formula to calculate the test statistic :

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

Step 3: Find the critical chi-square value

You can find the critical value in a chi-square critical value table or using statistical software. You need to known two numbers to find the critical value:

  • The degrees of freedom ( df ): For a chi-square test of independence, the df is (number of variable 1 groups − 1) * (number of variable 2 groups − 1).
  • Significance level (α): By convention, the significance level is usually .05.

Step 4: Compare the chi-square value to the critical value

Is the test statistic big enough to reject the null hypothesis? Compare it to the critical value to find out.

Critical value = 5.99

Step 5: Decide whether to reject the null hypothesis

  • The data allows you to reject the null hypothesis that the variables are unrelated and provides support for the alternative hypothesis that the variables are related.
  • The data doesn’t allow you to reject the null hypothesis that the variables are unrelated and doesn’t provide support for the alternative hypothesis that the variables are related.

There is a significant difference between the observed frequencies and the frequencies expected if the two variables were unrelated ( p < .05). This suggests that the proportion of households that recycle is not the same for all interventions.

Step 6: Follow up with post hoc tests (optional)

If there are more than two groups in either of the variables and you rejected the null hypothesis, you may want to investigate further with post hoc tests. A post hoc test is a follow-up test that you perform after your initial analysis.

Similar to a one-way ANOVA with more than two groups, a significant difference doesn’t tell you which groups’ proportions are significantly different from each other.

One post hoc approach is to compare each pair of groups using chi-square tests of independence and a Bonferroni correction. A Bonferroni correction is when you divide your original significance level (usually .05) by the number of tests you’re performing.

Chi-square test of independence Chi-square test statistic
Flyer vs. phone call 0.014
Flyer vs. control 6.198
Phone call vs. control 6.471
  • Since there are two intervention groups and two outcome groups for each test, there is (2 − 1) * (2 − 1) = 1 degree of freedom.
  • There are three tests, so the significance level with a Bonferroni correction applied is α = .05 / 3 = .016.
  • For a test of significance at α = .016 and df = 1, the Χ 2 critical value is 5.803.
  • The chi-square value is greater than the critical value for the pamphlet vs control and phone call vs. control tests.

Based on these findings, the city concludes that a significantly greater proportion of households recycled after receiving a pamphlet or phone call compared to the control.

Several tests are similar to the chi-square test of independence, so it may not always be obvious which to use. The best choice will depend on your variables, your sample size, and your hypotheses.

When to use the chi-square goodness of fit test

There are two types of Pearson’s chi-square test. The chi-square test of independence is one of them, and the chi-square goodness of fit test is the other. The math is the same for both tests—the main difference is how you calculate the expected values.

You should use the chi-square goodness of fit test when you have one categorical variable and you want to test a hypothesis about its distribution .

When to use Fisher’s exact test

If you have a small sample size ( N < 100), Fisher’s exact test is a better choice. You should especially opt for Fisher’s exact test when your data doesn’t meet the condition of a minimum of five observations expected in each combined group.

When to use McNemar’s test

You should use McNemar’s test when you have a closely-related pair of categorical variables that each have two groups. It allows you to test whether the proportions of the variables are equal. This test is most often used to compare before and after observations of the same individuals.

When to use a G test

A G test and a chi-square test give approximately the same results. G tests can accommodate more complex experimental designs than chi-square tests. However, the tests are usually interchangeable and the choice is mostly a matter of personal preference.

One reason to prefer chi-square tests is that they’re more familiar to researchers in most fields.

Do you want to test your knowledge about the chi-square goodness of fit test? Download our practice questions and examples with the buttons below.

Download Word doc Download Google doc

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.

  • 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

You can use the CHISQ.TEST() function to perform a chi-square test of independence in Excel. It takes two arguments, CHISQ.TEST(observed_range, expected_range), and returns the p value.

You can use the chisq.test() function to perform a chi-square test of independence in R. Give the contingency table as a matrix for the “x” argument. For example:

m = matrix(data = c(89, 84, 86, 9, 8, 24), nrow = 3, ncol = 2)

chisq.test(x = m)

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

A chi-square distribution is a continuous probability distribution . The shape of a chi-square distribution depends on its degrees of freedom , k . The mean of a chi-square distribution is equal to its degrees of freedom ( k ) and the variance is 2 k . The range is 0 to ∞.

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 Test of Independence | Formula, Guide & Examples. Scribbr. Retrieved August 5, 2024, from https://www.scribbr.com/statistics/chi-square-test-of-independence/

Is this article helpful?

Shaun Turney

Shaun Turney

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

  • Search Search Please fill out this field.
  • Chi-Square (χ2) Statistic
  • What It Can Tell You
  • When to Use
  • How to Perform It
  • Limitations

The Bottom Line

  • Business Leaders
  • Math and Statistics

Chi-Square (χ2) Statistic: What It Is, Examples, How and When to Use the Test

Adam Hayes, Ph.D., CFA, is a financial writer with 15+ years Wall Street experience as a derivatives trader. Besides his extensive derivative trading expertise, Adam is an expert in economics and behavioral finance. Adam received his master's in economics from The New School for Social Research and his Ph.D. from the University of Wisconsin-Madison in sociology. He is a CFA charterholder as well as holding FINRA Series 7, 55 & 63 licenses. He currently researches and teaches economic sociology and the social studies of finance at the Hebrew University in Jerusalem.

when is null hypothesis rejected chi square

Paige McLaughlin / Investopedia

What Is a Chi-Square (χ2) Statistic?

A chi-square ( χ 2 ) statistic is a test that measures how a model compares to actual observed data. The data used in calculating a chi-square statistic must be random, raw, mutually exclusive, drawn from independent variables, and drawn from a large enough sample. For example, the results of tossing a fair coin meet these criteria.

Chi-square tests are often used to test hypotheses. The chi-square statistic compares the size of any discrepancies between the expected results and the actual results, given the size of the sample and the number of variables in the relationship.

For these tests, degrees of freedom are used to determine if a certain  null hypothesis  can be rejected based on the total number of variables and samples within the experiment. As with any statistic, the larger the sample size, the more reliable the results.

Key Takeaways

  • A chi-square ( χ 2 ) statistic is a measure of the difference between the observed and expected frequencies of the outcomes of a set of events or variables.
  • Chi-square is useful for analyzing such differences in categorical variables, especially those nominal in nature.
  • χ 2 depends on the size of the difference between actual and observed values, the degrees of freedom, and the sample size.
  • χ 2 can be used to test whether two variables are related or independent of each other.
  • It can also be used to test the goodness of fit between an observed distribution and a theoretical distribution of frequencies.

Formula for a Chi-Square (χ2) Statistic

 χ c 2 = ∑ ( O i − E i ) 2 E i where: c = Degrees of freedom O = Observed value(s) \begin{aligned}&\chi^2_c = \sum \frac{(O_i - E_i)^2}{E_i} \\&\textbf{where:}\\&c=\text{Degrees of freedom}\\&O=\text{Observed value(s)}\\&E=\text{Expected value(s)}\end{aligned} ​ χ c 2 ​ = ∑ E i ​ ( O i ​ − E i ​ ) 2 ​ where: c = Degrees of freedom O = Observed value(s) ​ 

What a Chi-Square (χ2) Statistic Can Tell You

There are two main kinds of chi-square tests that will provide different information:

  • The test of independence, which asks a question of relationship, such as, “Is there a relationship between student gender and course choice?”
  • The goodness-of-fit test, which asks a theoretical question such as, “How well does the coin in my hand match a theoretically fair coin?”

Chi-square analysis is applied to categorical variables and is especially useful when those variables are nominal (where order doesn’t matter, like marital status or gender).

Test of Independence

When considering student gender and course choice, a χ 2 test for independence could be used. To do this test, the researcher would collect data on the two chosen variables (gender and courses picked) and then compare the frequencies at which male and female students select among the offered classes using the formula given above and a χ 2 statistical table.

If there is no relationship between gender and course selection (that is if they are independent), then the actual frequencies at which male and female students select each offered course should be expected to be approximately equal, or conversely, the proportion of male and female students in any selected course should be approximately equal to the proportion of male and female students in the sample .

A χ 2 test for independence can tell us how likely it is that random chance can explain any observed difference between the actual frequencies in the data and these theoretical expectations.

In a test of independence, a company may want to evaluate whether its new product, an herbal supplement that promises to give people an energy boost, is reaching the people who are most likely to be interested.

It is being advertised on websites related to sports and fitness, on the assumption that active and health-conscious people are most likely to buy it. It does an extensive poll that is intended to evaluate interest in the product by demographic group. The poll suggests no correlation between interest in this product and the most health-conscious people.

Test of Goodness of Fit

χ 2 provides a way to test how well a sample of data matches the (known or assumed) characteristics of the larger population that the sample is intended to represent. This is known as goodness of fit.

If the sample data does not fit the expected properties of the population in which one is interested, then one would not want to use this sample to draw conclusions about the larger population.

As an example of a test of goodness of fit , a marketing professional is considering launching a new product that the company believes will be irresistible to women over age 45. The company has conducted product testing panels of 500 potential buyers of the product.

The marketing professional has information about the age and gender of the test panels. This allows the construction of a chi-square test showing the distribution by age and gender of the people who said they would buy the product.

The result will show whether or not the likeliest buyer is a woman over 45. If the test shows that men over age 45 or women ages 18 to 44 are just as likely to buy the product, then the marketing professional will revise the advertising, promotion, and placement of the product to appeal to this wider group of customers.

Example of How to Use a Chi-Square (χ2) Statistic

For example, consider an imaginary coin with exactly a 50/50 chance of landing heads or tails and a real coin that you toss 100 times. If this coin is fair, then it will also have an equal probability of landing on either side, and the expected result of tossing the coin 100 times is that heads will come up 50 times and tails will come up 50 times.

In this case, χ 2 can tell us how well the actual results of 100 coin flips compare to the theoretical model that a fair coin will give 50/50 results. The actual toss could come up 50/50, or 60/40, or even 90/10.

The farther away the actual results of the 100 tosses are from 50/50, the less good the fit of this set of tosses is to the theoretical expectation of 50/50, and the more likely one might conclude that this coin is not actually a fair coin.

When to Use a Chi-Square (χ2) Test

A chi-square test is used to help determine if observed results are in line with expected results and to rule out that observations are due to chance.

A chi-square test is appropriate for this when the data being analyzed is from a random sample , and when the variable in question is a categorical variable. A categorical variable consists of selections such as type of car, race, educational attainment, male or female, or how much somebody likes a political candidate (from very much to very little).

These types of data are often collected via survey responses or questionnaires. Therefore, chi-square analysis is often most useful in analyzing this type of data.

How to Perform a Chi-Square (χ2) Test

These are the basic steps whether you are performing a goodness-of-fit test or a test of independence:

  • Create a table of the observed and expected frequencies.
  • Use the formula to calculate the chi-square value.
  • Find the critical chi-square value using a chi-square value table or statistical software .
  • Determine whether the chi-square value or the critical value is the larger of the two.
  • Reject or accept the null hypothesis.

Limitations of a Chi-Square (χ2) Statistic

The chi-square test is sensitive to sample size. Relationships may appear to be significant when they aren’t, simply because a very large sample is used.

In addition, the chi-square test cannot establish whether one variable has a causal relationship with another. It can only establish whether two variables are related.

What Is a Chi-Square Test Used for?

Chi-square is a statistical test used to examine the differences between categorical variables from a random sample in order to judge the goodness of fit between expected and observed results.

Who Uses Chi-Square Analysis?

Since chi-square applies to categorical variables, it is most used by researchers who are studying survey response data. This type of research can range from demography to consumer and marketing research to political science and economics.

Is Chi-Square Analysis Used When the Independent Variable Is Nominal or Ordinal?

A nominal variable is a categorical variable that differs by quality, but whose numerical order could be irrelevant. For instance, asking somebody their favorite color would produce a nominal variable. Asking somebody’s age, on the other hand, would produce an ordinal set of data. Chi-square can be best applied to nominal data.

A chi-square statistic is used to measure the difference between the observed and expected frequencies of the outcomes of a set of variables. It can be helpful for analyzing differences in categorical variables, especially those nominal in nature. The two different types of chi-square tests—test of independence and test of goodness of fit—will answer different relational questions.

when is null hypothesis rejected chi square

  • Terms of Service
  • Editorial Policy
  • Privacy Policy
  • Your Privacy Choices

Tutorial Playlist

Statistics tutorial, everything you need to know about the probability density function in statistics, the best guide to understand central limit theorem, an in-depth guide to measures of central tendency : mean, median and mode, the ultimate guide to understand conditional probability, a comprehensive look at percentile in statistics, the best guide to understand bayes theorem, everything you need to know about the normal distribution, an in-depth explanation of cumulative distribution function, a complete guide to chi-square test.

What Is Hypothesis Testing in Statistics? Types and Examples

Understanding the Fundamentals of Arithmetic and Geometric Progression

The definitive guide to understand spearman’s rank correlation, mean squared error: overview, examples, concepts and more, all you need to know about the empirical rule in statistics, the complete guide to skewness and kurtosis, a holistic look at bernoulli distribution, all you need to know about bias in statistics, a complete guide to get a grasp of time series analysis.

The Key Differences Between Z-Test Vs. T-Test

The Complete Guide to Understand Pearson's Correlation

A complete guide on the types of statistical studies, everything you need to know about poisson distribution, your best guide to understand correlation vs. regression, the most comprehensive guide for beginners on what is correlation, what is a chi-square test formula, examples & application.

Lesson 9 of 24 By Avijeet Biswal

A Complete Guide to Chi-Square Test

Table of Contents

A statistical technique called chi-squared test (represented symbolically as χ²) is employed to examine discrepancies between the data distributions that are observed and those that are expected. Known also as Pearson's chi-squared test, it was developed in 1900 by Karl Pearson for the analysis of categorical data and distribution. Assuming the null hypothesis is correct, this test determines the probability that the observed frequencies in a sample match the predicted frequencies. The null hypothesis, which essentially suggests that any observed differences are the result of random chance, is a statement that suggests there is no substantial difference between the observed and predicted frequencies. Usually, the sum of the squared differences between the predicted and observed frequencies, normalized by the expected frequencies, over the sample variance is used to construct chi-squared tests. This test offers a means to test theories on the links between categorical variables by determining whether the observed deviations are statistically significant or can be attributable to chance.

The world is constantly curious about the Chi-Square test's application in machine learning and how it makes a difference. Feature selection is a critical topic in machine learning , as you will have multiple features in line and must choose the best ones to build the model. By examining the relationship between the elements, the chi-square test aids in the solution of feature selection problems. In this tutorial, you will learn about the chi-square test and its application.

What Is a Chi-Square Test?

The Chi-Square test is a statistical procedure for determining the difference between observed and expected data. This test can also be used to determine whether it correlates to the categorical variables in our data. It helps to find out whether a difference between two categorical variables is due to chance or a relationship between them.

Chi-Square Test Definition

A chi-square test is a statistical test that is used to compare observed and expected results. The goal of this test is to identify whether a disparity between actual and predicted data is due to chance or to a link between the variables under consideration. As a result, the chi-square test is an ideal choice for aiding in our understanding and interpretation of the connection between our two categorical variables.

A chi-square test or comparable nonparametric test is required to test a hypothesis regarding the distribution of a categorical variable. Categorical variables, which indicate categories such as animals or countries, can be nominal or ordinal. They cannot have a normal distribution since they can only have a few particular values.

For example, a meal delivery firm in India wants to investigate the link between gender, geography, and people's food preferences.

It is used to calculate the difference between two categorical variables, which are:

  • As a result of chance or
  • Because of the relationship

Your Data Analytics Career is Around The Corner!

Your Data Analytics Career is Around The Corner!

Formula For Chi-Square Test

Chi_Sq_formula.

c = Degrees of freedom

O = Observed Value

E = Expected Value

The degrees of freedom in a statistical calculation represent the number of variables that can vary in a calculation. The degrees of freedom can be calculated to ensure that chi-square tests are statistically valid. These tests are frequently used to compare observed data with data that would be expected to be obtained if a particular hypothesis were true.

The Observed values are those you gather yourselves.

The expected values are the frequencies expected, based on the null hypothesis. 

Fundamentals of Hypothesis Testing

Hypothesis testing is a technique for interpreting and drawing inferences about a population based on sample data. It aids in determining which sample data best support mutually exclusive population claims.

Null Hypothesis (H0) - The Null Hypothesis is the assumption that the event will not occur. A null hypothesis has no bearing on the study's outcome unless it is rejected.

H0 is the symbol for it, and it is pronounced H-naught.

Become a Data Scientist With Real-World Experience

Become a Data Scientist With Real-World Experience

What Does A Chi-Square Statistic Test Tell You?

A Chi-Square test ( symbolically represented as  2 ) is fundamentally a data analysis based on the observations of a random set of variables. It computes how a model equates to actual observed data. A Chi-Square statistic test is calculated based on the data, which must be raw, random, drawn from independent variables, drawn from a wide-ranging sample and mutually exclusive. In simple terms, two sets of statistical data are compared -for instance, the results of tossing a fair coin. Karl Pearson introduced this test in 1900 for categorical data analysis and distribution. This test is also known as ‘Pearson’s Chi-Squared Test’. 

Chi-Squared Tests are most commonly used in hypothesis testing. A hypothesis is an assumption that any given condition might be true, which can be tested afterwards. The Chi-Square test estimates the size of inconsistency between the expected results and the actual results when the size of the sample and the number of variables in the relationship is mentioned. 

These tests use degrees of freedom to determine if a particular null hypothesis can be rejected based on the total number of observations made in the experiments. Larger the sample size, more reliable is the result.

ypes of Chi-square Tests

There are two main types of Chi-Square tests namely -

Independence 

  • Goodness-of-Fit 

The Chi-Square Test of Independence is a derivable ( also known as inferential ) statistical test which examines whether the two sets of variables are likely to be related with each other or not. This test is used when we have counts of values for two nominal or categorical variables and is considered as non-parametric test. A relatively large sample size and independence of obseravations are the required criteria for conducting this test.

For Example- 

In a movie theatre, suppose we made a list of movie genres. Let us consider this as the first variable. The second variable is whether or not the people who came to watch those genres of movies have bought snacks at the theatre. Here the null hypothesis is that th genre of the film and whether people bought snacks or not are unrelatable. If this is true, the movie genres don’t impact snack sales. 

Learn All The Tricks Of The BI Trade

Learn All The Tricks Of The BI Trade

Goodness-Of-Fit

In statistical hypothesis testing, the Chi-Square Goodness-of-Fit test determines whether a variable is likely to come from a given distribution or not. We must have a set of data values and the idea of the distribution of this data. We can use this test when we have value counts for categorical variables. This test demonstrates a way of deciding if the data values have a “ good enough” fit for our idea or if it is a representative sample data of the entire population. 

Suppose we have bags of balls with five different colours in each bag. The given condition is that the bag should contain an equal number of balls of each colour. The idea we would like to test here is that the proportions of the five colours of balls in each bag must be exact. 

What Are Categorical Variables?

Categorical variables belong to a subset of variables that can be divided into discrete categories. Names or labels are the most common categories. These variables are also known as qualitative variables because they depict the variable's quality or characteristics.

Categorical variables can be divided into two categories:

  • Nominal Variable: A nominal variable's categories have no natural ordering. Example: Gender, Blood groups
  • Ordinal Variable: A variable that allows the categories to be sorted is ordinal variables. Customer satisfaction (Excellent, Very Good, Good, Average, Bad, and so on) is an example.

Why Do You Use the Chi-Square Test?

Chi-square is a statistical test that examines the differences between categorical variables from a random sample in order to determine whether the expected and observed results are well-fitting.

Here are some of the uses of the Chi-Squared test:

  • The Chi-squared test can be used to see if your data follows a well-known theoretical probability distribution like the Normal or Poisson distribution.
  • The Chi-squared test allows you to assess your trained regression model's goodness of fit on the training, validation, and test data sets.

Who Uses Chi-Square Analysis?

Chi-square is most commonly used by researchers who are studying survey response data because it applies to categorical variables. Demography, consumer and marketing research, political science, and economics are all examples of this type of research.

Let's say you want to know if gender has anything to do with political party preference. You poll 440 voters in a simple random sample to find out which political party they prefer. The results of the survey are shown in the table below:

chi-1.

To see if gender is linked to political party preference, perform a Chi-Square test of independence using the steps below.

Step 1: Define the Hypothesis

H0: There is no link between gender and political party preference.

H1: There is a link between gender and political party preference.

Step 2: Calculate the Expected Values

Now you will calculate the expected frequency.

Chi_Sq_formula_1.

For example, the expected value for Male Republicans is: 

Chi_Sq_formula_2

Similarly, you can calculate the expected value for each of the cells.

chi-2.

Step 3: Calculate (O-E)2 / E for Each Cell in the Table

Now you will calculate the (O - E)2 / E for each cell in the table.

chi-3.

Step 4: Calculate the Test Statistic X2

X2  is the sum of all the values in the last table

 =  0.743 + 2.05 + 2.33 + 3.33 + 0.384 + 1

Before you can conclude, you must first determine the critical statistic, which requires determining our degrees of freedom. The degrees of freedom in this case are equal to the table's number of columns minus one multiplied by the table's number of rows minus one, or (r-1) (c-1). We have (3-1)(2-1) = 2.

Finally, you compare our obtained statistic to the critical statistic found in the chi-square table. As you can see, for an alpha level of 0.05 and two degrees of freedom, the critical statistic is 5.991, which is less than our obtained statistic of 9.83. You can reject our null hypothesis because the critical statistic is higher than your obtained statistic.

This means you have sufficient evidence to say that there is an association between gender and political party preference.

Chi_Sq_formula_3

Practice Problems

1. voting patterns.

A researcher wants to know if voting preferences (party A, party B, or party C) and gender (male, female) are related. Apply a chi-square test to the following set of data:

  • Male: Party A - 30, Party B - 20, Party C - 50
  • Female: Party A - 40, Party B - 30, Party C - 30

To determine if gender influences voting preferences, run a chi-square test of independence.

2. State of Health

In a sample population, a medical study examines the association between smoking status (smoker, non-smoker) and the occurrence of lung disease (yes, no). The information is as follows:

  • Smoker: Yes - 90, No - 60
  • Non-smoker: Yes - 30, No - 120 

To find out if smoking status is related to the incidence of lung disease, do a chi-square test.

3. Consumer Preferences

Customers are surveyed by a company to determine whether their age group (under 20, 20-40, over 40) and their preferred product category (food, apparel, or electronics) are related. The information gathered is:

  • Under 20: Electronic - 50, Clothing - 30, Food - 20
  • 20-40: Electronic - 60, Clothing - 70, Food - 50
  • Over 40: Electronic - 30, Clothing - 40, Food - 80

Use a chi-square test to investigate the connection between product preference and age group

4. Academic Performance

An educational researcher looks at the relationship between students' success on standardized tests (pass, fail) and whether or not they participate in after-school programs. The information is as follows:

  • Yes: Pass - 80, Fail - 20
  • No: Pass - 50, Fail - 50

Use a chi-square test to determine if involvement in after-school programs and test scores are connected.

5. Genetic Inheritance

A geneticist investigates how a particular trait is inherited in plants and seeks to ascertain whether the expression of a trait (trait present, trait absent) and the existence of a genetic marker (marker present, marker absent) are significantly correlated. The information gathered is:

  • Marker Present: Trait Present - 70, Trait Absent - 30
  • Marker Absent: Trait Present - 40, Trait Absent - 60

Do a chi-square test to determine if there is a correlation between the trait's expression and the genetic marker.

How to Solve Chi-Square Problems

1. state the hypotheses.

  • Null hypothesis (H0): There is no association between the variables
  • Alternative hypothesis (H1): There is an association between the variables.

2. Calculate the Expected Frequencies

  • Use the formula: E=(Row Total×Column Total)Grand TotalE = \frac{(Row \ Total \times Column \ Total)}{Grand \ Total}E=Grand Total(Row Total×Column Total)​

3. Compute the Chi-Square Statistic

  • Use the formula: χ2=∑(O−E)2E\chi^2 = \sum \frac{(O - E)^2}{E}χ2=∑E(O−E)2​, where O is the observed frequency and E is the expected frequency.

4. Determine the Degrees of Freedom (df)

  • Use the formula: df=(number of rows−1)×(number of columns−1)df = (number \ of \ rows - 1) \times (number \ of \ columns - 1)df=(number of rows−1)×(number of columns−1)

5. Find the Critical Value and Compare

  • Use the chi-square distribution table to find the critical value for the given df and significance level (usually 0.05).
  • Compare the chi-square statistic to the critical value to decide whether to reject the null hypothesis.

These practice problems help you understand how chi-square analysis tests hypotheses and explores relationships between categorical variables in various fields.

When to Use a Chi-Square Test?

A Chi-Square Test is used to examine whether the observed results are in order with the expected values. When the data to be analysed is from a random sample, and when the variable is the question is a categorical variable, then Chi-Square proves the most appropriate test for the same. A categorical variable consists of selections such as breeds of dogs, types of cars, genres of movies, educational attainment, male v/s female etc. Survey responses and questionnaires are the primary sources of these types of data. The Chi-square test is most commonly used for analysing this kind of data. This type of analysis is helpful for researchers who are studying survey response data. The research can range from customer and marketing research to political sciences and economics. 

Start your Dream Career with the Best Resources!

Start your Dream Career with the Best Resources!

Chi-Square Distribution 

Chi-square distributions (X2) are a type of continuous probability distribution. They're commonly utilized in hypothesis testing, such as the chi-square goodness of fit and independence tests. The parameter k, which represents the degrees of freedom, determines the shape of a chi-square distribution.

A chi-square distribution is followed by very few real-world observations. The objective of chi-square distributions is to test hypotheses, not to describe real-world distributions. In contrast, most other commonly used distributions, such as normal and Poisson distributions, may explain important things like baby birth weights or illness cases per year.

Because of its close resemblance to the conventional normal distribution, chi-square distributions are excellent for hypothesis testing. Many essential statistical tests rely on the conventional normal distribution.

In statistical analysis , the Chi-Square distribution is used in many hypothesis tests and is determined by the parameter k degree of freedoms. It belongs to the family of continuous probability distributions . The Sum of the squares of the k independent standard random variables is called the Chi-Squared distribution. Pearson’s Chi-Square Test formula is - 

Chi_Square_Distribution_1

Where X^2 is the Chi-Square test symbol

Σ is the summation of observations

O is the observed results

E is the expected results 

The shape of the distribution graph changes with the increase in the value of k, i.e. degree of freedoms. 

When k is 1 or 2, the Chi-square distribution curve is shaped like a backwards ‘J’. It means there is a high chance that X^2 becomes close to zero. 

Courtesy: Scribbr

When k is greater than 2, the shape of the distribution curve looks like a hump and has a low probability that X^2 is very near to 0 or very far from 0. The distribution occurs much longer on the right-hand side and shorter on the left-hand side. The probable value of X^2 is (X^2 - 2).

When k is greater than ninety, a normal distribution is seen, approximating the Chi-square distribution.

Chi-Square P-Values

Here P denotes the probability; hence for the calculation of p-values, the Chi-Square test comes into the picture. The different p-values indicate different types of hypothesis interpretations. 

  • P <= 0.05 (Hypothesis interpretations are rejected)
  • P>= 0.05 (Hypothesis interpretations are accepted) 

The concepts of probability and statistics are entangled with Chi-Square Test. Probability is the estimation of something that is most likely to happen. Simply put, it is the possibility of an event or outcome of the sample. Probability can understandably represent bulky or complicated data. And statistics involves collecting and organising, analysing, interpreting and presenting the data. 

Finding P-Value

When you run all of the Chi-square tests, you'll get a test statistic called X2. You have two options for determining whether this test statistic is statistically significant at some alpha level:

  • Compare the test statistic X2 to a critical value from the Chi-square distribution table.
  • Compare the p-value of the test statistic X2 to a chosen alpha level.

Test statistics are calculated by taking into account the sampling distribution of the test statistic under the null hypothesis, the sample data, and the approach which is chosen for performing the test. 

The p-value will be as mentioned in the following cases.

  • A lower-tailed test is specified by: P(TS ts | H0 is true) p-value = cdf (ts)
  • Lower-tailed tests have the following definition: P(TS ts | H0 is true) p-value = cdf (ts)
  • A two-sided test is defined as follows, if we assume that the test static distribution  of H0 is symmetric about 0. 2 * P(TS |ts| | H0 is true) = 2 * (1 - cdf(|ts|))

P: probability Event

TS: Test statistic is computed observed value of the test statistic from your sample cdf(): Cumulative distribution function of the test statistic's distribution (TS)

Types of Chi-square Tests

Pearson's chi-square tests are classified into two types:

  • Chi-square goodness-of-fit analysis
  • Chi-square independence test

These are, mathematically, the same exam. However, because they are utilized for distinct goals, we generally conceive of them as separate tests.

Properties of Chi-Square Test 

  • Variance is double the times the number of degrees of freedom.
  • Mean distribution is equal to the number of degrees of freedom.
  • When the degree of freedom increases, the Chi-Square distribution curve becomes normal.

Limitations of Chi-Square Test

There are two limitations to using the chi-square test that you should be aware of. 

  • The chi-square test, for starters, is extremely sensitive to sample size. Even insignificant relationships can appear statistically significant when a large enough sample is used. Keep in mind that "statistically significant" does not always imply "meaningful" when using the chi-square test.
  • Be mindful that the chi-square can only determine whether two variables are related. It does not necessarily follow that one variable has a causal relationship with the other. It would require a more detailed analysis to establish causality.

Get In-Demand Skills to Launch Your Data Career

Get In-Demand Skills to Launch Your Data Career

Chi-Square Goodness of Fit Test

When there is only one categorical variable, the chi-square goodness of fit test can be used. The frequency distribution of the categorical variable is evaluated for determining whether it differs significantly from what you expected. The idea is that the categories will have equal proportions, however, this is not always the case.

When you want to see if there is a link between two categorical variables, you perform the chi-square test. To acquire the test statistic and its related p-value in SPSS, use the chisq option on the statistics subcommand of the crosstabs command. Remember that the chi-square test implies that each cell's anticipated value is five or greater.

In this tutorial titled ‘The Complete Guide to Chi-square test’, you explored the concept of Chi-square distribution and how to find the related values. You also take a look at how the critical value and chi-square value is related to each other.

If you want to gain more insight and get a work-ready understanding in statistical concepts and learn how to use them to get into a career in Data Analytics , our Post Graduate Program in Data Analytics in partnership with Purdue University should be your next stop. A comprehensive program with training from top practitioners and in collaboration with IBM, this will be all that you need to kickstart your career in the field. 

Was this tutorial on the Chi-square test useful to you? Do you have any doubts or questions for us? Mention them in this article's comments section, and we'll have our experts answer them for you at the earliest!

1) What is the chi-square test used for? 

The chi-square test is a statistical method used to determine if there is a significant association between two categorical variables. It helps researchers understand whether the observed distribution of data differs from the expected distribution, allowing them to assess whether any relationship exists between the variables being studied.

2) What is the chi-square test and its types? 

The chi-square test is a statistical test used to analyze categorical data and assess the independence or association between variables. There are two main types of chi-square tests: a) Chi-square test of independence: This test determines whether there is a significant association between two categorical variables. b) Chi-square goodness-of-fit test: This test compares the observed data to the expected data to assess how well the observed data fit the expected distribution.

3) What is the chi-square test easily explained? 

The chi-square test is a statistical tool used to check if two categorical variables are related or independent. It helps us understand if the observed data differs significantly from the expected data. By comparing the two datasets, we can draw conclusions about whether the variables have a meaningful association.

4) What is the difference between t-test and chi-square? 

The t-test and the chi-square test are two different statistical tests used for different types of data. The t-test is used to compare the means of two groups and is suitable for continuous numerical data. On the other hand, the chi-square test is used to examine the association between two categorical variables. It is applicable to discrete, categorical data. So, the choice between the t-test and chi-square test depends on the nature of the data being analyzed.

5) What are the characteristics of chi-square? 

The chi-square test has several key characteristics:

1) It is non-parametric, meaning it does not assume a specific probability distribution for the data.

2) It is sensitive to sample size; larger samples can result in more significant outcomes.

3) It works with categorical data and is used for hypothesis testing and analyzing associations.

4) The test output provides a p-value, which indicates the level of significance for the observed relationship between variables.

5)It can be used with different levels of significance (e.g., 0.05 or 0.01) to determine statistical significance.

Find our PL-300 Microsoft Power BI Certification Training Online Classroom training classes in top cities:

NameDatePlace
23 Aug -7 Sep 2024,
Weekdays batch
Your City
6 Sep -21 Sep 2024,
Weekdays batch
Chicago
21 Sep -6 Oct 2024,
Weekend batch
Houston

About the Author

Avijeet Biswal

Avijeet is a Senior Research Analyst at Simplilearn. Passionate about Data Analytics, Machine Learning, and Deep Learning, Avijeet is also interested in politics, cricket, and football.

Recommended Resources

What Is Hypothesis Testing in Statistics? Types and Examples

Getting Started with Google Display Network: The Ultimate Beginner’s Guide

Sanity Testing Vs Smoke Testing: Know the Differences, Applications, and Benefits Of Each

Sanity Testing Vs Smoke Testing: Know the Differences, Applications, and Benefits Of Each

Fundamentals of Software Testing

Fundamentals of Software Testing

The Key Differences Between Z-Test Vs. T-Test

The Building Blocks of API Development

  • PMP, PMI, PMBOK, CAPM, PgMP, PfMP, ACP, PBA, RMP, SP, and OPM3 are registered marks of the Project Management Institute, Inc.

Google Search

Sociology 3112

Department of sociology, main navigation, the chi-square test for independence, learning objectives.

  • Understand the characteristics of the chi-square distribution
  • Carry out the chi-square test and interpret its results
  • Understand the limitations of the chi-square test

Chi-Square Distribution: a family asymmetrical, positively skewed distributions, the exact shape of which is determined by their respective degrees of freedom Observed Frequencies: the cell frequencies actually observed in a bivariate table Expected Frequencies: The cell frequencies that one might expect to see in a bivariate table if the two variables were statistically independent

The primary use of the chi-square test is to examine whether two variables are independent or not. What does it mean to be independent, in this sense? It means that the two factors are not related. Typically in social science research, we're interested in finding factors that are dependent upon each other—education and income, occupation and prestige, age and voting behavior. By ruling out independence of the two variables, the chi-square can be used to assess whether two variables are, in fact, dependent or not. More generally, we say that one variable is "not correlated with" or "independent of" the other if an increase in one variable is not associated with an increase in the another. If two variables are correlated, their values tend to move together, either in the same or in the opposite direction. Chi-square examines a special kind of correlation: that between two nominal variables.

The Chi-Square Distribution

The chi-square distribution, like the t distribution, is actually a series of distributions, the exact shape of which varies according to their degrees of freedom. Unlike the t distribution, however, the chi-square distribution is asymmetrical, positively skewed and never approaches normality. The graph below illustrates how the shape of the chi-square distribution changes as the degrees of freedom (k) increase:

when is null hypothesis rejected chi square

The Chi-Square Test

Earlier in the semester, you familiarized yourself with the five steps of hypothesis testing: (1) making assumptions (2) stating the null and research hypotheses and choosing an alpha level (3) selecting a sampling distribution and determining the test statistic that corresponds with the chosen alpha level (4) calculating the test statistic and (5) interpreting the results. Like the t tests we discussed previously, the chi-square test begins with a handful of assumptions, a pair of hypotheses, a sampling distribution and an alpha level and ends with a conclusion obtained via comparison of an obtained statistic with a critical statistic. The assumptions associated with the chi-square test are fairly straightforward: the data at hand must have been randomly selected (to minimize potential biases) and the variables in question must be nominal or ordinal (there are other methods to test the statistical independence of interval/ratio variables; these methods will be discussed in subsequent chapters). Regarding the hypotheses to be tested, all chi-square tests have the same general null and research hypotheses. The null hypothesis states that there is no relationship between the two variables, while the research hypothesis states that there is a relationship between the two variables. The test statistic follows a chi-square distribution, and the conclusion depends on whether or not our obtained statistic is greater that the critical statistic at our chosen alpha level .

In the following example, we'll use a chi-square test to determine whether there is a relationship between gender and getting in trouble at school (both nominal variables). Below is the table documenting the raw scores of boys and girls and their respective behavior issues (or lack thereof):

Gender and Getting in Trouble at School

  Got in Trouble Did Not Get in Trouble Total
Boys 46 71 117
Girls 37 83 120
Total 83 154 237

To examine statistically whether boys got in trouble in school more often, we need to frame the question in terms of hypotheses. The null hypothesis is that the two variables are independent (i.e. no relationship or correlation) and the research hypothesis is that the two variables are related. In this case, the specific hypotheses are:

H0: There is no relationship between gender and getting in trouble at school H1: There is a relationship between gender and getting in trouble at school

As is customary in the social sciences, we'll set our alpha level at 0.05

Next we need to calculate the expected frequency for each cell. These values represent what we would expect to see if there really were no relationship between the two variables. We calculate the expected frequency for each cell by multiplying the row total by the column total and dividing by the total number of observations. To get the expected count for the upper right cell, we would multiply the row total (117) by the column total (83) and divide by the total number of observations (237). (83 x 117)/237 = 40.97. If the two variables were independent, we would expect 40.97 boys to get in trouble. Or, to put it another way, if there were no relationship between the two variables, we would expect to see the number of students who got in trouble be evenly distributed across both genders.

We do the same thing for the other three cells and end up with the following expected counts (in parentheses next to each raw score):

  Got in Trouble Did Not Get in Trouble Total
Boys 46 (40.97) 71 (76.02) 117
Girls 37 (42.03) 83 (77.97) 120
Total 83 154 237

With these sets of figures, we calculate the chi-square statistic as follows:

when is null hypothesis rejected chi square

For each cell, we square the difference between the observed frequency and the expected frequency (observed frequency – expected frequency) and divide that number by the expected frequency. Then we add all of the terms (there will be four, one for each cell) together, like so:

when is null hypothesis rejected chi square

After we've crunched all those numbers, we end up with an obtained statistic of 1.87. ( Please note: a chi-square statistic can't be negative because nominal variables don't have directionality. If your obtained statistic turns out to be negative, you might want to check your math.) But before we can come to a conclusion, we need to find our critical statistic, which entails finding our degrees of freedom. In this case, the number of degrees of freedom is equal to the number of columns in the table minus one multiplied by the number of rows in the table minus one, or (r-1)(c-1). In our case, we have (2-1)(2-1), or one degree of freedom.

Finally, we compare our obtained statistic to our critical statistic found on the chi-square table posted in the "Files" section on Canvas. We also need to reference our alpha, which we set at .05. As you can see, the critical statistic for an alpha level of 0.05 and one degree of freedom is 3.841, which is larger than our obtained statistic of 1.87. Because the critical statistic is greater than our obtained statistic, we can't reject our null hypothesis.

The Limitations of the Chi-Square Test

There are two limitations to the chi-square test about which you should be aware. First, the chi-square test is very sensitive to sample size. With a large enough sample, even trivial relationships can appear to be statistically significant. When using the chi-square test, you should keep in mind that "statistically significant" doesn't necessarily mean "meaningful." Second, remember that the chi-square can only tell us whether two variables are related to one another. It does not necessarily imply that one variable has any causal effect on the other. In order to establish causality, a more detailed analysis would be required.

Main Points

  • The chi-square distribution is actually a series of distributions that vary in shape according to their degrees of freedom.
  • The chi-square test is a hypothesis test designed to test for a statistically significant relationship between nominal and ordinal variables organized in a bivariate table. In other words, it tells us whether two variables are independent of one another.
  • The obtained chi-square statistic essentially summarizes the difference between the frequencies actually observed in a bivariate table and the frequencies we would expect to see if there were no relationship between the two variables.
  • The chi-square test is sensitive to sample size.
  • The chi-square test cannot establish a causal relationship between two variables.

Carrying out the Chi-Square Test in SPSS

To perform a chi square test with SPSS, click "Analyze," then "Descriptive Statistics," and then "Crosstabs." As was the case in the last chapter, the independent variable should be placed in the "Columns" box, and the dependent variable should be placed in the "Rows" box. Now click on "Statistics" and check the box next to "Chi-Square." This test will provide evidence either in favor of or against the statistical independence of two variables, but it won't give you any information about the strength or direction of the relationship.

After looking at the output, some of you are probably wondering why SPSS provides you with a two-tailed p-value when chi-square is always a one-tailed test. In all honesty, I don't know the answer to that question. However, all is not lost. Because two-tailed tests are always more conservative than one-tailed tests (i.e., it's harder to reject your null hypothesis with a two-tailed test than it is with a one-tailed test), a statistically significant result under a two-tailed assumption would also be significant under a one-tailed assumption. If you're highly motivated, you can compare the obtained statistic from your output to the critical statistic found on a chi-square chart. Here's a video walkthrough with a slightly more detailed explanation:

  • Using the World Values Survey data, run a chi-square test to determine whether there is a relationship between sex ("SEX") and marital status ("MARITAL"). Report the obtained statistic and the p-value from your output. What is your conclusion?
  • Using the ADD Health data, run a chi-square test to determine whether there is a relationship between the respondent's gender ("GENDER") and his or her grade in math ("MATH"). Again, report the obtained statistic and the p-value from your output. What is your conclusion?
  • Career Advice
  • Computer Vision
  • Data Engineering
  • Data Science
  • Language Models
  • Machine Learning
  • Programming
  • Cheat Sheets
  • Recommendations
  • Tech Briefs

10 Statistics Questions to Ace Your Data Science Interview

Master statistics and land your first data science job.

Statistics Interview Questions for Data Science

I am a data scientist with a background in computer science.

I’m familiar with data structures, object oriented programming, and database management since I was taught these concepts for 3 years in university.

However, when entering the field of data science, I noticed a significant skill gap.

I didn’t have the math or statistics background required in almost every data science role.

I took a few online courses in statistics, but nothing seemed to really stick.

Most programs were either really basic and tailored to high level executives. Others were detailed and built on top of prerequisite knowledge I did not possess.

I spent time scouring the Internet for resources to better understand concepts like hypothesis testing and confidence intervals.

And after interviewing for multiple data science positions, I’ve found that most statistics interview questions followed a similar pattern.

In this article, I’m going to list 10 of the most popular statistics questions I’ve encountered in data science interviews, along with sample answers to these questions.  

Question 1: What is a p-value?

  Answer: Given that the null hypothesis is true, a p-value is the probability that you would see a result at least as extreme as the one observed.

P-values are typically calculated to determine whether the result of a statistical test is significant. In simple words, the p-value tells us whether there is enough evidence to reject the null hypothesis.  

Question 2: Explain the concept of statistical power

  Answer: If you were to run a statistical test to detect whether an effect is present, statistical power is the probability that the test will accurately detect the effect.

Here is a simple example to explain this:

Let’s say we run an ad for a test group of 100 people and get 80 conversions.

The null hypothesis is that the ad had no effect on the number of conversions. In reality, however, the ad did have a significant impact on the amount of sales.

Statistical power is the probability that you would accurately reject the null hypothesis and actually detect the effect. A higher statistical power indicates that the test is better able to detect an effect if there is one.  

Question 3: How would you describe confidence intervals to a non-technical stakeholder?

  Let’s use the same example as before, in which an ad is run for a sample size of 100 people and 80 conversions are obtained.

Instead of saying that the conversion rate is 80%, we would provide a range, since we don’t know how the true population would behave. In other words, if we were to take an infinite number of samples, how many conversions would we see?

Here is an example of what we might say solely based on the data obtained from our sample:

“If we were to run this ad for a larger group of people, we are 95% confident that the conversion rate will fall anywhere between 75% to 88%.”

We use this range because we don’t know how the total population will react, and can only generate an estimate based on our test group, which is just a sample.  

Question 4: What is the difference between a parametric and non-parametric test?

  A parametric test assumes that the dataset follows an underlying distribution. The most common assumption made when conducting a parametric test is that the data is normally distributed.

Examples of parametric tests include ANOVA, T-Test, F-Test and the Chi-squared test.

Non-parametric tests, however, don’t make any assumptions about the dataset’s distribution. If your dataset isn’t normally distributed, or if it contains ranks or outliers, it is wise to choose a non-parametric test.  

Question 5: What is the difference between covariance and correlation?

  Covariance measures the direction of the linear relationship between variables. Correlation measures the strength and direction of this relationship.

While both correlation and covariance give you similar information about feature relationship, the main difference between them is scale.

Correlation ranges between -1 and +1. It is standardized, and easily allows you to understand whether there is a positive or negative relationship between features and how strong this effect is. On the other hand, covariance is displayed in the same units as the dependent and independent variables, which can make it slightly harder to interpret.  

Question 6: How would you analyze and handle outliers in a dataset?

  There are a few ways to detect outliers in the dataset.

Question 7: Differentiate between a one-tailed and two-tailed test.

  A one-tailed test checks whether there is a relationship or effect in a single direction. For example, after running an ad, you can use a one-tailed test to check for a positive impact, i.e. an increase in sales. This is a right-tailed test.

A two-tailed test examines the possibility of a relationship in both directions. For instance, if a new teaching style has been implemented in all public schools, a two-tailed test would assess whether there is a significant increase or decrease in scores.  

Question 8: Given the following scenario, which statistical test would you choose to implement?

  An online retailer want to evaluate the effectiveness of a new ad campaign. They collect daily sales data for 30 days before and after the ad was launched. The company wants to determine if the ad contributed to a significant difference in daily sales.

Options: A) Chi-squared test B) Paired t-test C) One-way ANOVA d) Independent samples t-test

Answer : To evaluate the effectiveness of a new ad campaign, we should use an paired t-test. A paired t-test is used to compare the means of two samples and check if a difference is statistically significant. In this case, we are comparing sales before and after the ad was run, comparing a change in the same group of data, which is why we use a paired t-test instead of an independent samples t-test.  

Question 9: What is a Chi-Square test of independence?

  A Chi-Square test of independence is used to examine the relationship between observed and expected results. The null hypothesis (H0) of this test is that any observed difference between the features is purely due to chance.

In simple terms, this test can help us identify if the relationship between two categorical variables is due to chance, or whether there is a statistically significant association between them.

For example, if you wanted to test whether there was a relationship between gender (Male vs Female) and ice cream flavor preference (Vanilla vs Chocolate), you can use a Chi-Square test of independence.  

Question 10: Explain the concept of regularization in regression models.

  Regularization is a technique that is used to reduce overfitting by adding extra information to it, allowing models to adapt and generalize better to datasets that they haven't been trained on.

In regression, there are two commonly-used regularization techniques: ridge and lasso regression.

These are models that slightly change the error equation of the regression model by adding a penalty term to it.

In the case of ridge regression, a penalty term is multiplied by the sum of squared coefficients. This means that models with larger coefficients are penalized more. In lasso regression, a penalty term is multiplied by the sum of absolute coefficients.

While the primary objective of both methods is to shrink the size of coefficients while minimizing model error, ridge regression penalizes large coefficients more.

On the other hand, lasso regression applies a constant penalty to each coefficient, which means that coefficients can shrink to zero in some cases.  

10 Statistics Questions to Ace Your Data Science Interview — Next Steps

  If you’ve managed to follow along this far, congratulations!

You now have a strong grasp of the statistics questions asked in data science interviews.

As a next step, I recommend taking an online course to brush up on these concepts and put them into practice.

Here are some statistics learning resources I’ve found useful:

The final course can be audited for free on edX, whereas the first two resources are YouTube channels that cover statistics and machine learning extensively.

   

Natassha Selvaraj is a self-taught data scientist with a passion for writing. Natassha writes on everything data science-related, a true master of all data topics. You can connect with her on LinkedIn or check out her YouTube channel .

More On This Topic

  • Top 7 Essential Cheat Sheets To Ace Your Data Science Interview
  • 10 Cheat Sheets You Need To Ace Data Science Interview
  • 7 Super Cheat Sheets You Need To Ace Machine Learning Interview
  • 24 SQL Questions You Might See on Your Next Interview
  • KDnuggets News, May 4: 9 Free Harvard Courses to Learn Data…
  • How to Answer Data Science Coding Interview Questions

when is null hypothesis rejected chi square

Get the FREE ebook 'The Great Big Natural Language Processing Primer' and 'The Complete Collection of Data Science Cheat Sheets' along with the leading newsletter on Data Science, Machine Learning, AI & Analytics straight to your inbox.

By subscribing you accept KDnuggets Privacy Policy

Latest Posts

  • 3 Ways of Building Python Projects using GPT-4o
  • 7 AI Portfolio Projects to Boost the Resume
  • 10 GitHub Repositories to Master Statistics
  • 5 IT Jobs That Are High in Demand But Don’t Get Enough Recognition
  • 5 Python Tips for Data Efficiency and Speed
  • 5 Free Online Courses to Learn Data Engineering Fundamentals
  • NumPy for Image Processing
  • Organize, Search, and Back Up Files with Python’s Pathlib
  • 6 ChatGPT Prompts to Enhance your Productivity at Work
  • Time Series Data with NumPy

when is null hypothesis rejected chi square

No, thanks!

  • School Guide
  • Mathematics
  • Number System and Arithmetic
  • Trigonometry
  • Probability
  • Mensuration
  • Maths Formulas
  • Class 8 Maths Notes
  • Class 9 Maths Notes
  • Class 10 Maths Notes
  • Class 11 Maths Notes
  • Class 12 Maths Notes

Chi-square with Ordinal Data

Chi-square test is a primordial technique employed by statisticians to evaluate the hypothesis concerned with an association between two variables. This article will take you through an understanding of the Chi-square test especially when used with ordinal data.

In this article, we will learn the general concept of the test, the assumption placed on it and how and in what manner all these results may be understood and analyzed.

Table of Content

What is Chi-Square Test?

Chi-square test formula, how to calculate the chi-square statistic, what is ordinal data, using chi-square test with ordinal data, how to interpret chi-square test results, example of chi-square with ordinal data.

Chi-square test can be described as the statistical method that is used in testing the variation between the categories’ explanations of the collected data. It is mainly applied to examine hypotheses relating to the correlation between two variables. It is used comprehensively in numerous areas of studies including marketing, political science, and biology to determine if the distribution of categorical variables deviates from what is expected by chance.

The formula for the Chi-square statistic (χ 2 ) is:

[Tex]\chi^2 = \sum \frac{(O_i – E_i)^2}{E_i}[/Tex]
  • O i is Observed Frequency
  • E i is Expected frequency

Each component represents the observed and expected frequencies for each category. It is a mathematical formula used when arriving at the test statistic which is the sum of the squared difference between the frequency that occurred, and that which was expected, all divided by the expected frequency.

The steps to calculate Chi-Square Statistics are as follows:

Step 1: Define Hypotheses: Squash your null hypothesis (H 0 ) and alternative hypotheses (H 1 ). Step 2: Create a Contingency Table: Tabulate observed frequencies. Step 3: Calculate Expected Frequencies: For each cell, use [Tex]E_i = \frac{(\text{row total} \times \text{column total})}{\text{grand total}}[/Tex] Step 4: Determine χ 2 : Using the above-mentioned formula ascertain the corresponding value of Chi-square for the categorical data. Step 5: Determine Degrees of Freedom: The following should be applied as ((r–1)X(c–1)) where r is the number of rows & c is the number of columns. Step 6: Compare with Critical Value: Here it is necessary to check the obtained Chi-square statistic against the Chi-square critical value from distribution table.

Expected vs. Observed Frequencies

Referring to the Chi-square test, observed frequencies ‘O’ represent true data values gathered using a study or an experiment. On the other hand, expected frequencies ‘E’ are believed frequencies which would exist if the two variables under investigation are independent of each other.

Assumptions for Chi-Square Test

Various assumption for Chi-square test includes:

  • Independence: Observations must be independent of each other.
  • Expected Frequency: Each expected frequency should be at least 5.
  • Categorical Data: Data must be in categorical form.

Meeting these assumptions ensures the validity of the Chi-square test results.

Ordinal data are quantitative data that can be ranked in order but the intervals between them are not fixed. The main difference between nominal data and ordinal data is that the former is characterized by ordering while the intervals between terms are irregular.

Examples include:

  • Customer satisfaction ratings (e.g., Excellent, Good, Fair, Poor)
  • Education levels (e.g., High School, Bachelor’s, Master’s).

To use chi-square test with ordinal data follow the steps added below:

Step 1: Organize Data: Create a contingency table with ordinal categories. Step 2: Compute Expected Frequencies: As before, calculate for each cell. Step 3: Calculate Chi-Square Statistic: Use the same formula. Step 4: Evaluate Results: Check the Chi-square value against the critical value.

Challenges with ordinal data include ensuring the data’s order is considered without assuming equal intervals between categories.

The p-value shows the likelihood of these associations existing by mere coincidence. If the p-value is less than the specifically set significance level for instance 0.05 then the null hypothesis is rejected, implying a relationship between the two variables.

Understanding Statistical Significance

The term statistical significance refers to the results which cannot be attributed to random occurrence. Communicate these results clearly, emphasizing their practical implications and limitations.

Let’s consider a hypothetical dataset of customer satisfaction and service quality ratings. The observed frequencies are as follows:


High

Medium

Low

Satisfied

30

20

10

Neutral

20

30

10

Unsatisfied

10

20

30

Calculate Row Totals, Column Totals, and Grand Total: [Tex]\begin{array}{|c|c|c|c|c|} \hline & \text{High} & \text{Medium} & \text{Low} & \text{Row Total} \\ \hline \text{Satisfied} & 30 & 20 & 10 & 60 \\ \hline \text{Neutral} & 20 & 30 & 10 & 60 \\ \hline \text{Unsatisfied} & 10 & 20 & 30 & 60 \\ \hline \text{Column Total} & 60 & 70 & 50 & 180 \\ \hline \end{array}[/Tex] Calculate Expected Frequencies (E): Expected frequency for each cell can be calculated using the formula: [Tex]E = \frac{(\text{Row Total} \times \text{Column Total})}{\text{Grand Total}} [/Tex] For example, the expected frequency for “Satisfied” and “High”: [Tex]E_{\text{Satisfied, High}} = \frac{(60 \times 60)}{180} = 20 [/Tex] Here are the expected frequencies for all cells: [Tex]\begin{array}{|c|c|c|c|} \hline & \text{High} & \text{Medium} & \text{Low} \\ \hline \text{Satisfied} & 20 & 23.33 & 16.67 \\ \hline \text{Neutral} & 20 & 23.33 & 16.67 \\ \hline \text{Unsatisfied} & 20 & 23.33 & 16.67 \\ \hline \end{array}[/Tex] Calculate Chi-Square Statistic (χ 2 ): The Chi-square statistic is calculated using the formula: [Tex]\chi^2 = \sum \frac{(O_i – E_i)^2}{E_i} [/Tex] Let’s calculate χ 2 : [Tex]\chi^2 = \frac{(30 – 20)^2}{20} + \frac{(20 – 23.33)^2}{23.33} + \frac{(10 – 16.67)^2}{16.67} \\ \quad + \frac{(20 – 20)^2}{20} + \frac{(30 – 23.33)^2}{23.33} + \frac{(10 – 16.67)^2}{16.67} \\ \quad + \frac{(10 – 20)^2}{20} + \frac{(20 – 23.33)^2}{23.33} + \frac{(30 – 16.67)^2}{16.67} \\ = \frac{(10)^2}{20} + \frac{(-3.33)^2}{23.33} + \frac{(-6.67)^2}{16.67} \\ \quad + \frac{(0)^2}{20} + \frac{(6.67)^2}{23.33} + \frac{(-6.67)^2}{16.67} \\ \quad + \frac{(-10)^2}{20} + \frac{(-3.33)^2}{23.33} + \frac{(13.33)^2}{16.67} \\ = \frac{100}{20} + \frac{11.09}{23.33} + \frac{44.49}{16.67} \\ \quad + \frac{0}{20} + \frac{44.49}{23.33} + \frac{44.49}{16.67} \\ \quad + \frac{100}{20} + \frac{11.09}{23.33} + \frac{177.69}{16.67} \\ = 5 + 0.48 + 2.67 \\ \quad + 0 + 1.91 + 2.67 \\ \quad + 5 + 0.48 + 10.66 \\ = 5 + 0.48 + 2.67 + 0 + 1.91 + 2.67 + 5 + 0.48 + 10.66 \\ = 28.37[/Tex] Degrees of Freedom: The degrees of freedom (df) are calculated using: df = (r-1) × (c-1) For our example: df = (3-1) × (3-1) = 2 × 2 = 4 Compare with Critical Value: We compare the calculated χ 2 value with the critical value from the Chi-square distribution table at a specific significance level (e.g., 0.05). For df = 4, the critical value at 0.05 significance level is approximately 9.488. Since χ 2 = 28.37 is greater than 9.488, we reject the null hypothesis, suggesting a significant association between customer satisfaction and service quality.

Chi-square test is one of the several relevant statistic tests one can use and it is meant for dealing with categorical data hence makes it relevant with ordinal data. Therefore, after elaborating on the assumptions, calculations, and the interpretation process, you can apply this test to your data. This guide should help you grasp the concepts and perform Chi-square tests confidently.

Problems on Chi-Square with Ordinal Data

Problem 1: A teacher wants to determine if there is a significant association between students’ satisfaction levels and their grades in a class. The satisfaction levels are “Satisfied,” “Neutral,” and “Unsatisfied,” while the grades are “High,” “Medium,” and “Low.” The data collected is as follows:

Calculate Row Totals and Column Totals:


High

Medium

Low

Row Total

Satisfied

30

20

10

60

Neutral

20

30

10

60

Unsatisfied

10

20

30

60

Column Total

60

70

50

180

Calculate Expected Frequencies (E):

[Tex]E_i = \frac{R_i \times C_j}{N}[/Tex]

[Tex]E_{11} = \frac{(40 \times 30)}{100} = 12[/Tex]

[Tex]E_{12} = \frac{(40 \times 70)}{100} = 28[/Tex]

[Tex]E_{21} = \frac{(60 \times 30)}{100} = 18[/Tex]

[Tex]E_{22} = \frac{(60 \times 70)}{100} = 42[/Tex]

Calculate the Chi-Square Statistic (χ 2 ):

[Tex]\chi^2 = \sum \frac{(O_{ij} – E_{ij})^2}{E_{ij}}[/Tex]

[Tex]\chi^2 = \frac{(10-12)^2}{12} + \frac{(30-28)^2}{28} + \frac{(20-18)^2}{18} + \frac{(40-42)^2}{42}[/Tex]

[Tex]\chi^2 = \frac{4}{12} + \frac{4}{28} + \frac{4}{18} + \frac{4}{42}[/Tex]

[Tex]\chi^2 = 0.33 + 0.14 + 0.22 + 0.10[/Tex]

[Tex]\chi^2 = 0.79[/Tex]

Degrees of Freedom:

[Tex]\text{df} = (r – 1) \times (c – 1)[/Tex]

[Tex]\text{df} = (2-1) \times (2-1) = 1[/Tex]

Compare with Critical Value:

At α=0.05 and df=4, the critical value from the Chi-square table is 9.488. Since χ 2 =29.119 is greater than 9.488, we reject the null hypothesis and conclude that there is a significant association between satisfaction levels and grades.

Problem 2: A researcher wants to study the relationship between exercise frequency and stress levels among adults. The exercise frequency is categorized as “Never,” “Sometimes,” and “Often,” while stress levels are categorized as “Low,” “Moderate,” and “High.” The data collected is as follows:


Low

Moderate

High

Never

25

15

10

Sometimes

20

30

15

Often

10

25

35


High

Medium

Low

Row Total

Never

25

15

10

50

Sometimes

20

30

15

65

Often

10

25

35

70

Column Total

55

70

60

185

[Tex]E_{ij} = \frac{(R_i \times C_j)}{N}[/Tex]

[Tex]E_{11} = \frac{(50 \times 40)}{120} = 16.67[/Tex]

[Tex]E_{12} = \frac{(50 \times 80)}{120} = 33.33[/Tex]

[Tex]E_{21} = \frac{(70 \times 40)}{120} = 23.33[/Tex]

[Tex]E_{22} = \frac{(70 \times 80)}{120} = 46.67[/Tex]

[Tex]\chi^2 = \frac{(20-16.67)^2}{16.67} + \frac{(30-33.33)^2}{33.33} + \frac{(20-23.33)^2}{23.33} + \frac{(50-46.67)^2}{46.67}[/Tex]

[Tex]\chi^2 = \frac{11.11}{16.67} + \frac{11.11}{33.33} + \frac{11.11}{23.33} + \frac{11.11}{46.67}[/Tex]

[Tex]\chi^2 = 0.67 + 0.33 + 0.48 + 0.24[/Tex]

[Tex]\chi^2 = 1.72[/Tex]

At α=0.05 and df=4, the critical value from the Chi-square table is 9.488. Since χ 2 =25.80 is greater than 9.488, we reject the null hypothesis and conclude that there is a significant association between exercise frequency and stress levels.

Practice Problems on Chi-Square with Ordinal Data

P1. A survey was conducted to study the association between students’ interest in different subjects (Math, Science, English) and their performance levels (High, Average, Low). The data collected is as follows:


High

Average

Low

Math

30

40

30

Science

20

30

50

English

10

20

70

Determine if there is a significant association between interest in subjects and performance levels using the Chi-square test.

P2. A health study aims to explore the relationship between diet type (Vegetarian, Non-Vegetarian, Vegan) and cholesterol levels (Low, Medium, High). The data collected is as follows:


Low

Medium

High

Vegetarian

25

35

20

Non-Vegetarian

15

25

40

Vegan

20

30

10

Use the Chi-square test to determine if there is a significant association between diet type and cholesterol levels.

P3. An environmental scientist is studying the relationship between pollution levels in different areas (Urban, Suburban, Rural) and the health outcomes of residents (Good, Fair, Poor). The data collected is:


Good

Fair

Poor

Urban

30

20

50

Suburban

40

30

30

Rural

50

40

20

Determine if there is a significant association between area type and health outcomes using the Chi-square test.

FAQs on Chi-Square Test with ordinal data

Can a chi-square test be used with ordinal data.

Yes, it is possible to conduct a chi-square test to check the connection with the ordinal level of data when testing two nominal variables. However, it appears to disregard the sequence in which the data is received.

What data type do you need for a chi-square test nominal ordinal categorical interval?

Whenever, performing a chi-square test, one is bound to use data which is in the form of categories though it could be nominal data, ordinal data or a dichotomous data.

What statistical test is used for ordinal data?

For ordinal data, the test could be the Mann-Whitney U test or the Kruskal-Wallis test since the arrangement of the data tends to be of importance.

Can chi-square be used for dichotomous variables?

Yes, the chi-square test can be used on dichotomous variables to find if there is an association between two binary variables.

What are the limitations of chi-square?

The chi-square test requires large sample sizes, assumes expected frequencies of at least 5, and does not consider the order of ordinal data.

Please Login to comment...

Similar reads.

  • School Learning
  • Math-Statistics

Improve your Coding Skills with Practice

 alt=

What kind of Experience do you want to share?

IMAGES

  1. Reject Null Hypothesis Chi Square Test

    when is null hypothesis rejected chi square

  2. Chi Square Null Hypothesis Example

    when is null hypothesis rejected chi square

  3. Reject Null Hypothesis Chi Square Test

    when is null hypothesis rejected chi square

  4. Pearson Chi-Square

    when is null hypothesis rejected chi square

  5. PPT

    when is null hypothesis rejected chi square

  6. Chi-Square Summary Sheet

    when is null hypothesis rejected chi square

COMMENTS

  1. Chi-Square (Χ²) Tests

    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.

  2. Understanding the Null Hypothesis in Chi-Square

    The null hypothesis in chi-square tests is essentially a statement of no effect or no relationship. When it comes to categorical data, it indicates that the distribution of categories for one variable is not affected by the distribution of categories of the other variable. For example, if we compare the preference for different types of fruit ...

  3. 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.

  4. Chi-square statistic for hypothesis testing

    Watch a video that explains how to use the chi-square statistic to test hypotheses about categorical data with an example.

  5. 11: Chi-Square Tests

    The chi-square test of independence uses this fact to compute expected values for the cells in a two-way contingency table under the assumption that the two variables are independent (i.e., the null hypothesis is true).

  6. When Do You Reject the Null Hypothesis? (3 Examples)

    A hypothesis test is a formal statistical test we use to reject or fail to reject a statistical hypothesis. We always use the following steps to perform a hypothesis test: Step 1: State the null and alternative hypotheses. The null hypothesis, denoted as H0, is the hypothesis that the sample data occurs purely from chance.

  7. Master Chi-Square Test : Accept or Reject Null Hypothesis

    Step -3 : Rejecting the Null Hypothesis : Compare above 2 values (calculated statistical value & value from chi square distribution table) to determine whether to reject null hypothesis or not.

  8. 8.1

    Under the null hypothesis and certain conditions (discussed below), the test statistic follows a Chi-Square distribution with degrees of freedom equal to ( r − 1) ( c − 1), where r is the number of rows and c is the number of columns. We leave out the mathematical details to show why this test statistic is used and why it follows a Chi-Square distribution.

  9. PDF The Chi Square Test

    The final step of the chi-square test of significance is to determine if the value of the chi-square test statistic is large enough to reject the null hypothesis.

  10. 11.1: Chi-Square Tests for Independence

    We would reject the null hypothesis that the factors are independent only if this number is large, so the test is right-tailed. In this example the random variable ∑ (O − E)2 / E has the chi-square distribution with one degree of freedom.

  11. Step 5

    If your chi-square calculated value is greater than the chi-square critical value, then you reject your null hypothesis. If your chi-square calculated value is less than the chi-square critical value, then you "fail to reject" your null hypothesis. Figure 5. Finding the probability value for a chi-square of 1.2335 with 1 degree of freedom.

  12. What Is The Null Hypothesis & When To Reject It

    We reject the null hypothesis when the data provide strong enough evidence to conclude that it is likely incorrect. This often occurs when the p-value (probability of observing the data given the null hypothesis is true) is below a predetermined significance level.

  13. Pearson's chi square test (goodness of fit)

    I understand that if the chi-square value exceeds the appropriate minimum value in the chi-square distribution table, taken into account the degrees of freedom, you can reject the null hypothesis.

  14. Chi-squared test

    Chi-squared test Chi-squared distribution, showing χ2 on the x -axis and p -value (right tail probability) on the y -axis. A chi-squared test (also chi-square or χ2 test) is a statistical hypothesis test used in the analysis of contingency tables when the sample sizes are large.

  15. Chi-Square Goodness of Fit Test

    Example: Chi-square goodness of fit test conditions. You can use a chi-square goodness of fit test to analyze the dog food data because all three conditions have been met: You want to test a hypothesis about the distribution of one categorical variable. The categorical variable is the dog food flavors. You recruited a random sample of 75 dogs.

  16. 6.2

    The Chi-square test statistic is calculated as follows: χ 2 ∗ = ∑ i = 1 r c ( O i − E i) 2 E i. Under the null hypothesis and certain conditions (discussed below), the test statistic follows a Chi-square distribution with degrees of freedom equal to ( r − 1) ( c − 1), where r is the number of rows and c is the number of columns.

  17. chi squared test

    2 Why do we reject null hypothesis of a Goodness of test when the Chi square statistic is more than the tabulated value of chi-square at say 5% level of significance and accept when it is less?

  18. Pearson's chi-squared test

    A simple example is testing the hypothesis that an ordinary six-sided dice is "fair" (i. e., all six outcomes are equally likely to occur). In this case, the observed data is , the number of times that the dice has fallen on each number. The null hypothesis is , and . As detailed below, if , then the fairness of dice can be rejected at the level of .

  19. 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.

  20. Chi-Square Test of Independence

    A chi-square test of independence is a nonparametric hypothesis test used to find out whether two categorical variables are related to each other.

  21. Chi-Square (χ2) Statistic: What It Is, Examples, How and When to Use

    Chi Square Statistic: A chi square statistic is a measurement of how expectations compare to results. The data used in calculating a chi square statistic must be random, raw, mutually exclusive ...

  22. What is a Chi-Square Test? Formula, Examples & Application

    Compare the chi-square statistic to the critical value to decide whether to reject the null hypothesis. These practice problems help you understand how chi-square analysis tests hypotheses and explores relationships between categorical variables in various fields.

  23. Chi-Square

    The Chi-Square Test. Earlier in the semester, you familiarized yourself with the five steps of hypothesis testing: (1) making assumptions (2) stating the null and research hypotheses and choosing an alpha level (3) selecting a sampling distribution and determining the test statistic that corresponds with the chosen alpha level (4) calculating ...

  24. 10 Statistics Questions to Ace Your Data Science Interview

    In simple words, the p-value tells us whether there is enough evidence to reject the null hypothesis. Question 2: Explain the concept of statistical power ... A Chi-Square test of independence is used to examine the relationship between observed and expected results. The null hypothesis (H0) of this test is that any observed difference between ...

  25. Chi-square with Ordinal Data

    Since χ 2 = 28.37 is greater than 9.488, we reject the null hypothesis, suggesting a significant association between customer satisfaction and service quality. Conclusion. Chi-square test is one of the several relevant statistic tests one can use and it is meant for dealing with categorical data hence makes it relevant with ordinal data.