UPI Study › Courses › Marketing Research › Free lessons › Lesson 11.1 Free lesson
The Chi-Square Test: What It Measures and How to Use It
Marketing Research · Chapter 11: Hypothesis Testing and Inferential StatisticsSection 11.1 · lesson 75 of 10112 min · free to watch
Lesson complete
Earn the 3 college credits for Marketing Research
Enrolling adds a quiz after each lesson, the graded work and the official transcript. Recommended for credit by NCCRS.
Next lesson: Understanding t-Tests: Assessing Statistical Differences Between Groups →← Descriptive vs. Inferential Statistics: What They Are and When to Use EachNext lesson: Understanding t-Tests: Assessing Statistical Differences Between Groups →
In this lesson
Test hypotheses with p-values and the chi-square test of independence.
- Explain the logic of hypothesis testing, p-values and the significance level alpha
- Distinguish Type I errors from Type II errors and describe power
- Run a chi-square test of independence on a cross-tab and interpret the result
- Check the expected-count assumption before trusting a chi-square p-value
Free study notes
Get this lesson's notes by email
The key points and 4 practice questions with answers, in your inbox. One email, free.
One email. Unsubscribe in one click.
Transcript
Everything said in the video, section by section (1,587 words). Read along, or search it.
Opening Question
Sixty Heads in a Hundred Flips
You flip a coin 100 times, and it lands heads 60 times. Is the coin cheating? Or is that just luck? Most people feel a flicker of suspicion at 60, and none at 52. So where does suspicion turn into evidence? Statisticians built a whole toolbox, to answer that question honestly.
Leo has the same worry about his data. Fernway Snacks is a composite case built for teaching. Leo works there, with Grace and Nadia. Online shoppers seem keener on Fernway's new bar, than corner-store shoppers. Is that a real pattern? Or a lucky roll of the dice? This lesson gives you the steps to decide.
Hypotheses
Assume Nothing Is Going On
First, the logic: assume nothing is going on. Hypothesis testing is a courtroom, for data. The suspect is, "nothing special is happening." We keep that assumption, unless the evidence is strong enough to make it hard to believe.
Two statements are always on the table. The null hypothesis, written H0, says nothing special is going on. The coin is fair. The two groups are the same. The two things are unrelated.
The alternative hypothesis, written H1, or Ha, says something is going on. The coin is biased. The groups differ. The things are related.
The coin shows the logic best. Assume the null hypothesis: the coin is fair. Then ask a question. How often would a fair coin give a result at least as lopsided as 60 heads? Instead of trusting a formula, let Python flip the fair coin 10,000 times, in batches of 100.
P-Value
How Often a Fair Coin Looks This Lopsided
Most runs of a fair coin land near 50 heads. But the tails of the picture are not empty. 297 runs gave 40 heads or fewer. 270 runs gave 60 or more. In all, 567 of the 10,000 runs were this lopsided, or worse.
A result of 60 or more, or 40 or fewer, shows up about once in every 18 runs. That share, 0.057 in the simulation, and 0.0569 exactly, is the p-value.
Read that definition slowly. The p-value is the probability of getting a result at least as extreme as ours, if the null hypothesis were true. It is not the probability that the coin is fair.
Before the experiment, we also fix a cutoff. It is called alpha, the significance level, and it is almost always 0.05. If the p-value is at or below alpha, we reject the null hypothesis, and call the result statistically significant. If it is above alpha, we fail to reject the null hypothesis.
Common Mistake
What a P-Value Does Not Say
Here, p equals 0.057. That is a hair above 0.05. So 60 heads is not quite enough, to call the coin unfair. Notice the careful wording. Failing to reject does not show that the coin is fair. It only says the evidence fell short.
Here is a common mistake. Someone reads p equals 0.04, as a four percent chance that the null hypothesis is true. Or p equals 0.30, as a thirty percent chance that the result is luck. Both readings are wrong.
A p-value is computed, assuming the null hypothesis is true. So it cannot also be the probability that the null hypothesis is true. It only says how surprising the data would be, in a world where nothing is going on.
Two Errors
False Alarms and Missed Links
Next: two ways to be wrong. Because we decide from a sample, we can be wrong in two different ways. Each one has a name. Picture a grid. Across the top, the truth, which nobody sees. Down the side, our decision.
If the null hypothesis is true, and we keep it, we are correct: no false alarm. If a real link exists, and we reject the null hypothesis, we are correct again: a real link is found. The other two boxes are the errors.
A Type I error rejects a true null hypothesis. It is a false alarm. Its chance is alpha. So with alpha at 0.05, we accept a five percent false-alarm risk, when nothing real is happening.
A Type II error keeps a false null hypothesis. It means we miss a real link. Its chance is called beta, and it falls when the sample is larger. And power, one minus beta, is the chance of finding a real link.
Error Trade-Off
Why Alpha Is a Compromise
What does this mean for Fernway? A Type I error means launching a new package, because shoppers "prefer" it, when they do not. A Type II error means shelving a package that shoppers truly prefer.
So why not set alpha very low? Because there is a trade. Lower alpha, and false alarms fall. But the chance of a miss goes up. That is why 0.05 is a compromise, rather than a law of nature. These two ideas, and the p-value, are used unchanged, in every test that follows.
Test of Independence
Channel and Repeat Buying in 300 Shoppers
Now, the chi-square test of independence. The coin had one variable. Leo's question links two categories. Where does a shopper usually buy? And would they buy again? Grace collects 300 shoppers, invented for teaching, and builds a cross-tab, from lesson 10.4. Each cell is a count.
Here are the observed counts. First, online. 62 yes, and 38 no. Next, the grocery. 57 yes, and 63 no. Then, the corner store. 31 yes, and 49 no. The yes rates are 62 percent online, 47.5 percent at the grocery, and 38.8 percent at the corner store.
First, the hypotheses, in words. The null hypothesis: channel and buying again are unrelated. The share who would buy again is the same in every channel. The alternative: they are related. In symbols, the null says the variables are independent. The alternative says they are not. Alpha is 0.05.
Formula
Expected Counts and Degrees of Freedom
Now the formula, in words. For every cell, take the observed count, minus the count we would expect if nothing were going on. Square it. Divide by the expected count. Then add up all the cells.
O is the observed count in a cell. E is the expected count in that cell. And the expected count is the row total, times the column total, divided by the grand total.
The test also needs degrees of freedom. They are the number of rows minus one, times the number of columns minus one. Here, two rows and three columns give one, times two. That is 2 degrees of freedom.
Why expected counts like these? If channel did not matter, half of every channel would say yes, because 150 of the 300 said yes overall. So the online column's 100 shoppers would split 50 and 50.
Test Statistic
A Value of 10.11 Beyond the 5.991 Cutoff
The expected counts are 50, 60 and 40, in each row. The smallest, 40, is comfortably above five. Now compare them with what Grace saw, in the yes row. Online: expected 50, observed 62. Grocery: expected 60, observed 57. Corner store: expected 40, observed 31.
Online shoppers say yes more often than expected. At the corner store, shoppers say yes less often. The test asks one thing. Are gaps this big, just luck?
The statistic is 10.11. A statistic near zero means the observed counts hug the expected ones. A large value means they are far away. To judge "large," we compare it with the chi-square curve, for 2 degrees of freedom.
On that curve, the cutoff that cuts off the top five percent is 5.991. Our 10.11 lands well inside that red region. The p-value is 0.0064.
Decision. The p-value of 0.0064 is below 0.05. And 10.11 is above 5.991. So we reject the null hypothesis.
Interpretation
Strong Evidence, Not Proof of Cause
What does that mean for Fernway? The rates of buying again really do differ by channel. A gap this large would be rare, if channel did not matter. The printed cell contributions show which cells pull the statistic up most. The online cells give 2.88 each. The corner-store cells give 2.025 each.
But be careful. The test does not say how big the effect is. And it does not say that channel causes it, as lesson 6.4 warned. Online shoppers might simply be younger.
Nadia asks Grace, "Did the test prove online shoppers like the bar more?" The colleague smiles. "It says a gap this big would show up about once in 150 tables, if channel made no difference. That is strong evidence, not proof. And it does not say why." The interviewer records both lines.
Pro Tip
Expected Counts of Five or More
A pro tip. Check the assumption, before trusting the p-value. Every expected count should be at least five. Check the expected counts, not the observed ones. If a cell falls short, combine similar categories, such as merging two small age groups. Or collect more data.
Try it yourself. In the Python file, replace the table with a new one: 52, 57, 41 in the yes row, and 48, 63, 39 in the no row. It still has 300 shoppers and the same totals. But the channel gap is much smaller. Guess first. Will the p-value rise, or fall? Then run it, and see.
Key Takeaways
The Testing Steps in Brief
Key takeaways. Assume the null hypothesis, that nothing is going on. Measure how surprising the data would be. Reject the null only when the p-value is at or below alpha. A Type I error is a false alarm. A Type II error means missing a real link. For a table of counts, the chi-square statistic adds up observed minus expected, squared, over expected, across all cells. Compare it with the chi-square curve, with rows minus one, times columns minus one, degrees of freedom. And remember: expected counts of five or more.
Next, in lesson 11.2, you will use t-tests to compare the average ratings of two groups, and of one group with a target. This lesson was made by UPI Study.
About Marketing Research at UPI Study
Marketing Research (Marketing 300) is a self-paced online course of 101 video lessons in 13 chapters, from consumer behavior, segmentation and the research process to qualitative methods, surveys and sampling, measurement, experiments, secondary and syndicated data, descriptive statistics, hypothesis tests, correlation and regression, research ethics and reports. It carries a NCCRS credit recommendation for 3 semester credits.
Every lesson transcript is free on pages like this one, and the videos are free with a free UPI Study account. Enrolling adds a practice quiz after each lesson, the graded work and final exam that earn the credit, lifetime access, and an official transcript on completion. UPI Study has helped over 130,000 students with college credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Enroll now → Course details Download the syllabus All Business courses Every credit course with PRO →
Why take it here
Why students take Marketing Research with UPI Study
Where the credit goes
Universities that work with NCCRS
Marketing Research carries a NCCRS credit recommendation. These universities work with NCCRS; some are UPI Study's signed partners. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Thomas Edison State UniversitySigned partner
University of the PeopleSigned partner
Charter Oak State CollegeSigned partner
Strayer UniversitySigned partner
Columbia Southern UniversitySigned partner
Indiana TechSigned partner
Penn StateWorks with NCCRS
Southern New Hampshire UniversityWorks with NCCRS
SUNYWorks with NCCRS
+many more cooperating universitiesFind my college →Find my college → Not listed? Ask Athena in the corner of this page, or book a 15-minute call.
FAQ
Questions students ask us
About The Chi-Square Test: What It Measures and How to Use It
What does a chi-square test of independence tell you?
How do you calculate expected counts for a chi-square test?
What is a p-value in plain words?
What is the difference between a Type I and a Type II error?
About the Marketing Research course
How many college credits is Marketing Research?
How much does Marketing Research cost and what is included?
Which universities accept UPI Study credits?
How long does Marketing Research take?
How are the exams done?
How do my credits reach my college?
Ready for the full course? Earn 3 credits in Marketing Research.
101 video lessons, a quiz after each one, and the graded work that earns the credit. Recommended for credit by NCCRS.
Updated
3 credits · NCCRSEnroll →