Tests for Independence (College Board AP® Statistics): Revision Note
Test for independence
What is a test for independence?
A chi-square test for independence is used to determine whether there is an association between two categorical variables in a single population
i.e. whether the two variables are independent of each other or associated (not independent)
For example, you may have collected data on the grade level and preferred school subject of a random sample of students
A test for independence could show whether there is an association between a student's grade level and their preferred school subject
The test compares the observed counts with the expected counts you would get if the two variables were independent
See the Chi-Square Distribution note for how to calculate expected counts, the chi-square test statistic and the degrees of freedom
The observed counts are shown in a two-way table
This is also known as a contingency table
E.g. a two-way table for the grade level and preferred school subject of a random sample of 100 students is shown below
| Grade level | |||||
9th | 10th | 11th | 12th | Total | ||
Preferred subject | Math/Science | 11 | 7 | 15 | 9 | 42 |
Humanities | 8 | 8 | 6 | 5 | 27 | |
Languages | 6 | 4 | 9 | 12 | 31 | |
Total | 25 | 19 | 30 | 26 | 100 | |
What are the null and alternative hypotheses for an independence test?
The null hypothesis, , is that the two categorical variables are independent
e.g. There is no association between grade level and preferred school subject for students at the school
It is assumed to be correct, unless there is convincing evidence against it
The alternative hypothesis, , is that the two categorical variables are not independent
e.g. There is an association between grade level and preferred school subject for students at the school
Examiner Tips and Tricks
A test for independence may also be described as a test for an association between two variables. Be careful with the wording: if two variables are independent, then there is no association between them.
What are the conditions for an independence test?
When performing a chi-square test for independence, check that
the data come from a random sample
if sampling without replacement, the sample size is less than or equal to 10% of the population size
all expected counts are greater than 5
This is sometimes called the large counts condition
How do I find the expected counts, test statistic and degrees of freedom?
These are found in the same way as for any chi-square test (see the Chi-Square Distribution note)
E.g. for the table above, the expected count for 10th graders who prefer languages is
The table below shows all the expected counts for the example above
| Grade level | |||||
9th | 10th | 11th | 12th | Total | ||
Preferred subject | Math/Science | 10.5 | 7.98 | 12.6 | 10.92 | 42 |
Humanities | 6.75 | 5.13 | 8.1 | 7.02 | 27 | |
Languages | 7.75 | 5.89 | 9.3 | 8.06 | 31 | |
Total | 25 | 19 | 30 | 26 | 100 | |
All the expected counts are greater than 5, so the large counts condition is met
The table has 3 rows and 4 columns, so the degrees of freedom are
How do I conclude a hypothesis test?
Conclusions to a hypothesis test need to show two things:
a decision about the null hypothesis
an interpretation of this decision in the context of the question
To make the decision, compare the p-value with the significance level,
If p-value , reject the null hypothesis
There is convincing statistical evidence of an association between the two variables
If p-value , fail to reject the null hypothesis
There is not convincing statistical evidence of an association between the two variables
Alternatively, compare the test statistic, , with the critical value from the chi-square table
If , reject the null hypothesis
If , fail to reject the null hypothesis
Rejecting the null hypothesis gives evidence of an association, not that one variable causes changes in the other
Unless the data come from a randomized experiment, you cannot conclude cause and effect
How can I perform an independence test on the calculator?
To complete a test for independence on your calculator:
Enter the observed counts into a matrix
Perform a test
This is often called a two-way test on a calculator
The calculator gives the test statistic, the p-value and the degrees of freedom
Compare the p-value with the significance level,
Examiner Tips and Tricks
Even if you perform the test on your calculator, show your work. Depending on the question, you may need to show how the chi-square test statistic is calculated in full, or just how an expected count and the degrees of freedom are found.
Be careful with the inequalities: you reject the null hypothesis when the p-value is small (p-value ), but when the test statistic is large ().
Worked Example
A coffee company wanted to understand more about who their customers were. They took a random sample of 200 adults to see if there was an association between an adult's relationship status and whether they were a coffee drinker or not.
The outcomes of their research are shown in the table below.
Single | Married / Cohabiting | Other | Total | |
|---|---|---|---|---|
Coffee drinker | 48 | 25 | 37 | 110 |
Non-coffee drinker | 23 | 32 | 35 | 90 |
Total | 71 | 57 | 72 | 200 |
(a) Determine, at the 5% significance level, if there is an association between an adult's relationship status and whether they are a coffee drinker or not.
(b) After seeing the result of the chi-square test, a researcher concludes that being single causes people to be more likely to drink coffee. Is this a valid conclusion? Justify your answer. Then, using conditional proportions from the data, describe the nature of the association between relationship status and coffee-drinking habits.
Answer:
(a)
Write the null and alternative hypotheses
There is no association between an adult's relationship status and whether they drink coffee
There is an association between an adult's relationship status and whether they drink coffee
State the type of test being used
The correct inference procedure is a chi-square test for independence at
Calculate the expected counts (by multiplying the row total by the column total and dividing by the grand total)
Single | Married / Cohabiting | Other | Total | |
|---|---|---|---|---|
Coffee drinker | 39.05 | 31.35 | 39.6 | 110 |
Non-coffee drinker | 31.95 | 25.65 | 32.4 | 90 |
Total | 71 | 57 | 72 | 200 |
Verify the conditions for the test
The data come from a random sample of 200 adults
It is reasonable to assume that 200 is less than 10% of all adults in the population
All expected counts are greater than 5
Calculate the chi-square test statistic,
State the number of degrees of freedom
Find the p-value from the chi-square table, using the row for 2 degrees of freedom
lies between 7.38 (tail probability 0.025) and 7.82 (tail probability 0.02)
Compare the p-value with the significance level and state the decision
, so reject
Interpret the result in the context of the question
There is convincing statistical evidence of an association between an adult's relationship status and whether they are a coffee drinker
(b)
Evaluate the causal claim
The data come from a random sample of 200 adults, not from a randomized experiment as the researcher did not randomly assign adults to a relationship status
Because this is an observational study, confounding variables (e.g. age, working hours, lifestyle) could explain the observed association
No, the researcher's causal conclusion is not valid
The chi-square test provides evidence of an association between relationship status and coffee drinking, but because the study is observational, the data cannot show that being single causes higher coffee-drinking rates
Calculate the conditional proportions of coffee drinkers for each relationship status
Single: , or 67.6%
Married / Cohabiting: , or 43.9%
Other: , or 51.4%
Describe the nature of the association
The proportion of coffee drinkers is highest among single adults (about 67.6%), lower among adults with another relationship status (about 51.4%) and lowest among married or cohabiting adults (about 43.9%)
In the sample, being single is associated with a higher proportion of coffee drinkers, and being married or cohabiting is associated with a lower proportion
Unlock more, it's free!
Was this revision note helpful?
Build on this topic