Tests for Independence (College Board AP® Statistics): Revision Note

Naomi C

Written by: Naomi C

Reviewed by: Dan Finlay

Updated on

Test for independence

What is a test for independence?

  • A chi-square (χ2) 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, H0, is that the two categorical variables are independent

    • e.g. H0: 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, Ha, is that the two categorical variables are not independent

    • e.g. Ha: 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 31×19100=5.89

  • 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 df=(3−1)(4−1)=6

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, χ2, with the critical value from the chi-square table

    • If χ2≥critical value, reject the null hypothesis

    • If χ2<critical value, 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 χ2 test

      • This is often called a χ2 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 (χ2≥critical value).

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

H0: There is no association between an adult's relationship status and whether they drink coffee

Ha: 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 α=0.05

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, χ2=∑(observed−expected)2expected

χ2=(48−39.05)239.05+(25−31.35)231.35+(37−39.6)239.6+(23−31.95)231.95+(32−25.65)225.65+(35−32.4)232.4

χ2=7.795...

State the number of degrees of freedom

df=(2−1)(3−1)=2

Find the p-value from the chi-square table, using the row for 2 degrees of freedom

7.795... lies between 7.38 (tail probability 0.025) and 7.82 (tail probability 0.02)

0.02<p-value<0.025

Compare the p-value with the significance level and state the decision

p-value<0.025<0.05, so reject H0

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: 4871≈0.676, or 67.6%

Married / Cohabiting: 2557≈0.439, or 43.9%

Other: 3772≈0.514, 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!

Join the 100,000+ Students that ❤️ Save My Exams

the (exam) results speak for themselves:

Build on this topic

Naomi C

Author: Naomi C

Expertise: Maths Content Creator

Naomi graduated from Durham University in 2007 with a Masters degree in Civil Engineering. She has taught Mathematics in the UK, Malaysia and Switzerland covering GCSE, IGCSE, A-Level and IB. She particularly enjoys applying Mathematics to real life and endeavours to bring creativity to the content she creates.

Dan Finlay

Reviewer: Dan Finlay

Expertise: Portfolio Lead

Dan graduated from the University of Oxford with a First class degree in mathematics. As well as teaching maths for over 8 years, Dan has marked a range of exams for Edexcel, tutored students and taught A Level Accounting. Dan has a keen interest in statistics and probability and their real-life applications.