Skip to main content
Advanced Statistical Methods

Chi-Square Applications: Tests for Independence and Goodness of Fit

Published: 2026-08-11
Level: postgraduate
Audience: Postgraduate students in Advanced Statistical Methods

Prerequisite Knowledge

This lecture builds on the following concepts from earlier lectures. If any feel unfamiliar, review the linked notes before proceeding.

Previously Covered in This Subject

  • The chi-square distribution and its degrees of freedom — covered in Lecture 5 (Inferences on the Population Variance)
  • The chi-square test for equality of population proportions — covered in Lecture 5 (Inferences on the Population Variance)
  • The standard normal distribution and Z-scores — covered in Lecture 2 (Normal Distribution and Statistical Inference)
  • Hypothesis testing: null and alternative hypotheses, and the p-value approach — covered in Lectures 3 and 4 (Statistical Inference and Hypothesis Testing, Hypothesis Testing Procedures)
  • The normal distribution and the empirical rule — covered in Lecture 2 (Normal Distribution and Statistical Inference)

This session puts the chi-square distribution to work on two classic inference problems: deciding whether two categorical variables are independent, and deciding whether a sample could have come from a specific distribution. Both tests use the same chi-square statistic, and both expect you to carry out the full calculation yourself — these are the sort of problems you are likely to be asked to compute in the exam. The session works through two complete textbook examples, one for each test, and closes with a short preview of the next chapter: the design of experiments and the analysis of variance.

6.1 Chi-square Test for Independence

6.1.1 Recap: Where the Chi-square Distribution Sits

Before we look at today's problems, it helps to remember where we are. Apart from the Z distribution and the T distribution, the chi-square distribution is the third fundamental distribution our inference has been built on. Last session covered what the chi-square distribution is and why it matters for making inferences about variances — a key idea, since variance appears everywhere in statistics. We also saw the chi-square distribution at work comparing multiple proportions, where we asked whether several population proportions could all be equal. The chi-square statistic turns out to be the common engine behind all of these: it measures how far observed counts sit from the counts we would expect under a null hypothesis.

Hook: Two categorical variables sit in a table — a beverage preference and the customer's gender, say. Are they independent of each other, or is one tied to the other? The chi-square distribution gives us a test that answers this question from a single random sample, and the instructor flagged this application as very, very required — the kind of thing you may expect to calculate from the exam point of view.

Today builds two more applications on top of that foundation. The first application is the one this section covers: judging whether two categorical variables are independent. A categorical variable is a qualitative variable — the data is collected in terms of categories rather than numbers (male/female, light/regular/dark, yes/no). If your data contains two such categorical variables, the chi-square distribution helps you answer one basic question: are these two variables independent of each other, or is there some dependency among them?

6.1.2 The Setting: Two Categorical Variables

The whole picture works like this. We take one random sample from a population and record, for every person (or item) in the sample, the values of the two categorical variables. We arrange the data in a table: the categories of one variable become the rows, and the categories of the other variable become the columns. The table has rows and columns, and every cell holds a count — the number of sample members that fell in that combination of categories. Those counts are the observed frequencies, written , where indexes the row (so ) and indexes the column (so ). Along the edges we keep the row totals, the column totals, and the grand total of all observations, usually written . A table like this is called a contingency table, because it shows how the two variables sit together.

Purpose of the test: The test for independence decides whether the row variable and the column variable are related. If they are independent, knowing a person's category on one variable tells you nothing about their category on the other. If they are not independent, an association exists — the pattern of one variable shifts with the other — and that pattern is exactly what a company or researcher wants to detect.

Inputs and outputs: The input is one contingency table of observed counts, built from one random sample of size , together with a stated level of significance . The output is a decision: either the evidence is strong enough to say the variables are not independent, or it is not.

What the arithmetic needs: three numbers per cell — the observed count , the expected count computed under independence, and their squared gap — plus the table's degrees of freedom.

The test we run on this table is simply called a test for independence, and the textbook gives the whole procedure on page 525. The worked details that follow use that treatment closely.

6.1.3 The Hypotheses of the Independence Test

As with any hypothesis test, the first step is to state the two logical statements — the null and the alternative — before doing any calculation. This is a fundamental habit: whenever a problem asks for a test, you should write down and explicitly. For the test for independence, the standard pair of statements is:

You can write exactly these statements in the exam whenever you encounter a test for independence. The logic behind putting independence in the null is worth understanding: the main motto here is to gather evidence against the null. The moment we reject , we are automatically saying that a dependency exists — the variables are not independent, so there is some association between them. Claiming an association is the stronger claim, and strong claims need strong evidence; that is why the association lives in the alternative while independence sits in the null as the default we assume until proven otherwise. Think of it as the working assumption of the test: the data must convince us to give it up.

6.1.4 Expected Frequencies and the Test Statistic

Once the hypotheses are stated, the procedure runs in a small number of steps. First, assume the null hypothesis is true. Under independence, we compute for every cell the expected frequency — the count we would expect to see in that cell if the two variables were unrelated. The formula is a very simple one:

which is the same formula used in the previous method we studied. In words: to get the expected frequency for a cell, take its row total, multiply by its column total, and divide by the grand total. The instructor's verbal description of the rule was: "if I want to find out the expected frequency for this particular cell... it should be row total into each column total divided by grand total."

Why does this formula make sense? If the two variables are independent, the chance of landing in row and column at the same time is the product of the two separate chances:

We estimate the two separate chances from the sample as and . The expected count in the cell is the sample size times that probability:

so the row-total-times-column-total-over-grand-total rule is really the independence probability rule, converted into counts.

Second, compute the test statistic. The chi-square test statistic is a double summation over all cells of the squared gap between what we observed and what we expected, relative to the expectation:

