
Goodness-of-Fit
Table of Contents What is Goodness-Of-Fit? Understanding Goodness-Of-Fit Types of Goodness-Of-Fit Tests Example of a Goodness-of-Fit Test Goodness-of-Fit FAQs The Bottom Line The goodness-of-fit test is a statistical hypothesis test to see how well sample data fit a distribution from a population with a normal distribution. The chi-square test is used exclusively for data put into classes (bins), and it requires a sufficient sample size to produce accurate results. Goodness-of-fit tests are commonly used to test for the normality of residuals or to determine whether two samples are gathered from identical distributions. χ 2 \= ∑ i \= 1 k ( O i − E i ) 2 / E i \\chi^2=\\sum\\limits^k\_{i=1}(O\_i-E\_i)^2/E\_i χ2\=i\=1∑k(Oi−Ei)2/Ei D \= max 1 ≤ i ≤ N ( F ( Y i ) − i − 1 N , i N − F ( Y i ) ) D=\\max\\limits\_{1\\leq i\\leq N}\\bigg(F(Y\_i)-\\frac{i-1}{N},\\frac{i}{N}-F(Y\_i)\\bigg) D\=1≤i≤Nmax(F(Yi)−Ni−1,Ni−F(Yi)) Named after Russian mathematicians Andrey Kolmogorov and Nikolai Smirnov, the Kolmogorov-Smirnov test (also known as the K-S test) is a statistical method that determines whether a sample is from a specific distribution within a population. The chi-square test whether relationships exist between categorical variables and whether the sample represents the whole. It estimates how closely the observed data mirrors the expected data, or how well they fit.

More in Economy
What is Goodness-Of-Fit?
The goodness-of-fit test is a statistical hypothesis test to see how well sample data fit a distribution from a population with a normal distribution. Put differently, this test shows if your sample data represents the data you would expect to find in the actual population or if it is somehow skewed. Goodness-of-fit establishes the discrepancy between the observed values and those that would be expected of the model in a normal distribution case.
There are multiple methods for determining goodness-of-fit. Some of the most popular methods used in statistics include the chi-square, the Kolmogorov-Smirnov test, the Anderson-Darling test, and the Shipiro-Wilk test.





