Chi - squared test - wikipedia Chi - squared test This article includes a list of references, but its sources remain unclear because it has insufficient inline citations. Please help to improve this article by introducing more precise citations. ( November 2014 ) Chi - squared distribution, showing χ on the x-axis and p - value on the y - axis. A chi - squared test, also written as χ test, is any statistical hypothesis test where the sampling distribution of the test statistic is a chi - squared distribution when the null hypothesis is true. Without other qualification, ' chi - squared test ' often is used as short for Pearson 's chi - squared test. The chi - squared test is used to determine whether there is a significant difference between the expected frequencies and the observed frequencies in one or more categories. In the standard applications of the test, the observations are classified into mutually exclusive classes, and there is some theory, or say null hypothesis, which gives the probability that any observation falls into the corresponding class. The purpose of the test is to evaluate how likely the observations that are made would be, assuming the null hypothesis is true. Chi - squared tests are often constructed from a sum of squared errors, or through the sample variance. Test statistics that follow a chi - squared distribution arise from an assumption of independent normally distributed data, which is valid in many cases due to the central limit theorem. A chi - squared test can be used to attempt rejection of the null hypothesis that the data are independent. Also considered a chi - squared test is a test in which this is asymptotically true, meaning that the sampling distribution ( if the null hypothesis is true ) can be made to approximate a chi - squared distribution as closely as desired by making the sample size large enough. Contents 1 History 1.1 Pearson 's chi - squared test 1.2 Other examples of chi - squared tests 1.2. 1 Fisher 's exact test 1.2. 2 Yates 's correction for continuity 1.2. 3 Other chi - squared tests 2 Chi - squared test for variance in a normal population 3 Example chi - squared test for categorical data 4 Applications 5 See also 6 References 7 Further reading History In the 19th century, statistical analytical methods were mainly applied in biological data analysis and it was customary for researchers to assume that observations followed a normal distribution, such as Sir George Airy and Professor Merriman, whose works were criticized by Karl Pearson in his 1900 paper. Until the end of 19th century, Pearson noticed the existence of significant skewness within some biological observations. In order to model the observations regardless of being normal or skewed, Pearson, in a series of articles published from 1893 to 1916, devised the Pearson distribution, a family of continuous probability distributions, which includes the normal distribution and many skewed distributions, and proposed a method of statistical analysis consisting of using the Pearson distribution to model the observation and performing the test of goodness of fit to determine how well the model and the observation really fit. Pearson 's chi - squared test See also : Pearson 's chi - squared test In 1900, Pearson published a paper on the χ test which is considered to be one of the foundations of modern statistics. In this paper, Pearson investigated the test of goodness of fit. Suppose that n observations in a random sample from a population are classified into k mutually exclusive classes with respective observed numbers x ( for i = 1, 2,..., k ), and a null hypothesis gives the probability p that an observation falls into the ith class. So we have the expected numbers m = np for all i, where ∑ i = 1 k p i = 1 ∑ i = 1 k m i = n ∑ i = 1 k p i = ∑ i = 1 k x i ( displaystyle ( \begin ( aligned ) sum _ ( i = 1 ) ^ ( k ) ( p_ ( i ) ) & = 1 ( 8pt ) sum _ ( i = 1 ) ^ ( k ) ( m_ ( i ) ) & = n sum _ ( i = 1 ) ^ ( k ) ( p_ ( i ) ) = sum _ ( i = 1 ) ^ ( k ) x_ ( i ) end ( aligned ) ) ) Pearson proposed that, under the circumstance of the null hypothesis being correct, as n → ∞ the limiting distribution of the quantity given below is the χ distribution. X 2 = ∑ i = 1 k ( x i − m i ) 2 m i = ∑ i = 1 k x i 2 m i − n ( displaystyle X ^ ( 2 ) = sum _ ( i = 1 ) ^ ( k ) ( \frac ( ( x_ ( i ) - m_ ( i ) ) ^ ( 2 ) ) ( m_ ( i ) ) ) = sum _ ( i = 1 ) ^ ( k ) ( ( \frac ( x_ ( i ) ^ ( 2 ) ) ( m_ ( i ) ) ) - n ) ) Pearson dealt first with the case in which the expected numbers m are large enough known numbers in all cells assuming every x may be taken as normally distributed, and reached the result that, in the limit as n becomes large, X follows the χ distribution with k − 1 degrees of freedom. However, Pearson next considered the case in which the expected numbers depended on the parameters that had to be estimated from the sample, and suggested that, with the notation of m being the true expected numbers and m ′ being the estimated expected numbers, the difference X 2 − X ′ 2 = ∑ i = 1 k x i 2 m i − ∑ i = 1 k x i 2 m i ′ ( displaystyle X ^ ( 2 ) - ( X ' ) ^ ( 2 ) = sum _ ( i = 1 ) ^ ( k ) ( \frac ( x_ ( i ) ^ ( 2 ) ) ( m_ ( i ) ) ) - sum _ ( i = 1 ) ^ ( k ) ( \frac ( x_ ( i ) ^ ( 2 ) ) ( m'_ ( i ) ) ) ) will usually be positive and small enough to be omitted. In a conclusion, Pearson argued that if we regarded X ′ as also distributed as χ distribution with k − 1 degrees of freedom, the error in this approximation would not affect practical decisions. This conclusion caused some controversy in practical applications and was not settled for 20 years until Fisher 's 1922 and 1924 papers. Other examples of chi - squared tests One test statistic that follows a chi - squared distribution exactly is the test that the variance of a normally distributed population has a given value based on a sample variance. Such tests are uncommon in practice because the true variance of the population is usually unknown. However, there are several statistical tests where the chi - squared distribution is approximately valid : Fisher 's exact test For an exact test used in place of the chi - squared test, see Fisher 's exact test. Yates 's correction for continuity Main article : Yates 's correction for continuity Using the chi - squared distribution to interpret Pearson 's chi - squared statistic requires one to assume that the discrete probability of observed binomial frequencies in the table can be approximated by the continuous chi - squared distribution. This assumption is not quite correct and introduces some error. To reduce the error in approximation, Frank Yates suggested a correction for continuity that adjusts the formula for Pearson 's chi - squared test by subtracting 0.5 from the absolute difference between each observed value and its expected value in a 2 × 2 contingency table. This reduces the chi - squared value obtained and thus increases its p - value. Other chi - squared tests Cochran -- Mantel -- Haenszel chi - squared test. McNemar 's test, used in certain 2 × 2 tables with pairing Tukey 's test of additivity The portmanteau test in time - series analysis, testing for the presence of autocorrelation Likelihood - ratio tests in general statistical modelling, for testing whether there is evidence of the need to move from a simple model to a more complicated one ( where the simple model is nested within the complicated one ). Chi - squared test for variance in a normal population If a sample of size n is taken from a population having a normal distribution, then there is a result ( see distribution of the sample variance ) which allows a test to be made of whether the variance of the population has a pre-determined value. For example, a manufacturing process might have been in stable condition for a long period, allowing a value for the variance to be determined essentially without error. Suppose that a variant of the process is being tested, giving rise to a small sample of n product items whose variation is to be tested. The test statistic T in this instance could be set to be the sum of squares about the sample mean, divided by the nominal value for the variance ( i.e. the value to be tested as holding ). Then T has a chi - squared distribution with n − 1 degrees of freedom. For example, if the sample size is 21, the acceptance region for T with a significance level of 5 % is between 9.59 and 34.17. Example chi - squared test for categorical data Suppose there is a city of 1,000,000 residents with four neighborhoods : A, B, C, and D. A random sample of 650 residents of the city is taken and their occupation is recorded as `` white collar '', `` blue collar '', or `` no collar ''. The null hypothesis is that each person 's neighborhood of residence is independent of the person 's occupational classification. The data are tabulated as : A total White collar 90 60 104 95 349 Blue collar 30 50 51 20 151 No collar 30 40 45 35 150 Total 150 150 200 150 650 Let us take the sample living in neighborhood A, 150, to estimate what proportion of the whole 1,000,000 live in neighborhood A. Similarly we take 349 / 650 to estimate what proportion of the 1,000,000 are white - collar workers. By the assumption of independence under the hypothesis we should `` expect '' the number of white - collar workers in neighborhood A to be 150 × 349 650 ≈ 80.54 ( displaystyle 150 \times ( \frac ( 349 ) ( 650 ) ) approx 80.54 ) Then in that `` cell '' of the table, we have ( observed − expected ) 2 expected = ( 90 − 80.54 ) 2 80.54 ≈ 1.11 ( displaystyle ( \frac ( left ( ( \text ( observed ) ) - ( \text ( expected ) ) \right ) ^ ( 2 ) ) ( \text ( expected ) ) ) = ( \frac ( left ( 90 - 80.54 \right ) ^ ( 2 ) ) ( 80.54 ) ) approx 1.11 ) The sum of these quantities over all of the cells is the test statistic. Under the null hypothesis, it has approximately a chi - squared distribution whose number of degrees of freedom are ( number of rows − 1 ) ( number of columns − 1 ) = ( 3 − 1 ) ( 4 − 1 ) = 6 ( displaystyle ( ( \text ( number of rows ) ) - 1 ) ( ( \text ( number of columns ) ) - 1 ) = ( 3 - 1 ) ( 4 - 1 ) = 6 ) If the test statistic is improbably large according to that chi - squared distribution, then one rejects the null hypothesis of independence. A related issue is a test of homogeneity. Suppose that instead of giving every resident of each of the four neighborhoods an equal chance of inclusion in the sample, we decide in advance how many residents of each neighborhood to include. Then each resident has the same chance of being chosen as do all residents of the same neighborhood, but residents of different neighborhoods would have different probabilities of being chosen if the four sample sizes are not proportional to the populations of the four neighborhoods. In such a case, we would be testing `` homogeneity '' rather than `` independence ''. The question is whether the proportions of blue - collar, white - collar, and no - collar workers in the four neighborhoods are the same. However, the test is done in the same way. Applications In cryptanalysis, chi - squared test is used to compare the distribution of plaintext and ( possibly ) decrypted ciphertext. The lowest value of the test means that the decryption was successful with high probability. This method can be generalized for solving modern cryptographic problems. In bioinformatics, chi - squared test is used to compare the distribution of certain property of genes ( e.g., genomic content, mutation rate, interaction network clustering, etc. ) belonging different categories ( e.g., disease genes, essential genes, genes on a certain chromosome etc. ). See also Statistics portal Contingency table Chi - square test nomogram G - test Minimum chi - square estimation Nonparametric statistics The Wald test can be evaluated against a chi - square distribution. References ^ Jump up to : Pearson, Karl ( 1900 ). `` 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 '' ( PDF ). Philosophical Magazine. Series 5. 50 : 157 -- 175. doi : 10.1080 / 14786440009463897. Jump up ^ Pearson, Karl ( 1893 ). `` Contributions to the mathematical theory of evolution ( abstract ) ''. Proceedings of the Royal Society. 54 : 329 -- 333. doi : 10.1098 / rspl. 1893.0079. JSTOR 115538. Jump up ^ Pearson, Karl ( 1895 ). `` Contributions to the mathematical theory of evolution, II : Skew variation in homogeneous material ''. Philosophical Transactions of the Royal Society. 186 : 343 -- 414. Bibcode : 1895RSPTA. 186... 343P. doi : 10.1098 / rsta. 1895.0010. JSTOR 90649. Jump up ^ Pearson, Karl ( 1901 ). `` Mathematical contributions to the theory of evolution, X : Supplement to a memoir on skew variation ''. Philosophical Transactions of the Royal Society A. 197 : 443 -- 459. Bibcode : 1901RSPTA. 197... 443P. doi : 10.1098 / rsta. 1901.0023. JSTOR 90841. Jump up ^ Pearson, Karl ( 1916 ). `` Mathematical contributions to the theory of evolution, XIX : Second supplement to a memoir on skew variation ''. Philosophical Transactions of the Royal Society A. 216 : 429 -- 457. Bibcode : 1916RSPTA. 216... 429P. doi : 10.1098 / rsta. 1916.0009. JSTOR 91092. Jump up ^ Cochran, William G. ( 1952 ). `` The Chi - square Test of Goodness of Fit ''. The Annals of Mathematical Statistics. 23 : 315 -- 345. doi : 10.1214 / aoms / 1177729380. JSTOR 2236678. Jump up ^ Fisher, Ronald A. ( 1922 ). `` On the Interpretation of chi - squared from Contingency Tables, and the Calculation of P ''. Journal of the Royal Statistical Society. 85 : 87 -- 94. doi : 10.2307 / 2340521. JSTOR 2340521. Jump up ^ Fisher, Ronald A. ( 1924 ). `` The Conditions Under Which chi - squared Measures the Discrepancey Between Observation and Hypothesis ''. Journal of the Royal Statistical Society. 87 : 442 -- 450. JSTOR 2341149. Jump up ^ Yates, Frank ( 1934 ). `` Contingency table involving small numbers and the χ test ''. Supplement to the Journal of the Royal Statistical Society. 1 ( 2 ) : 217 -- 235. JSTOR 2983604. Jump up ^ `` Chi - squared Statistic ''. Practical Cryptography. Retrieved 18 February 2015. Jump up ^ `` Using Chi Squared to Crack Codes ''. IB Maths Resources. British International School Phuket. Jump up ^ Ryabko, B. Ya. ; Stognienko, V.S. ; Shokin, Yu. I. ( 2004 ). `` A new test for randomness and its application to some cryptographic problems '' ( PDF ). Journal of Statistical Planning and Inference. 123 : 365 -- 376. doi : 10.1016 / s0378 - 3758 ( 03 ) 00149 - 6. Retrieved 18 February 2015. Jump up ^ Feldman, I. ; Rzhetsky, A. ; Vitkup, D. ( 2008 ). `` Network properties of genes harboring inherited disease mutations ''. PNAS. 105 ( 11 ) : 4323 -- 432. Bibcode : 2008PNAS... 105.4323 F. doi : 10.1073 / pnas. 0701722105. PMC 2393821. Retrieved 29 June 2018. Jump up ^ `` chi - square - tests '' ( PDF ). Retrieved 29 June 2018. Further reading Weisstein, Eric W. `` Chi - Squared Test ''. MathWorld. Corder, G.W. ; Foreman, D.I. ( 2014 ), Nonparametric Statistics : A Step - by - Step Approach, New York : Wiley, ISBN 978 - 1118840313 Greenwood, Cindy ; Nikulin, M.S. ( 1996 ), A guide to chi - squared testing, New York : Wiley, ISBN 0 - 471 - 55779 - X Nikulin, M.S. ( 1973 ), `` Chi - squared test for normality '', Proceedings of the International Vilnius Conference on Probability Theory and Mathematical Statistics, 2, pp. 119 -- 122 Bagdonavicius, V. ; Nikulin, M.S. ( 2011 ), `` Chi - squared goodness - of - fit test for right censored data '', The International Journal of Applied Mathematics and Statistics, pp. 30 -- 50 Statistics Outline Index Descriptive statistics Continuous data Center Mean arithmetic geometric harmonic Median Mode Dispersion Variance Standard deviation Coefficient of variation Percentile Range Interquartile range Shape Central limit theorem Moments Skewness Kurtosis L - moments Count data Index of dispersion Summary tables Grouped data Frequency distribution Contingency table Dependence Pearson product - moment correlation Rank correlation Spearman 's rho Kendall 's tau Partial correlation Scatter plot Graphics Bar chart Biplot Box plot Control chart Correlogram Fan chart Forest plot Histogram Pie chart Q -- Q plot Run chart Scatter plot Stem - and - leaf display Radar chart Data collection Study design Population Statistic Effect size Statistical power Sample size determination Missing data Survey methodology Sampling stratified cluster Standard error Opinion poll Questionnaire Controlled experiments Design control optimal Controlled trial Randomized Random assignment Replication Blocking Interaction Factorial experiment Uncontrolled studies Observational study Natural experiment Quasi-experiment Statistical inference Statistical theory Population Statistic Probability distribution Sampling distribution Order statistic Empirical distribution Density estimation Statistical model L space Parameter location scale shape Parametric family Likelihood ( monotone ) Location -- scale family Exponential family Completeness Sufficiency Statistical functional Bootstrap U V Optimal decision loss function Efficiency Statistical distance divergence Asymptotics Robustness Frequentist inference Point estimation Estimating equations Maximum likelihood Method of moments M - estimator Minimum distance Unbiased estimators Mean - unbiased minimum - variance Rao -- Blackwellization Lehmann -- Scheffé theorem Median unbiased Plug - in Interval estimation Confidence interval Pivot Likelihood interval Prediction interval Tolerance interval Resampling Bootstrap Jackknife Testing hypotheses 1 - & 2 - tails Power Uniformly most powerful test Permutation test Randomization test Multiple comparisons Parametric tests Likelihood - ratio Wald Score Specific tests Z - test ( normal ) Student 's t - test F - test Goodness of fit Chi - squared G - test Kolmogorov -- Smirnov Anderson -- Darling Lilliefors Jarque -- Bera Normality ( Shapiro -- Wilk ) Likelihood - ratio test Model selection Cross validation AIC BIC Rank statistics Sign Sample median Signed rank ( Wilcoxon ) Hodges -- Lehmann estimator Rank sum ( Mann -- Whitney ) Nonparametric anova 1 - way ( Kruskal -- Wallis ) 2 - way ( Friedman ) Ordered alternative ( Jonckheere -- Terpstra ) Bayesian inference Bayesian probability prior posterior Credible interval Bayes factor Bayesian estimator Maximum posterior estimator Correlation Regression analysis Correlation Pearson product - moment Partial correlation Confounding variable Coefficient of determination Regression analysis Errors and residuals Regression model validation Mixed effects models Simultaneous equations models Multivariate adaptive regression splines ( MARS ) Linear regression Simple linear regression Ordinary least squares General linear model Bayesian regression Non-standard predictors Nonlinear regression Nonparametric Semiparametric Isotonic Robust Heteroscedasticity Homoscedasticity Generalized linear model Exponential families Logistic ( Bernoulli ) / Binomial / Poisson regressions Partition of variance Analysis of variance ( ANOVA, anova ) Analysis of covariance Multivariate ANOVA Degrees of freedom Categorical / Multivariate / Time - series / Survival analysis Categorical Cohen 's kappa Contingency table Graphical model Log - linear model McNemar 's test Multivariate Regression Manova Principal components Canonical correlation Discriminant analysis Cluster analysis Classification Structural equation model Factor analysis Multivariate distributions Elliptical distributions Normal Time - series General Decomposition Trend Stationarity Seasonal adjustment Exponential smoothing Cointegration Structural break Granger causality Specific tests Dickey -- Fuller Johansen Q - statistic ( Ljung -- Box ) Durbin -- Watson Breusch -- Godfrey Time domain Autocorrelation ( ACF ) partial ( PACF ) Cross-correlation ( XCF ) ARMA model ARIMA model ( Box -- Jenkins ) Autoregressive conditional heteroskedasticity ( ARCH ) Vector autoregression ( VAR ) Frequency domain Spectral density estimation Fourier analysis Wavelet Whittle likelihood Survival Survival function Kaplan -- Meier estimator ( product limit ) Proportional hazards models Accelerated failure time ( AFT ) model First hitting time Hazard function Nelson -- Aalen estimator Test Log - rank test Applications Biostatistics Bioinformatics Clinical trials / studies Epidemiology Medical statistics Engineering statistics Chemometrics Methods engineering Probabilistic design Process / quality control Reliability System identification Social statistics Actuarial science Census Crime statistics Demography Econometrics National accounts Official statistics Population statistics Psychometrics Spatial statistics Cartography Environmental statistics Geographic information system Geostatistics Kriging Portal Commons WikiProject Retrieved from `` https://en.wikipedia.org/w/index.php?title=Chi-squared_test&oldid=865888367 '' Categories : Statistical tests for contingency tables Nonparametric statistics Hidden categories : Articles lacking in - text citations from November 2014 All articles lacking in - text citations Articles with incomplete citations from January 2013 All articles with incomplete citations Talk Contents Interaction About Wikipedia Dansk Deutsch Ελληνικά Español Euskara فارسی Français Gaeilge Galego 한국어 हिन्दी Italiano עברית Latviešu Magyar Македонски Nederlands 日本 語 Polski Português Русский Simple English Basa Sunda Suomi Türkçe Українська Tiếng Việt 中文 20 more Edit links This page was last edited on 26 October 2018, at 20 : 45 ( UTC ). Text is available under the Creative Commons Attribution - ShareAlike License ; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia ® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization. About Wikipedia

Question: for what purpose can the chi-square test be used
Answer: to evaluate how likely the observations that are made would be, assuming the null hypothesis is true