The verbal description that goes with it: "the chi-square test statistic is double summation minus whole square by ," where is given by the data and is computed from the formula above. Three design choices in this formula matter. Squaring the gap makes every contribution positive, so cells where we saw too many counts and cells where we saw too few both add to the total instead of cancelling. Dividing by weights each cell relative to its size: a deviation of 3 matters more in a cell expecting 5 than in a cell expecting 50. And the whole statistic is a sum of non-negative terms, so always — it can only grow when the observed counts drift away from the expected ones. If the variables really are independent, the observed counts sit close to the expected ones and the statistic stays small; if they are not, the gaps grow and the statistic grows with them.

There is a condition attached to this formula, and it is a very, very essential condition: each expected frequency must be 5 or more ( for every cell). If some cell comes out under 5, we cannot use the statistic as it stands; the remedy is to merge cells — combine two neighboring categories into one so the combined expected frequency climbs to 5 or above — and then recalculate. We return to this in the Q&A section, because there is a subtlety about degrees of freedom when merging happens.

Third, the degrees of freedom. For the test for independence they are

— "rows minus 1 into columns minus 1." The intuition: once the row totals and column totals are fixed, you are free to fill only of the cells by hand; every remaining cell is forced by the totals, so the chi-square distribution describing the statistic has exactly that many degrees of freedom. For the worked example that follows, that is .

Scope and assumptions: the formula and the test statistic are valid only when a few conditions hold. The sample must be a random sample, with every observation counted in exactly one cell. The expected frequency in every cell must be at least 5 — when this fails, the chi-square distribution no longer describes the statistic well, and the test becomes unreliable. The categories of each variable must be mutually exclusive (a drinker cannot be both male and female) and cover all possibilities. If any of these fail, the p-value you read is not trustworthy.

One more habit from this session: instead of comparing the statistic against a critical value from a table, we use the p-value approach for the rejection rule. The instructor put it directly: "I am not interested in talking about this critical value — we will discuss the rejection rule approach with the help of the basic p-values." If the p-value comes out less than the level of significance , we reject the null; if it is greater, we fail to reject. The arithmetic itself is light: for an table you compute cell contributions, each a handful of calculator steps, so the whole test takes minutes by hand and an instant in software — the real cost is collecting a random sample large enough that every expected count reaches 5.

6.1.5 Worked Example: Beer Preference and Gender

Worked example — beer preference and gender. A beer industry association conducts a survey to determine the preferences of beer drinkers for light, regular, and dark beers. A sample of 200 beer drinkers is taken, and each person in the sample is asked to indicate a preference for one of the three types of beer. At the end of the survey, each respondent also provides their gender. The question posed is: is there an association between beer type and gender — that is, is beer preference independent of gender?

Step 1 — the observed table. The two categorical variables are gender (male, female) and beer preference (light, regular, dark). The beer-type variable forms the three rows and the gender variable forms the two columns, giving an by table. The observed frequencies collected from the 200 drinkers are:

Cell (row, column) Observed
Light, male 51
Light, female 39
Regular, male 56
Regular, female 21
Dark, male 25
Dark, female 8

Step 2 — the totals. The light row totals ; the regular row totals ; the dark row totals . The male column totals , and the female column totals . The grand total is 200.

Step 3 — the expected frequencies. Assume the null hypothesis of independence is true and compute the expected frequency for every cell with . The first cell was shown in full: for the light–male cell (observed 51), the row total is 90, the column total is 132, and the grand total is 200, so

The instructor asked everyone to redo this on their own and convince themselves the calculation is right. The same calculation for every cell gives:

Step 4 — the contributions. For each cell, subtract the expected from the observed, square the result, and divide by the expected:

The full table, which you can reproduce on your calculator, is:

Cell (row, column) Observed Expected
Light, male 51 59.40 −8.40 70.56 1.19
Light, female 39 30.60 8.40 70.56 2.31
Regular, male 56 50.82 5.18 26.83 0.53
Regular, female 21 26.18 −5.18 26.83 1.02
Dark, male 25 21.78 3.22 10.37 0.48
Dark, female 8 11.22 −3.22 10.37 0.92
Total 200 200 0 6.45

Step 5 — the test statistic. Sum all six contributions:

The chi-square value for this problem is 6.45, with degrees of freedom. Sense-check: the largest gaps sit in the light-beer cells (), and their contributions (1.19 and 2.31) dominate the total — exactly what you would expect if light-beer preference differs most between men and women. Also notice the column sums to 0; that is a built-in check on your arithmetic — if your differences do not cancel, a calculation error crept in somewhere.

Two practical notes from the class. First, if you are comfortable doing the work in a tabulated form like this, that is fine — presenting the calculation as a table is perfectly acceptable. Second, many statistical calculators let you enter the raw data and read off the mean and variance directly, which is handy for checking your hand calculation.

A bar chart of the two genders side by side tells the same story the test will confirm. Put beer preference (light, regular, dark) on the horizontal axis and the proportion within each gender on the vertical axis, running from 0 to about 0.7. Women's highest bar is light beer at about 57%, while men's highest bar is regular beer at about 42%; men also prefer dark beer more often than women. The two sets of bars are visibly uneven — that visual gap is what the chi-square statistic will put on a number scale.

6.1.6 Conclusion: p-value and the Decision

