• Users Online: 212
  • Home
  • Print this page
  • Email this page
Home About us Editorial board Ahead of print Current issue Search Archives Submit article Instructions Subscribe Contacts Login 

 Table of Contents  
Year : 2015  |  Volume : 1  |  Issue : 1  |  Page : 69-71

Chi-square test and its application in hypothesis testing

Statistical Section, Central Council for Research in Ayurvedic Sciences, Ministry of AYUSH, GOI, New Delhi, India

Date of Web Publication22-May-2015

Correspondence Address:
Dr. Richa Singhal
Central Council for Research in Ayurvedic Sciences, Ministry of AYUSH, GOI, New Delhi
Login to access the Email id

Source of Support: None, Conflict of Interest: None

DOI: 10.4103/2395-5414.157577

Rights and Permissions

In medical research, there are studies which often collect data on categorical variables that can be summarized as a series of counts. These counts are commonly arranged in a tabular format known as a contingency table. The chi-square test statistic can be used to evaluate whether there is an association between the rows and columns in a contingency table. More specifically, this statistic can be used to determine whether there is any difference between the study groups in the proportions of the risk factor of interest. Chi-square test and the logic of hypothesis testing were developed by Karl Pearson. This article describes in detail what is a chi-square test, on which type of data it is used, the assumptions associated with its application, how to manually calculate it and how to make use of an online calculator for calculating the Chi-square statistics and its associated P-value.

Keywords: Categorical data analysis, Chi-square test, hypothesis testing, online calculator

How to cite this article:
Rana R, Singhal R. Chi-square test and its application in hypothesis testing. J Pract Cardiovasc Sci 2015;1:69-71

How to cite this URL:
Rana R, Singhal R. Chi-square test and its application in hypothesis testing. J Pract Cardiovasc Sci [serial online] 2015 [cited 2021 Nov 29];1:69-71. Available from: https://www.j-pcs.org/text.asp?2015/1/1/69/157577

The logic of hypothesis testing was first invented by Karl Pearson (1857-1936), a renaissance scientist, in Victorian London in 1900. [1] Pearson's Chi-square distribution and the Chi-square test also known as test for goodness-of-fit and test of independence are his most important contribution to the modern theory of statistics. The importance of Pearson's Chi-square distribution was that, the statisticians could use the statistical methods that did not depend on the normal distribution to interpret the findings. He invented the Chi-square distribution to mainly cater the needs of biologists, economists, and psychologists. His paper in 1900 published in Philosophical magazine elaborates the invention of Chi-square distribution and goodness of fit test. [2],[3]

Chi-square test is a nonparametric test used for two specific purpose: (a) To test the hypothesis of no association between two or more groups, population or criteria (i.e. to check independence between two variables); (b) and to test how likely the observed distribution of data fits with the distribution that is expected (i.e., to test the goodness-of-fit). It is used to analyze categorical data (e.g. male or female patients, smokers and non-smokers, etc.), it is not meant to analyze parametric or continuous data (e.g., height measured in centimeters or weight measured in kg, etc.).

For example if we want to test that in a health camp attended by 50 persons the one who exercise regularly are having lesser body mass index (BMI) by taking their actual BMI values, than it cannot be tested using a Chi-square test. However, if we divide the same set of 50 persons into two categories as obese with BMI ≥ 30 and nonobese with BMI < 30, than the same data can be tested using a Chi-square test by counting the number of obese and nonobese persons across two groups, the one who exercise regularly and the one who does not. A 2x2 contingency table also known as cross tables can be constructed for calculating a Chi-square statistic [Table 1].
Table 1: Sample of a 2×2 contingency table

Click here to view

  Assumptions Underlying a Chi-square Test Top

  • The data are randomly drawn from a population
  • The values in the cells are considered adequate when expected counts are not <5 and there are no cells with zero count [4],[5]
  • The sample size is sufficiently large. The application of the Chi-square test to a smaller sample could lead to type II error (i.e. accepting the null hypothesis when it is actually false). There is no expected cut-off for the sample size; however, the minimum sample size varies from 20 to 50
  • The variables under consideration must be mutually exclusive. It means that each variable must only be counted once in a particular category and should not be allowed to appear in other category. In other, words no item shall be counted twice.

  How to Calculate a Chi-square Statistics? Top

