Tests for Independence (College Board AP® Statistics): Study Guide

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 a significant relationship between two categorical variables

    • i.e. if two variables are independent of each other or if they are related (dependent)

  • For example, you may have collected data on the grade level and school subject preference from a group of students

    • A test for independence could indicate whether the grade level of a student has an impact on their preferred school subject

  • A chi-square test for independence is a specific goodness of fit test

    • The observed values are compared with values that you would expect if the two variables are independent

  • Observed values can be shown in a two-way table

    • This is also known as a contingency table

  • E.g. a contingency table for the grade level and school subject preference of a group of 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 the assumption that the two categorical variables are independent

    • e.g. H0 : The grade level of a student is independent of their school subject preference (there is no association)

      • It is assumed to be correct, unless evidence proves otherwise

  • The alternative hypothesis, Ha, is the assumption that the two categorical variables are not independent

    • e.g. Ha: The grade level of a student is not independent of their school subject preference (there is an association)

Examiner Tips and Tricks

In an exam, a test for independence may also be referred to as a test for an association between two variables, but 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 independence test:

    • Observed values must come from a random sample

    • Observed values must be independent

      • They are sampled with replacement

      • or the sample size is less than 10% of the population size

    • Expected values must meet the large counts condition

      • Each expected value must be greater than or equal to 5

      • or at least 80% of the expected values are greater than 5 and all are greater than or equal to 1

Examiner Tips and Tricks

In the exam, either condition is accepted for the large counts condition.

How do I calculate a chi-square value?

  • The chi-square value for the test of independence, X2, can be calculated from the formula given to you in the exam

    • χ2=(observedexpected)2expected

  • The larger X2 is, the more different the observed values are from the expected values

  • To be able to calculate the chi-square value, you therefore need to find the expected values first

  • To calculate the expected value for a particular cell, multiply together:

    • the probability of being in that particular row

    • by the probability of being in that particular column

    • by the total number in the sample

    • This is equivalent to simply multiplying the row total by the column total and dividing by the grand total

  • E.g. the expected value for the number of 10th graders who prefer languages in the example above is

    • 31100·19100·100=5.89

    • or just 31·19100=5.89

  • The table below shows all the expected values 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

Examiner Tips and Tricks

Expected values do not need to be integer values, so leave them unrounded to avoid calculation errors!

What are degrees of freedom?

  • The number of degrees of freedom, 'dof', is equal to

    • the (number of rows1)(number of columns1)

    • e.g. dof for the contingency table above is (31)(41)=2·3=6

How do I use the chi-square distribution table?

  • You can use the chi-square tables given to you in the exam to find the critical value

    • This is the threshold value that determines whether you reject the null hypothesis or not

  • To find the critical value from the tables, you need the significance levelα% and the dof

    • The critical value is located in the cell where the relevant row and column intersect

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

    • If χ2>critical value then we reject the null hypothesis

      • There is convincing statistical evidence to suggest that the two categorical variables are not independent

    • If χ2<critical value then we fail to reject the null hypothesis

      • There is not convincing statistical evidence to say that the two categorical variables are not independent

How can I perform an independence test on the calculator?

  • To complete an independence test on your calculator:

    • Create a matrix of the observed values

    • Perform a chi-square test

      • This is often called a χ2 two-way test on a calculator

    • Compare your calculated χ2, with the critical value from the chi-square tables

  • Alternatively, you can compare the given significance level, α, with the calculator's p-value

    • If using the p-value, remember

      • If p<α then we reject the null hypothesis

      • If p>α then we fail to reject the null hypothesis

Examiner Tips and Tricks

Even if you perform the independence test on your calculator, it is still important to show all of your working to demonstrate full understanding. Depending on the question, you may need to show how the chi-square statistic is calculated in full or just how an expected value and the degrees of freedom are calculated.

If you compare the p-value with α, don't forget that the inequalities are the opposite to when you are comparing the χ2 value to the critical value when you are determining whether or not to reject the null hypothesis!

Worked Example

A coffee company wanted to understand more about who their customers were. They took a random sample of 200 individuals to see if there was an association between an individual'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 individual'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 individual's relationship status and whether they drink coffee or not, they are independent

Ha : There is an association between an individual's relationship status and whether they drink coffee or not, they are not independent

State the type of test being used

The correct inference procedure is a chi-square test of independence at α=0.05

Calculate the expected values (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

All conditions for inference have been met:

  • The observed values are independent as the sample of individuals is randomly selected

  • All expected values are greater than 5

Calculate the chi-square value, χ2, (observedexpected)2expected

χ2=(4839.05)239.05+(2531.35)231.35+(3739.6)239.6+(2331.95)231.95+(3225.65)225.65+(3532.4)232.4=7.795...

State the number of degrees of freedom

degrees of freedom = (21)(31)=2

Find the critical value from the chi-square tables

Find the row corresponding to 2 degrees of freedom and the column corresponding to α=0.05

critical value=5.99

Compare the calculated χ2 value to the critical value and state the conclusion of the test

7.795...>5.99χ2>critical value

We reject H0

Interpret the result in the context of the question

There is convincing statistical evidence to suggest that there is an association between an individual's relationship status and whether they are a coffee drinker or not, i.e. the two variables are not independent

(b)

Evaluate the causal claim

The data come from a random sample of 200 individuals, not from a randomized experiment — the researcher did not randomly assign individuals to a relationship status

Because this is an observational study, confounding variables (e.g. age, working hours, lifestyle) could explain the observed association, and a cause-and-effect relationship cannot be established

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 and individuals were not randomly assigned to a relationship status, the data cannot establish that being single causes higher coffee-drinking rates

Compute conditional proportions for coffee drinkers by relationship status

Single: 48710.676, or 67.6%

Married / Cohabiting: 25570.439, or 43.9%

Other: 37720.514, or 51.4%

Describe the nature of the association

The proportion of coffee drinkers is highest among single individuals (about 67.6%), lower among individuals categorized as other (about 51.4%), and lowest among married or cohabiting individuals (about 43.9%)

The sample data suggest that being single is associated with a higher likelihood of being a coffee drinker, while being married or cohabiting is associated with a lower likelihood of being a coffee drinker

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.