With and , we go to the chi-square table with the upper-tail area in mind. The question put to the class was: roughly what might the p-value be, and what is your conclusion — is p greater than alpha or less than alpha? The chi-square table for 2 degrees of freedom reads: an upper-tail area of 0.10 corresponds to the value 4.605, 0.05 corresponds to 5.991, 0.025 corresponds to 7.378, 0.01 corresponds to 9.210, and 0.005 corresponds to 10.597. Our statistic 6.45 sits between 5.991 and 7.378, so the p-value for this example lies somewhere between 0.05 and 0.025, which already indicates that p is strictly less than the default level of significance. The rule of thumb: if the level of significance is not given in a problem, consider it at 5% () and compare with that. Since 6.45 exceeds the 5% table value 5.991, the p-value is certainly less than 0.05, and software confirms the exact value .

Common traps in the independence test:

  • Forgetting to square the difference — adding raw terms gives zero and proves nothing; the test runs on squared gaps.
  • Dividing by the observed frequency instead of the expected one — the divisor is always .
  • Using the wrong degrees of freedom — it is , not or .
  • Skipping the check — the condition must hold for every cell before the statistic is valid.
  • Ending at "reject " — the conclusion must be said in words, not just the verdict.

So we reject the null hypothesis. In the language of the problem: there is a dependency between the two categorical variables — beer preference is not independent of gender. If you want to write the conclusion more precisely than "reject the null," you can write it literally: "They are not independent — beer preference depends on gender." Rejecting the null is one aspect; saying what it means in words is the part that shows real understanding, and it is a skill that gets evaluated later in the course (see the Exam Guidance Summary).

Recap + bridge: the test for independence compares observed counts in a two-way table with the counts expected under independence, and the chi-square statistic turns the gaps into one number with a p-value attached. Here that number was 6.45, the p-value fell between 0.05 and 0.025, and the verdict was a dependency between beer preference and gender. The second application of the same statistic — the goodness-of-fit test — comes next; the formula does not change, but the way the expected frequencies are built changes completely.

6.1.7 Student Questions and Answers

The class raised five questions about this example. The first two were about the arithmetic, the next about the logic of the hypotheses, and the last two about the decision rule and its wording.

Q: What is the test statistic formula you are using here, and how do you calculate the expected frequencies?

A: The test statistic is this expression: the double summation over all cells of minus whole square, divided by . For the expected frequency of any cell, multiply its row total by its column total and divide by the grand total. Take the cell with observed frequency 39 (light, female): its row total is 90, its column total is 68, and the grand total is 200, so . Take the cell with observed frequency 8 (dark, female): its expected frequency is . Likewise, for all six observed frequencies you compute the respective expected frequencies and then feed them into the chi-square formula.

The expected-frequency arithmetic raises an immediate worry, and the next question voiced it directly.

Q: What do we do if an expected frequency turns out to be less than 5?

A: The condition for using the chi-square test statistic is that each expected frequency must be at least 5. If a cell falls below 5 — say its expected frequency comes out to be 3 — to make that cell larger than 5, the only option is clubbing — merging — the two cells: rather than treating them as two separate cells, treat them as one, so the combined expected frequency climbs above 5. And whatever merging you did on the expected frequencies, you must do the same on the observed frequencies — if you club two expected cells, club the two corresponding observed cells as well. Then be careful about the degrees of freedom: when you merge cells, the degrees of freedom get reduced, so you must adjust them accordingly before deciding. The textbook examples are purposefully chosen so that all expected frequencies stay at or above 5, but when the scenario does arise, clubbing is the way to force the expected values above 5. The next session will take up one such example to show exactly how merging works and how the degrees of freedom drop.

With the mechanics settled, the discussion turned to the logic of putting independence in the null hypothesis rather than the association.

Q: Why do we put independence in the null hypothesis rather than the association? To establish any association between two qualitative variables, we need evidence — like making a person innocent first and then proving he is a criminal, which requires establishing a few facts. Assuming both variables are independent feels harmless, while claiming an association needs much more supportive material.

A: Your reading is right, and that is exactly the logic followed here. Assuming the two variables are independent does no harm, whereas establishing that an association exists needs much more support, so whatever needs to be detected or supported is established in the alternative. At the same time, your own logical statements are not wrong — it is not necessary that you follow my rules exactly. Whatever statements you establish, you try to prove them, and you must give the conclusion. Majority of the time — 90% of statements — will follow the guideline I mentioned, but it depends on the management context, the pharmacy context, the biological sense; here and there you can write the logical statements your own way.

The decision rule itself drew one more question — what to conclude when p is less than alpha.

Q: If p is less than alpha, what is our conclusion?

A: If p is less than alpha, we reject the null hypothesis. The moment we reject the null, we are accepting the alternative. Here the null said beer preference is independent of gender; rejecting it means the beer preference is not independent of gender — there is a dependency between them. So beyond writing "reject the null," you can add the plain-language reading: "they are not independent — depends on gender." This is also the kind of sentence the later assignment will check: there is a component in the assignment that evaluates how best you can use your writing skills and how you can interpret the things, and this example is simple enough to practice exactly that.

One closing question asked to see the p-value approach for this example end to end.

Q: For this example, can you comment on the p-value approach — roughly what is the p-value and what do we conclude?

A: The p-value lies somewhere between 0.05 and 0.025, so it is strictly less than alpha = 0.05. Since the level of significance defaults to 5% when not given, we compare against 0.05 and reject the null hypothesis — there is a dependency between the two categorical variables concerned.

6.1.8 Exam Notes

Exam note: the two applications in this session — the test for independence and the goodness-of-fit test — are very, very required, and you may expect to carry out the calculation for these in the exam. The exam is open book, so there is no need to carry any extra tables — you can check the table values provided and write your comment. Write down and for every problem; the standard independence statements ("the two categorical variables are independent / not independent") can be written as-is. When the level of significance is not given, use 5% by default.