The formula for calculating a Chi-square statistic is:


O stands for the observed frequency,

E stands for the expected frequency.

Expected count is subtracted from the observed count to find the difference between the two. Then the square of the difference is calculated to get rid of the negative vales (as the squares of 2 and −2 are, of course, both 4). Then the square of the difference is divided by the expected count to normalize bigger and smaller values (because we don't want to get bigger Chi-square values just because we are working on large data sets). The sigma sign in front of them denotes that we have, to sum up, these values calculated for each cell.

As an example, suppose we want to find out that whether there is an association between smoking and lung disease.

The null and alternative hypothesis will be:

H 0 : There is no association between smoking and lung disease.

H 1 : There is an association between smoking and lung disease.

The basic step for calculating a Chi-square test is setting up a 2 × 2 contingency table [Table 2].
Table 2: General notation for a 2×2 contingency table (observed values for the data)

Click here to view

The general formula for calculating the expected counts from observed count for a particular cell is [(corresponding row total * corresponding column total) /Total no. of patients] [Table 3].
Table 3: Expected values for the data presented in a 2×2 table

Click here to view

Before we proceed further, we need to know how many degrees of freedom (df) we have. When a comparison is made between one sample and another, a simple rule is that the df equals (number of columns − 1) × (number of rows − 1) excluding the rows and column containing the total. Hence, in our example df = (2−1) × (2−1) = 1.

Hypothetical data for calculating the Chi-square test for our example of testing an association between smoking and lung disease is given in [Table 4]. Chi-square test can be calculated manually by using the formula described above. Refer [Table 5] and [Table 6] for manual calculations. Chi-square value for our example as shown in [Table 6] is 3.42, df = 1. If we want to test our hypothesis at 5% level of significance than our predetermined alpha level of significance is 0.05. Looking into the Chi-square distribution table [Table 7] with 1 degree of freedom and reading along the row we find our value of χ2 (3.42) lies between 2.706 and 3.841. The corresponding probability is between the 0.10 and 0.05 probability levels. That means that the P value is above 0.05 (it is actually 0.065). Since a P value of 0.065 is greater than the conventionally accepted significance level of 0.05 (i.e., P > 0.05) we fail to reject the null hypothesis or in other words we accept our null hypothesis and conclude that there is no association between smoking and lung disease.
Table 4: Hypothetical data containing observed values for calculating Chi-square statistics

Click here to view
Table 5: Expected values for the hypothetical data

Click here to view
Table 6: Summarizing the data for calculating the Chi-square value

Click here to view
Table 7: Excerpts from the Chi-square distribution table

Click here to view

  How to Use a Chi-square Distribution Table to Approximate P Value? Top

Scientists and statisticians use large tables of values to calculate the P value for their experiment. These tables are generally set up with the vertical axis on the left corresponding to df and the horizontal axis on the top corresponding to P value. Use these tables by first finding our df, then reading that row across from the left to the right until we find the first value bigger than our Chi-square value. Look at the corresponding P value at the top of the column. Chi-square distribution tables are available from a variety of sources-they can easily be found online or in science and statistics textbooks.

  Using an Online Chi-square Calculator Top

The Chi-square statistics and its associated P value can be calculated through online calculators also which are easily available on the internet. For user-friendly online calculator, you may visit this uniform resource locator www.socscistatistics.com/tests/chisquare/default2.aspx. Many more online calculators are available on the World Wide Web. The basic step for using an online calculator is to correctly fill in your data into it.

Step by step procedure of using an online calculator is described below:

  • Step 1: For our example of finding an association between smoking and lung disease we have to fill in the observed values in the cells of an online calculator [Figure 1]
    Figure 1: Setting up the data in the 2 × 2 table of an online calculator.

    Click here to view
  • Step 2: Click on the next button. Another screen will pop up as shown in [Figure 2]
    Figure 2: Setting up the significance level for calculation.

    Click here to view
  • Step 3: Click on the Calculate Chi^2 button. And you are done with your calculation Output of the Chi-square test will be as shown in [Figure 3].
    Figure 3: Chi-square value and P-value calculated by online calculator.

    Click here to view

The image above shows the Chi-square value as 3.4177 and its associated P value as 0.0645 which is actually greater than P value of 0.05, hence no significant difference has been observed. To conclude, there is no association between smoking and lung disease.

  What Does a Chi-square Test Tell and What it Does Not? Top

It may be clearly understood that Chi-square test only tells us the probability of independence of a distribution of data or in simple terms it will only test that whether two variables are associated with each other or not. It will not tell us that how closely they are associated. For instance in the above example, the Chi-square test will only tell us that whether there is any relation between smoking and lung disease. It will not tell us that how likely it is, that smokers are prone to lung disease. However, once we got to know that there is a relation between these two variables, we can explore other methods to calculate the amount of association between them.

  References Top

Magnello ME Karl Pearson and the origin of modern statistics: An elastician becomes a statistician, Rutherford J, Vol. 1, 2005-2006. Available online at: http://rutherfordjournal.org.  Back to cited text no. 1
Pearson K. On the criterion that a given system of deviations from the probable in the case of a correlated system of variables is such that it can be reasonably supposed to have arisen from random sampling. Philos Mag Ser 1900;50:157-75.  Back to cited text no. 2
Plackett RL. Karl Pearson and the Chi-squared test. Int Stat Rev 1983;51:59-72.  Back to cited text no. 3
Yates F, Moore D, McCabe G. The Practice of Statistics 1 st ed. New York: W.H.Freeman, 1999.  Back to cited text no. 4
Yates F. Contingency table involving small numbers and the Chi-squared test. Suppl J R Stat Soc 1934;1:217-35.  Back to cited text no. 5


  [Figure 1], [Figure 2], [Figure 3]

  [Table 1], [Table 2], [Table 3], [Table 4], [Table 5], [Table 6], [Table 7]

This article has been cited by
1 Patients 80?+ have similar medication initiation rates to those aged 50–79 in Ontario FLS
J. E. M. Sale,A. Yang,V. Elliot-Gibson,R. Jain,R. Sujic,D. Linton,J. Weldon,L. Frankel,E. Bogoch
Osteoporosis International. 2021;
[Pubmed] | [DOI]
2 Repurposing new drug candidates and identifying crucial molecules underlying PCOS Pathogenesis Based On Bioinformatics Analysis
Zeinab Dehghan,Samira Mohammadi-Yeganeh,Marzieh Sameni,Seyed Amir Mirmotalebisohi,Hakimeh Zali,Mohammad Salehi
DARU Journal of Pharmaceutical Sciences. 2021;
[Pubmed] | [DOI]
3 Development of a conceptual framework for risk assessment of elevated internal temperatures in landfills
Samain Sabrin,Rouzbeh Nazari,Maryam Karimi,Md Golam Rabbani Fahad,Jess Everett,Robert Peters
Science of The Total Environment. 2021; 782: 146831
[Pubmed] | [DOI]
4 Soil-litter ant (Hymenoptera: Formicidae) community response to reforested lands of Gishwati tropical montane forest, northern-western part of Rwanda
Venuste Nsengimana,Wouter Dekoninck
Journal of Tropical Ecology. 2021; : 1
[Pubmed] | [DOI]
5 Preference between Indian Picture Symbols for Communication (IPSC) and Picture Communication Symbols (PCS) in neurotypical adults and adults with aphasia
Vineetha Sara Philip,S. P. Goswami
Speech, Language and Hearing. 2021; : 1
[Pubmed] | [DOI]
6 Investigating the prevalence and predictors of food insecurity: a comparison of HFSSM and EU-SILC indicators
Emma Beacom, Christopher McLaughlin, Sinéad Furey, Lynsey Elizabeth Hollywood, Paul Humphreys
British Food Journal. 2021; ahead-of-p(ahead-of-p)
[Pubmed] | [DOI]
Yashen Wang,Huanhuan Zhang
ACM Transactions on Knowledge Discovery from Data. 2021; 15(2): 1
[Pubmed] | [DOI]
8 The impact of COVID-19 outbreak and perceptions of people towards household waste management chain in Nepal
Ashis Acharya,Govinda Bastola,Bindu Modi,Asmi Marhatta,Suraj Belbase,Ganesh Lamichhane,Narayan Gyawali,Ranjan Kumar Dahal
Geoenvironmental Disasters. 2021; 8(1)
[Pubmed] | [DOI]
9 Predicting Increase in Demand for Public Buses in University Students Daily Life Needs: Case Study Based on a City in Japan
Ali Bakdur,Fumito Masui,Michal Ptaszynski
Sustainability. 2021; 13(9): 5137
[Pubmed] | [DOI]
10 Impact of Gender and Expatriation Choice on Career Paths in Supply Chain Management: Evidence from Master of Science Graduates
Salomée Ruel,Anicia Jaegler
Sustainability. 2021; 13(12): 6907
[Pubmed] | [DOI]
11 Towards Sustainable Private Labels in an Autonomous Community during COVID-19—Analysis of Consumer Behavior and Perception on the Example of Tenerife
Maksymilian Czeczotko,Hanna Górska-Warsewicz,Waclaw Laskowski,Barbara Rostecka
Sustainability. 2021; 13(13): 7467
[Pubmed] | [DOI]
12 The Prevalence of Potentially Inappropriate Prescribing in the Elderly at the Primary Care Level in Kazakhstan
Ainash Ibysheva,Gulmira Muldaeva,Leila I. Arystan,Almagul B. Kuzgibekova,Bibigul A. Abeuova,Leila S. Haydargalieva
Open Access Macedonian Journal of Medical Sciences. 2021; 9(A): 572
[Pubmed] | [DOI]
13 An Analysis into the Contribution of Google Applications in the Successful Implementation of Online Education During the COVID-19 Pandemic
Rajeshwari M.,Rajeshwari Vinayachandra,Geetha Poornima K.,Krishna Prasad K.
International Journal of Applied Engineering and Management Letters. 2021; : 131
[Pubmed] | [DOI]
14 The Effect of Integration of Different Online Education Methods on Educational Advancement and Student Development: A Study
Geetha Poornima K.,Geetha Poornima Vinayachandra,Rajeshwari M.,Krishna Prasad K.
International Journal of Case Studies in Business, IT, and Education. 2021; : 200
[Pubmed] | [DOI]
15 Students’ Perception of the Effectiveness of Technology Assisted Online Education During COVID-19 Pandemic: An Empirical Study
Michal Vinayachandra,Geetha Poornima K.,Rajeshwari M.,Krishna Prasad K.
International Journal of Management, Technology, and Social Sciences. 2021; : 203
[Pubmed] | [DOI]
16 Sustainability Balanced Scorecard Architecture and Environmental Investment Decision-Making
Suaad Jassem,Zarina Zakaria,Anna Che Azmi
Foundations of Management. 2020; 12(1): 193
[Pubmed] | [DOI]
17 Awareness level on the role of forensic DNA database in criminal investigation in Nigeria: A case study of Benin city
Udogadi Nwawuba Stanley, Blessing Nkiruka Akpata Chinyere
Journal of Forensic Science and Research. 2020; 4(1): 007
[Pubmed] | [DOI]
18 A Novel Risk-Based Prioritization Approach for Wireless Sensor Network Deployment in Pipeline Networks
Xiaojian Yi,Peng Hou,Haiping Dong
Energies. 2020; 13(6): 1512
[Pubmed] | [DOI]
19 Fishers’ Perceptions and Attitudes toward Weather and Climate Information Services for Climate Change Adaptation in Senegal
Ndèye Seynabou Diouf,Issa Ouedraogo,Robert B. Zougmoré,Madické Niang
Sustainability. 2020; 12(22): 9465
[Pubmed] | [DOI]
20 Test of Association in the Presence of Complex Environment
Muhammad Aslam,Osama H. Arif
Complexity. 2020; 2020: 1
[Pubmed] | [DOI]
21 Understanding Discharge Voltage Inconsistency in Lithium-Ion Cells via Statistical Characteristics and Numerical Analysis
Linshu Wang,Yanyan Fang,Lve Wang,Fengling Yun,Jiantao Wang,Shigang Lu
IEEE Access. 2020; 8: 84821
[Pubmed] | [DOI]
22 Machine Learning-Based Application for Predicting Risk of Type 2 Diabetes Mellitus (T2DM) in Saudi Arabia: A Retrospective Cross-Sectional Study
Asif Hassan Syed,Tabrej Khan
IEEE Access. 2020; 8: 199539
[Pubmed] | [DOI]
23 Customers perception on logistics service quality using Kansei engineering: empirical evidence from indonesian logistics providers
Dian Palupi Restuputri,Ilyas Masudin,Citra Permata Sari,Albert W. K. Tan
Cogent Business & Management. 2020; 7(1)
[Pubmed] | [DOI]
24 Machine learning predicts live-birth occurrence before in-vitro fertilization treatment
Ashish Goyal,Maheshwar Kuchana,Kameswari Prasada Rao Ayyagari
Scientific Reports. 2020; 10(1)
[Pubmed] | [DOI]
25 Over 40% of 450 registered wheat cultivars (Triticum aestivum) worldwide are composed of multiple biotypes
Eugene Metakovsky,Viktor Melnik,Laura Pascual,Colin W. Wrigley
Journal of Cereal Science. 2020; : 103088
[Pubmed] | [DOI]
26 Analyzing expectation of landowners from Brownfield TOD project: A case study from MP Nagar, Bhopal
Manmeet C. Verma,Rahul Tiwari
Materials Today: Proceedings. 2020;
[Pubmed] | [DOI]
27 Gliadin genotypes worldwide for spring wheats (Triticum aestivum L.) 1. Genetic diversity and grain-quality gliadin alleles during the 20th century
E. Metakovsky,V.A. Melnik,L. Pascual,C.W. Wrigley
Journal of Cereal Science. 2019; 87: 172
[Pubmed] | [DOI]
28 Gliadin genotypes worldwide for spring wheats (Triticum aestivum L.) 2. Strong differentiation of polymorphism between countries and regions of origin
E. Metakovsky,V.A. Melnik,L. Pascual,C.W. Wrigley
Journal of Cereal Science. 2019; 87: 311
[Pubmed] | [DOI]
29 Types, frequencies and value of intra-varietal genotypic non-uniformity in common wheat cultivars: Authentic biotypes and foreign seeds
Eugene Metakovsky,Viktor Melnik,Laura Pascual,Georgy A. Romanov,Colin W. Wrigley
Journal of Cereal Science. 2019; : 102813
[Pubmed] | [DOI]
30 Embracing Sustainability in Shipping: Assessing Industry’s Adaptations Incited by the, Newly, Introduced ‘triple bottom line’ Approach to Sustainable Maritime Development
C.W. Fasoulis,C.W. Rafet
Social Sciences. 2019; 8(7): 208
[Pubmed] | [DOI]
31 There is a direct link between allantoin concentration and cadmium tolerance in Arabidopsis
Maryam Nourimand,Christopher D. Todd
Plant Physiology and Biochemistry. 2018;
[Pubmed] | [DOI]
32 Radiographer mammographersæ attitudes towards implementing new techniques for imaging the augmented breast, after viewing a training DVD or receiving cascade training: A survey
N.C. Moneme,J. Curtis
Radiography. 2018;
[Pubmed] | [DOI]
33 Exploring student learning profiles in algebra-based studio physics: A person-centered approach
Jarrad W.?T. Pond,Jacquelyn J. Chini
Physical Review Physics Education Research. 2017; 13(1)
[Pubmed] | [DOI]


Similar in PUBMED
   Search Pubmed for
   Search in Google Scholar for
 Related articles
Access Statistics
Email Alert *
Add to My List *
* Registration required (free)

  In this article
   Assumptions Unde...
   How to Calculate...
   How to Use a Chi...
   Using an Online ...
   What Does a Chi-...
   Article Figures
   Article Tables

 Article Access Statistics
    PDF Downloaded5188    
    Comments [Add]    
    Cited by others 33    

Recommend this journal