Understanding Goodness-Of-Fit
Goodness-of-fit tests are statistical methods often used to make inferences about observed values. These tests determine how related actual values are to the predicted values in a model, and when used in decision-making, goodness-of-fit tests can help predict future trends and patterns.
The most common goodness-of-fit test is the chi-square test, typically used for discrete distributions. The chi-square test is used exclusively for data put into classes (bins), and it requires a sufficient sample size to produce accurate results.
Goodness-of-fit tests are commonly used to test for the normality of residuals or to determine whether two samples are gathered from identical distributions.
Types of Goodness-Of-Fit Tests
Chi-Square Test
χ 2 = ∑ i = 1 k ( O i − E i ) 2 / E i \chi^2=\sum\limits^k_{i=1}(O_i-E_i)^2/E_i χ2=i=1∑k(Oi−Ei)2/Ei
The chi-square test, also known as the chi-square test for independence, is an inferential statistics method that tests the validity of a claim made about a population based on a random sample. However, it does not indicate the type or intensity of the relationship. For instance, it does not conclude whether the relationship is positive or negative.
To qualify for the chi-square test for independence, variables must be mutually exclusive.
To calculate a chi-square goodness-of-fit, it is necessary to set the desired alpha level of significance (e.g., if your confidence level is 95% or .95, then the alpha is .05), identify the categorical variables to test, and define hypothesis statements about the relationships between them. The null hypothesis asserts that no relationship exists between variables, and the alternative hypothesis assumes that a relationship exists. The frequency of the observed values is measured and subsequently used with the expected values and the degrees of freedom to calculate chi-square. If the result is lower than alpha, the null hypothesis is invalid, indicating a relationship exists between the variables.
Kolmogorov-Smirnov Test
D = max 1 ≤ i ≤ N ( F ( Y i ) − i − 1 N , i N − F ( Y i ) ) D=\max\limits_{1\leq i\leq N}\bigg(F(Y_i)-\frac{i-1}{N},\frac{i}{N}-F(Y_i)\bigg) D=1≤i≤Nmax(F(Yi)−Ni−1,Ni−F(Yi))
Named after Russian mathematicians Andrey Kolmogorov and Nikolai Smirnov, the Kolmogorov-Smirnov test (also known as the K-S test) is a statistical method that determines whether a sample is from a specific distribution within a population. The Kolmogorov-Smirnov test — recommended for large samples (e.g., over 2000) — is non-parametric, meaning it does not rely on any distribution to be valid. It focuses The goal is to prove the null hypothesis, which is the sample of the normal distribution.
Contrary to the chi-square test, the Kolmogorov-Smirnov test applies to continuous distributions. Like chi-square, it uses a null and alternative hypothesis and an alpha level of significance. Null indicates that the data follow a specific distribution within the population, and alternative indicates that the data did not follow a specific distribution within the population. The alpha is used to determine the critical value used in the test.
The calculated test statistic, often denoted as D, determines whether the null hypothesis is accepted or rejected. If D is greater than the critical value at alpha, the null hypothesis is rejected. If D is less than the critical value, the null hypothesis is accepted, indicating
Shipiro-Wilk Test
W = ( ∑ i = 1 n a i ( x ( i ) ) 2 ∑ i = 1 n ( x i − x ˉ ) 2 , W=\frac{\big(\sum^n_{i=1}a_i(x_{(i)}\big)^2}{\sum^n_{i=1}(x_i-\bar{x})^2}, W=∑i=1n(xi−xˉ)2(∑i=1nai(x(i))2,
The Shipiro-Wilk test determines if a sample follows a normal distribution. Using a sample with one variable of continuous data, the Shipiro-Wilk test only checks for normality. It is recommended for small sample sizes up to 2000. Alike the others, it uses alpha and forms two hypotheses: null and alternative. The null hypothesis states that the sample comes from the normal distribution, whereas the alternative hypothesis states that the sample does not come from the normal distribution.
The Shipiro-Wilk test uses a probability plot called the QQ Plot. This scatterplot visually displays two sets of quantiles on the y-axis, arranged from smallest to largest. If each quantile came from the same distribution, the scatterplot will display a linear series of plots. The Shipiro-Wilk test uses the QQ Plot to estimate the variance. Using QQ Plot variance along with the estimated variance of the population, one can determine if the sample belongs to a normal distribution. If the quotient of both variances equal or are close to 1, then the null hypothesis can be accepted. If considerably lower than 1, it can be rejected.
Example of a Goodness-of-Fit Test
For example, a small community gym might be operating under the assumption that it has its highest attendance on Mondays, Tuesdays and Saturdays, average attendance on Wednesdays, and Thursdays, and lowest attendance on Fridays and Sundays. Based on these assumptions, the gym employs a certain number of staff members each day to check in members, clean facilities, offer training services, and teach classes.
However, the gym is not performing well financially and the owner wants to know if these attendance assumptions and staffing levels are correct. The owner decides to count the number of gym attendees each day for six weeks. He can then compare the gym's assumed attendance with its observed attendance using a chi-square goodness-of-fit test for example. With the new data, he can determine how to best manage the gym and improve profitability.
Goodness-of-Fit FAQs
What Does Goodness-of-Fit Mean?
Goodness-of-Fit is a statistical hypothesis test used to see how closely observed data mirrors expected data. Goodness-of-Fit tests can help determine if a sample follows a normal distribution, if categorical variables are related, or if random samples are from the same distribution.
Why Is Goodness-of-Fit Important?
Goodness-of-Fit tests help determine if observed data aligns with what is expected. Decisions can be made based on the outcome of the hypothesis test conducted. For example, a retailer wants to know what product offering appeals to young people. The retailer surveys a random sample of old and young people to identify which product is preferred. Using chi-square, they identify that, with 95% confidence, a relationship exists between product A and young people. Based on these results, it could be determined that this sample represents the population of young adults. Retail marketers can use this to reform their campaigns.
What Is Goodness-of-Fit in the Chi-Square Test?
The chi-square test whether relationships exist between categorical variables and whether the sample represents the whole. It estimates how closely the observed data mirrors the expected data, or how well they fit.
How Do You Do the Goodness-of-Fit Test?
The Goodness-of-FIt test consists of different testing methods. The goal of the test will help determine which method to use. For example, if the goal is to test normality on a relatively small sample, the Shipiro-Wilk test may be suitable. If wanting to determine whether a sample came from a specific distribution within a population, the Kolmogorov-Smirnov test will be used. Each test uses its own unique formula. However, they have commonalities, such as a null hypothesis and level of significance.
The Bottom Line
Goodness-of-fit tests determine how well sample data fit what is expected of a population. From the sample data, an observed value is gathered and compared to the calculated expected value using a discrepancy measure. There are different goodness-of-fit hypothesis tests available depending on what outcome you're seeking.
Choosing the right goodness-of-fit test largely depends on what you want to know about a sample and how large the sample is. For example, if wanting to know if observed values for categorical data match the expected values for categorical data, use chi-square. If wanting to know if a small sample follows a normal distribution, the Shipiro-Wilk test might be advantageous. There are many tests available to determine goodness-of-fit.
Related terms:
Chi-Square (χ2) Statistic
A chi-square (χ2) statistic is a test that measures how expectations compare to actual observed data (or model results). read more
Degrees of Freedom
Degrees of Freedom refers to the maximum number of logically independent values, which are values that have the freedom to vary, in the data sample. read more
Economics : Overview, Types, & Indicators
Economics is a branch of social science focused on the production, distribution, and consumption of goods and services. read more
Hypothesis Testing
Hypothesis testing is the process that an analyst uses to test a statistical hypothesis. The methodology employed by the analyst depends on the nature of the data used and the reason for the analysis. read more
Inflation
Inflation is a decrease in the purchasing power of money, reflected in a general increase in the prices of goods and services in an economy. read more
Normal Distribution
Normal distribution is a continuous probability distribution wherein values lie in a symmetrical fashion mostly situated around the mean. read more
Null Hypothesis : Testing & Examples
A null hypothesis is a type of hypothesis used in statistics that proposes that no statistical significance exists in a set of given observations. read more
Runs Test
Traders use a runs test to determine the randomness of data by revealing any variables that might affect data patterns, such as a stock's price movement. read more