The rest of the exam guidance for this concept, in summary form:

  • Present the calculation tabulated if you are comfortable with that format — a clean table is a perfectly acceptable presentation and easier to check.
  • Remember the condition for every cell, and that merging cells changes the degrees of freedom.
  • Use the p-value approach with the rejection rule reject , fail to reject.
  • End every problem by translating the verdict into words — "they are not independent — beer preference depends on gender" — because the writing and interpretation are part of what gets evaluated.

6.2 Chi-square Test for Goodness of Fit

6.2.1 The Idea: Does the Sample Come from a Given Distribution?

The second application of the chi-square distribution is the goodness-of-fit test. Its purpose is to determine whether a population is being sampled from a specific distribution. We come across this question all the time: is this data coming from a binomial distribution? Was this sample drawn from a Poisson distribution? Does this random sample come from a normal distribution or not? To validate whether a given sample comes from a particular distribution, we again make use of the same chi-square formula — the same statistic as in the independence test. The name says it in one line: the test asks how good the fit is between the shape of the sample data and the shape of the hypothesized distribution. If the fit is good, the sample could easily have come from that distribution; if the fit is poor, the observed data and the hypothesized distribution do not match.

Listen carefully: the goodness-of-fit calculations have tricks in between because the observed and expected frequencies are computed differently than in the independence test. In the independence test both frequency columns came from a given table of counts. Here the observed frequencies come from tallying raw data into bands, and the expected frequencies come from the probability structure of the hypothesized distribution. The instructor's recommendation: go through this entire problem carefully, because it is a very interesting application of the chi-square test for goodness of fit, and it is a textbook worked example.

6.2.2 The ChemLine Example: Hypotheses

The example is from the textbook: employee aptitude test scores for 50 randomly chosen applicants at ChemLine, a company that hires about 400 new employees annually for its four plants located throughout the United States. Define as the test score of a randomly chosen applicant — is our random variable. The personnel director asks whether a normal distribution applies to the population of test scores. If such a distribution can be used, it would be helpful in evaluating specific test scores: scores in the upper 20% or lower 40% of the population could be identified quickly, without sorting through all the individual scores.

Why this matters — the bell-curve grading picture. Before the mechanics, think about why this matters in practice. If an entire class or population follows an empirical (bell-shaped) distribution, a usual grading practice applies: without any doubt, 10% of the total students should get A grades, 10% should get E grades, then 20, 20, and so on, filling the middle bands the same way. Companies, when giving hikes or awards, may also lean on the Gaussian distribution — if someone is extremely talented, they will be awarded. For all these settings, the ultimate motto is the same: justify whether the given sample came from the normal distribution or not. Once that is settled, the bell curve itself becomes the ruler you use to grade, award, or screen people.

The null and alternative follow the pattern we used before. Under , the population test scores follow a normal distribution with mean and standard deviation . Under , the population test scores do not follow a normal distribution — and if they do not follow a normal, we do not know what they follow, which is a complicated statement, and that is exactly why it sits in the alternative:

As usual, we should visualize what the null is claiming: if the test scores are normal, the entire area under the distribution is spread over the test-score range in the familiar bell shape. Draw the bell curve with test score on the horizontal axis and the probability density on the vertical axis; the curve peaks at the mean, and its spread is set by the standard deviation. The null says the 50 sample scores are just draws from that single smooth bell.

6.2.3 Estimating the Parameters from the Sample

Before any further analysis, we develop estimates of the mean and standard deviation of the normal distribution, because at the population level we do not know and . This is the theory of estimation at work — the very fundamental idea of inference: we do not know the population mean, but we hold a random sample in our hands, so we work at the sample level and then generalize to the population. If the population mean is unknown, the best replacement is the sample mean; wherever appears we use the sample variance, and wherever appears we use the sample standard deviation:

The two estimates. For this example, the sample mean is the average of all the test scores — 71 plus 66 and so on up to 84 — divided by 50. Adding all 50 scores gives 3421, so:

The sample variance uses the squared deviations of the scores from this mean, summed and divided by :

and the sample standard deviation is its square root:

These values can be checked against the textbook, and statistical calculators can compute them straight away once the data is entered.

With these estimates, the null hypothesis can be restated in concrete numbers: the population of test scores has a normal distribution with mean 68.42 and standard deviation 10.41. So under the null, . Remember: for a goodness-of-fit problem you explicitly calculate and , or if they are supplied you just use those given observations directly.

6.2.4 Building the Intervals with the Z-table

Because the normal distribution is a continuous probability distribution, we must use a different procedure for finding the observed and expected frequencies than we did with the categorical table. We hold 50 test scores; to get the observed and expected frequencies we follow two points.

First, to find the observed frequencies, we divide the entire data into different categories — call them intervals — each with a lower bound and an upper bound. The second point is the rule of thumb that controls how many intervals we can make: the expected frequency in each category or interval must be at least 5. With 50 observations, how many intervals should we divide the data into? The answer the class gave: 10. Very good — with 50 observations and 10 equal intervals, each interval holds an expected frequency of 5, which maintains the condition.

The area under the normal curve tells us the probabilities: the whole area is 1, and dividing it into 10 equal parts means each interval carries probability . Cumulatively, the areas build up 0.1, 0.2, 0.3, and so on, until the whole interval is 1. These are the probabilities we use to find the cutoff points between intervals.

Since follows a normal distribution, we can standardize it using the relation between and the standard normal variable :

and when and are unknown, we replace them with the estimates from the sample:

Worked example — the interval cutoffs. To find the first cutoff, we ask: what is the lowest 10% of the test scores? In terms of probability, the bottom 10% has probability 0.1, and the corresponding Z value from the normal tables is (the class confirmed this reading of the tables). Now we solve for the test-score cutoff:

So the first class interval runs from up to 55.10 — everything "less than 55.10." For the second cutoff we ask for the lowest 20% of test scores; the standard normal table gives , and

So the second interval runs from 55.10 to 59.68. Working through the table the same way for the lowest 30%, 40%, and so on, gives the complete list of cutoffs:

Percentage Z value Test score cutoff
Lowest 10% −1.28 68.42 − 1.28(10.41) = 55.10
Lowest 20% −0.84 68.42 − 0.84(10.41) = 59.68
Lowest 30% −0.52 68.42 − 0.52(10.41) = 63.01
Lowest 40% −0.25 68.42 − 0.25(10.41) = 65.82
Lowest 50% 0.00 68.42 + 0(10.41) = 68.42
Lowest 60% +0.25 68.42 + 0.25(10.41) = 71.02
Lowest 70% +0.52 68.42 + 0.52(10.41) = 73.83
Lowest 80% +0.84 68.42 + 0.84(10.41) = 77.16
Lowest 90% +1.28 68.42 + 1.28(10.41) = 81.74

Sense-check: the cutoffs climb evenly around the mean — 55.10 and 59.68 sit well below 68.42, while 77.16 and 81.74 sit the same distance above, mirroring the symmetry of the bell curve. Because the table is symmetric, the z values flip sign as the percentage passes 50%.

This is exactly how the interval bounds in the worked problem (55.10, 59.68, and the rest) are found. On the bell curve, draw vertical lines at each of these cutoffs; they slice the area under the curve into ten equal strips, each holding probability 0.1.

6.2.5 Observed and Expected Frequencies

With the intervals fixed, the two frequency columns are filled in different ways. The observed frequencies come from counting: tally how many of the 50 test scores actually fall inside each interval. The expected frequencies come from the null hypothesis: if the scores really are normal with mean 68.42 and standard deviation 10.41, then each of the 10 intervals should hold an expected frequency of — the sample size times the interval probability. Doing the tally for the ChemLine data gives:

Test score interval Observed frequency Expected frequency
less than 55.10 5 5
55.10 to 59.68 5 5
59.68 to 63.01 9 5
63.01 to 65.82 6 5
65.82 to 68.42 2 5
68.42 to 71.02 5 5
71.02 to 73.83 2 5
73.83 to 77.16 5 5
77.16 to 81.74 5 5
81.74 and over 6 5
Total 50 50

The expected column is uniform — exactly 5 in every row — because the intervals were designed to be equal-probability. The observed column shows where the real data bunches: 9 scores landed between 59.68 and 63.01 (more than the 5 the normal would predict), while only 2 scores landed in each of the bands 65.82–68.42 and 71.02–73.83 (fewer than predicted). Those bumps and dips are the "misfit" the chi-square statistic will measure.

The comparison with the independence test is worth making explicit:

Test for independence Goodness-of-fit test
Data layout Contingency table, rows by columns Raw data tallied into intervals
Observed frequencies Read from the table, Counted from the raw data,
Expected frequencies , the sample size times the interval probability
Test statistic Same double summation over all cells Same chi-square formula over the intervals

When to pick which: if your data is two categorical variables already summarized in a table, use the independence test; if your data is one set of raw values and you want to check its distribution family, use goodness of fit.

6.2.6 The Test Statistic, Degrees of Freedom, and p-value

The test statistic is the same chi-square expression as before:

with the sum taken over the intervals. For the ChemLine data, the cell-by-cell computation is:

Test score interval Observed Expected
less than 55.10 5 5 0 0 0.0
55.10 to 59.68 5 5 0 0 0.0
59.68 to 63.01 9 5 4 16 3.2
63.01 to 65.82 6 5 1 1 0.2
65.82 to 68.42 2 5 −3 9 1.8
68.42 to 71.02 5 5 0 0 0.0
71.02 to 73.83 2 5 −3 9 1.8
73.83 to 77.16 5 5 0 0 0.0
77.16 to 81.74 5 5 0 0 0.0
81.74 and over 6 5 1 1 0.2
Total 50 50 0 7.2

So the computed value of the test statistic is . The only nonzero contributions come from the intervals where the observed count actually differed from 5 — the two overcrowded bands (3.2 and 0.2 from the +4 and +1 surplus) and the two undercrowded bands (1.8 and 1.8 from the two −3 gaps) — which is the whole logic of the statistic in miniature: no difference, no contribution.

The degrees of freedom, however, follow a different rule. For the independence test it was ; for the goodness-of-fit test it is

where stands for the number of intervals or categories — here — and stands for the number of parameters of the distribution estimated from the sample. The distribution here is the normal distribution, whose parameters are and ; both were unknown, and we estimated both from the sample observations (that is what we did with and ), so . This gives

This convention is the one people generally follow whenever a goodness-of-fit problem comes into the picture. Why subtract ? Because each estimated parameter eats one degree of freedom: the sample mean and sample standard deviation were not specified by the theory, they were fitted to the data, so the test must be less strict — and drops by one for each.

Scope: the rule applies whenever parameters are estimated from the same sample that is being tested. If the mean and standard deviation had been given by theory instead of estimated, would be 0 and the rule would reduce to . Forgetting to subtract is the most common way to pick the wrong row of the chi-square table in a goodness-of-fit problem.

Now for the p-value. Consider a portion of the chi-square table at 7 degrees of freedom: the value 2.833 has an area to its right of 0.90, and the value 12.017 has an area to its right of 0.10. Our statistic 7.2 lies somewhere between 2.833 and 12.017, so the p-value — the area to the right of the statistic — lies between 0.1 and 0.9, and by mere inspection of the diagram it is certainly greater than 0.1. There is no doubt: the p-value is greater than alpha, where alpha is 0.1 as given in the problem. From software, the exact p-value comes out to about 0.4084 — a value we cannot read from the tables, but we do not need to: writing "it lies between 0.1 and 0.9," or "p is greater than 0.1," or "p is less than 0.9" is all acceptable, as long as you can anticipate where the p-value falls. The decision rule is the same good old story as for the Z test, the T test, and the chi-square distribution alike:

6.2.7 Conclusion: Accepting the Normal Distribution

Since the p-value is greater than alpha, we fail to reject the null hypothesis — we accept that the population test scores follow a normal distribution with mean 68.42 and standard deviation 10.41. The conclusion can be carried back to the person who asked the question: you can recommend to the personnel director that the normal distribution may be applied to assist the interpretations he wants — finding the lowest 20%, the lowest 40%, the lowest 60%, and so on, quickly. That is the whole payoff of the test: once we establish that the sample plausibly came from a normal population, the normal distribution becomes a working tool for evaluating individual scores.

Think about what this unlocks in practice. With the normal model in hand, the personnel director no longer needs to sort 400 applicants' files by hand: a score's distance from the mean in standard-deviation units gives its percentile immediately, so "upper 20%" and "lower 40%" cutoffs fall straight out of the Z table. The same logic runs through grade assignment in classes, performance-award decisions in companies, and quality screening in manufacturing — anywhere a bell-shaped assumption lets you turn one raw score into a position in the population.

Recap + bridge: the goodness-of-fit test compares observed counts tallied from raw data with expected counts derived from a hypothesized distribution — here the normal with mean 68.42 and standard deviation 10.41. The statistic came out to 7.2 with 7 degrees of freedom, the p-value landed between 0.1 and 0.9 (about 0.4084 exactly), and since p exceeded alpha = 0.1, the normal distribution was accepted as a working model. The Q&A below settles the loose ends: how many intervals to make, where the table values come from, and what the syllabus actually expects.

6.2.8 Student Questions and Answers

The class asked seven questions about the goodness-of-fit example, from the setup of the intervals to the fine print of the decision.

Q: With 50 observations and the rule that each interval needs an expected frequency of at least five, how many intervals should we make?

A: 10 equal intervals. If you divide the entire data into 10 categories, then each interval automatically carries an expected frequency of 5, which maintains our condition of five in each category.

With the intervals settled, the first cutoff value came under scrutiny.

Q: For the lowest 10% of the test scores, is the Z value minus 1.28 from the normal tables?

A: Yes — the bottom 10% of the area corresponds to z = −1.28 in the standard normal table. Then solve: X = 68.42 − 1.28 × 10.41 = 55.10, which is the first cutoff. For the lowest 20%, the table gives z = −0.84, and X = 68.42 − 0.84 × 10.41 = 59.68. The same idea continues for the lowest 30%, lowest 40%, and so on.

Next, a student read a number from the chi-square table and wondered whether it was the statistic.

Q: Is the chi-square value 12.017?

A: No. Our chi-square value is 7.2 — I calculated it as 7.2. The values 12.017 and 2.833 are table values at 7 degrees of freedom: the area to the right of 12.017 is given as 0.10, and the area to the right of 2.833 is 0.90. Since 7.2 lies between them, the p-value lies between 0.1 and 0.9, certainly greater than 0.1.

The discussion then broadened to what belongs in the course and which normality checks exist beyond chi-square.

Q: Are all these things in our syllabus? There are other tests to validate normality, like the Shapiro-Wilk test.

A: Whatever is being discussed is in the syllabus. There are indeed other tests and metrics — the Shapiro–Wilk test and so on are there to validate whether data follows a normal distribution — but we are not using all those metrics here. As far as the chi-square application is concerned, this test is the one that can be used. There are also other ways to check normality: stem-and-leaf diagrams and histograms give a graphical look, and this chi-square test is the numerical way to validate whether the given sample comes from the normal distribution.

One student asked how far the method reaches beyond the normal case.

Q: Apart from normal, can goodness of fit also be applied to binomial or Poisson distributions?

A: In principle, yes — any problem can come. If you are asked to check whether specific data follows a binomial distribution, you should completely refer to the binomial tables, and you need to know what the binomial function is and how to find the probabilities. Similarly, a Poisson check would be a different story. But very frankly, no such binomial and no such Poisson will come here — no such binomial and Poisson will I ask. For this course, the goodness-of-fit example is the one needed to understand the many ways of validating a normal distribution.

Another question tested the significance-level default.

Q: In this problem alpha is 0.1. What if the level of significance is not given in a problem?

A: If alpha is not given, checking at 5% is fine — you can blindly take 5%, that is the common rule, and it is given in the text (pages 532 to 536 of the chapter on chi-square applications). Here alpha is 0.1, and the conclusion at 5% is the same: the p-value is somewhere around 0.4, so it makes no impact whether you check at 0.01, 0.05, or 0.1 — your conclusion remains the same, no change.

Finally, a question about the normal table itself — which convention to follow.

Q: Why are we not using the same table as before — which normal table should we use?

A: You can use the same table and you will get the same result — there is no difference. The only thing to know is that the normal distribution is a symmetric distribution, and the textbook convention is the one being followed. It is not a big deal: whichever table you use, your answer will make sense to both instructors, as long as you have understood the material thoroughly.

6.2.9 Exam Notes

Exam note: for goodness-of-fit problems, the degrees of freedom are , with the number of intervals and the number of parameters estimated from the sample — explicitly calculate and , or use them when supplied. In the goodness-of-fit example, alpha is given as 0.1; if it is not given, checking at 5% is fine and gives the same conclusion. The exact p-value (like 0.4084) can only come from software — from the tables, an approximate statement ("p lies between 0.1 and 0.9", "p > 0.1") is perfectly acceptable.

The rest of the exam guidance for this concept, in summary form:

  • No binomial or Poisson goodness-of-fit questions will be asked; normal-distribution problems are acceptable in the exam.
  • The p-value decision rule (p ≤ alpha rejects, p > alpha fails to reject) is the same for the Z test, the T test, and the chi-square distribution.
  • The observed frequencies come from tallying the raw data; the expected frequencies are per interval — build the two columns the goodness-of-fit way, not the independence-test way.
  • The ten equal-probability intervals come from the Z table cutoffs (55.10, 59.68, 63.01, 65.82, 68.42, 71.02, 73.83, 77.16, 81.74); remember the expected frequency of at least five in every interval.

6.3 Preview: Design of Experiments and Analysis of Variance

6.3.1 Design of Experiments

The next chapter is Chapter 13, and it opens a new area: the design of experiments. The plan is to cover, in the best possible way, what exactly experimental designs are, why designing an experiment is necessary, and what its relevance is. There are many types of designs; depending on the practical situation you are in, you will design an experiment and recommend the type that should be performed so that you get the best possible output or response.

This matters most for people who will work in the pharmaceutical industry or in biological and life sciences. They should not perform experiments throughout the year — that is hugely time-consuming and cost-consuming. Instead, they should run a clever combination of experiments and still reach sound conclusions. Finding the best possible combination of runs to perform, and getting the best output for the least effort, is what design of experiments is all about. The chapter also covers what types of designs are available and how to address those situations.

Why this preview matters: the two chi-square tests in this session compare data with what a hypothesis predicts. Design of experiments flips the perspective — instead of observing a sample passively, you plan which treatments to run, how to assign subjects, and how many replications you need, so the data you collect can answer the question cleanly and cheaply. Pharmaceutical and life-science companies routinely use designed experiments precisely to cut time and cost — running every possible experiment is rarely an option.

6.3.2 Analysis of Variance

Alongside the designs, the next session will take up another very interesting procedure conceptually: the analysis of variance, or ANOVA. We already know the basic significance of variance. Analysis of variance asks what we can analyze further in terms of variance, especially when it comes to the design of experiments. The plan is to work through Chapter 13 with examples, showing how the calculation part is carried out — and how the designs connect to the conceptual understanding of analysis of variance. These topics are all in Chapter 13, which is the focus of the coming session.

The connection between the two halves of the preview is direct: an experiment is designed so that the variance in the measured response can be split into parts — variance due to the treatments you changed on purpose, and variance due to chance. ANOVA is the tool that reads that split. Where today's chi-square tests asked about frequencies in categories, ANOVA asks about differences between group means — a new question, a new distribution (the F distribution), and the same overall habit: state the hypotheses, compute a test statistic, read the p-value, and state the conclusion in words.

Exam Guidance Summary

  • The two chi-square applications are exam-required. Both the test for independence and the goodness-of-fit test were flagged as "very, very required," with the expectation that you will calculate them in the exam. Practice both calculation styles: the table-based independence computation and the interval-based goodness-of-fit computation.
  • Open-book exam. No extra tables are needed — check the table values given and write your own comment.
  • Always write the hypotheses. State and explicitly for every problem. The standard independence statements can be written as-is; justify whatever variant you choose, and always give the conclusion in words, not just "reject."
  • Default alpha. When the level of significance is not given, use 5% by default — that is the common rule.
  • p-value approach. The rejection rule runs on p-values: rejects the null, fails to reject. Approximate p-values ("lies between", "greater than 0.1") are acceptable; exact values come only from software.
  • Degrees of freedom. Independence test: . Goodness of fit: , where is the number of intervals and is the number of parameters estimated from the sample.
  • The condition. Every expected frequency must be at least 5; if not, merge cells — and merge the observed frequencies in the same way — then adjust the degrees of freedom.
  • Goodness of fit specifics. Alpha is 0.1 in the worked example; checking at 5% gives the same conclusion. No binomial or Poisson goodness-of-fit questions will be asked. Normal-distribution problems are acceptable in the exam.
  • Presentation. Tabulating your calculation is fine and makes the work easier to follow.
  • Revision support. The next session is a planned revision of everything discussed so far for the mid-semester, with small questions, and practice problems with solutions will be shared before the mid-semester so you can practice the calculations.
  • Where to find it. The chi-square applications live in Chapter 12 of the textbook: the test for independence is on page 525, and the goodness-of-fit example runs through pages 532 to 536.
  • Quizzes and assignment. There will be two quizzes, and Quiz 2 covers these chapters; the assignment is a 15-mark group data-analysis report (see the Key Industry Applications section) that includes an interpretation component.

Key Industry Applications

  • Real-world: beer industry association survey — a consumer-preference study where the test for independence decides whether beer type (light, regular, dark) is associated with the gender of the drinker. Market-research studies like this are a standard setting for the test for independence, and the verdict feeds straight into promotion and advertising decisions: when preference depends on gender, a manufacturer can customize campaigns for each target market.
  • Real-world: ChemLine — a company hiring roughly 400 new employees each year across four plants in the United States. Its personnel director uses the goodness-of-fit test to check whether aptitude test scores follow a normal distribution, which then allows quick evaluation of specific scores (upper 20%, lower 40%, and so on) without sorting through individual files.
  • Real-world: normal-curve grading — if an entire class follows a normal (empirical) distribution, then roughly 10% of the students should get A grades, 10% should get E grades, and the middle bands split 20, 20, and so on. The same logic turns a percentile from the Z table into a grade band.
  • Real-world: performance awards — companies may lean on the Gaussian distribution when deciding hikes or awards, so that extremely talented performers get recognized; the same goodness-of-fit check that validates the aptitude-test data legitimizes that practice.
  • Real-world: pharmaceutical and life-science industries — designed experiments (Chapter 13) let researchers run smart combinations of experiments instead of performing experiments throughout the year, saving huge amounts of time and cost, with ANOVA reading the variance split.
  • Real-world: data-analysis software — the assignment invites you to use whatever software is available around you: Power BI, Minitab, SAS, SPSS, RStudio, or Excel, depending on the context; statistical calculators can also compute the mean and variance directly from entered data.

ASM Lecture 6 notes · Chi-Square Applications: Tests for Independence and Goodness of Fit

Advanced Statistical Methods· postgraduate· 2026-08-11

Sections Breakdown

1Chi-square Test for Independence

The test for independence decides whether two categorical variables arranged in a contingency table are related, covering the expected-frequency formula, the chi-square statistic, (R-1)(C-1) degrees of freedom, and the full beer preference and gender example.

2Chi-square Test for Goodness of Fit

The goodness-of-fit test checks whether a sample could come from a given distribution, building ten equal-probability intervals from the Z table and computing the chi-square statistic with k-p-1 degrees of freedom in the ChemLine aptitude-score example.

3Preview: Design of Experiments and Analysis of Variance

A first look at Chapter 13: how designed experiments deliver the best output for the least time and cost, and how analysis of variance reads the split of variance produced by those designs.

4Exam Guidance Summary

Exam strategy for the two chi-square applications: both tests are exam-required, the exam is open book, hypotheses and the p-value approach are mandatory, plus the degrees-of-freedom rules and the E >= 5 condition.

5Key Industry Applications

Real-world settings for the two tests: market research, personnel screening, bell-curve grading, performance awards, pharmaceutical experiments, and the data-analysis software suggested for the assignment.

Postgraduate students in Advanced Statistical Methods

Exam Revision Notes

Below is the distilled, exam-ready core. Every entry comes from the full explanation above. Use this section for rapid review; return to the main notes when a point needs more context.

Chi-square Test for Independence

Must-know: Test for independence: expected frequency E_ij = row total x column total / grand total; chi-square = double summation of (F_ij - E_ij)^2 / E_ij; df = (R-1)(C-1); every expected frequency must be at least 5; beer example chi-square = 6.45, p between 0.05 and 0.025, reject H0 - beer preference depends on gender.

⚠️ Top pitfall: Forgetting the E_ij >= 5 condition for every cell; using df = N - 1 instead of (R-1)(C-1); dividing by the observed instead of the expected frequency; ending at 'reject H0' without the conclusion in words.

Self-check: For the light-female cell (observed 39, row total 90, column total 68, N = 200), what is the expected frequency and the chi-square contribution?

Connects to: 6.2

Chi-square Test for Goodness of Fit

Must-know: Goodness of fit: estimate x-bar and s from the sample (68.42 and 10.41), cut the normal curve into k equal-probability intervals with expected frequency at least 5, tally observed frequencies, compute chi-square = 7.2, df = k - p - 1 = 10 - 2 - 1 = 7; p between 0.1 and 0.9 (about 0.4084) exceeds alpha = 0.1, so the normal distribution is accepted.

⚠️ Top pitfall: Using the independence-test degrees of freedom (R-1)(C-1) instead of k - p - 1; forgetting to subtract p for the estimated mean and standard deviation; confusing the observed frequencies (tallied from raw data) with the expected ones (n x probability, all 5 here); misreading table values such as 12.017 as the statistic when 7.2 is the statistic.

Self-check: With 50 observations and the expected-frequency-at-least-5 rule, how many equal intervals are used, and what is the expected frequency in each?

Connects to: 6.1, 6.3

Preview: Design of Experiments and Analysis of Variance

Must-know: Chapter 13 covers design of experiments (choosing the best combination of runs for the best output with least effort) and analysis of variance (splitting variance between treatments and chance); both are the focus of the coming session with worked examples and calculations.

Self-check: Why should pharmaceutical researchers use designed experiments rather than running experiments throughout the year?

Connects to: 6.1, 6.2

Exam Guidance Summary

Must-know: Both the test for independence and the goodness-of-fit test are exam-required; open book; write hypotheses; default alpha 5%; p-value approach; df = (R-1)(C-1) and k - p - 1; E >= 5 for every cell; approximate p-values acceptable; no binomial or Poisson goodness-of-fit questions.

⚠️ Top pitfall: Not adjusting the degrees of freedom after merging cells, or forgetting the E >= 5 condition.

Self-check: What are the degrees of freedom for the independence test and for the goodness-of-fit test?

Connects to: 6.1, 6.2

Key Industry Applications

Must-know: The test for independence drives consumer-preference research (beer association survey); the goodness-of-fit test validates the normal assumption for ChemLine's personnel screening; the assignment invites Power BI, Minitab, SAS, SPSS, RStudio, or Excel.

Self-check: Which software tools are suggested for the group data-analysis assignment?

Connects to: 6.1, 6.2

Was this lecture useful?

Loading comments…
🤖

BitsNotes AI Assistant

Subject Notes Assistant

Configure AI Chat

Choose how to access the chatbot
Have your own API key?

Switch to "Bring Your Own Key" tab above for unlimited access with any OpenAI-compatible provider.

🔑 Enter API key above to fetch live models from provider, or enter model name manually.
OpenAI-Compatible API Support

Choose any provider preset (Gemini, DeepSeek, Kimi, GLM, MiniMax, Qwen, OpenAI, Groq, Ollama, etc.) or enter a custom endpoint URL.

Security & Privacy First

Your API key is sent directly from your browser to your specified provider. BitsNotes servers never store or see your key.