Grade by Grade
E. Culminating Data Management Investigation · Culminating Data Management Investigation

Analysing the Data II: Relationships Between Variables

E1.4About 75 minutes
Learning goals
  • I can choose a two-variable analysis that matches my variable types (scatter plot and regression for two numerical variables; contingency table for two categorical variables).
  • I can calculate and interpret the correlation coefficient r and the coefficient of determination r² in context.
  • I can find and interpret the least-squares line of best fit, and use it for sensible predictions.
  • I can use a residual plot to judge whether a linear model fits.
  • I can build a contingency table and compare conditional percentages.

Words to know

correlation coefficient (r)
A number from −1 to 1 that measures the direction and strength of a linear relationship between two numerical variables.
coefficient of determination (r²)
The proportion of the variation in the response variable that is explained by the linear relationship with the explanatory variable.
least-squares line
The line ŷ = a + bx that makes the sum of the squared residuals as small as possible.
residual
Actual value minus predicted value: y − ŷ.
extrapolation
Using a model to predict outside the range of the data used to build it; often unreliable.
conditional percentage
A percentage calculated within one row or column of a contingency table, such as the percentage of students with jobs who meet the guideline.

Two variables, one story

Hypothesis 2 asks whether, among students with jobs, more hours of work goes with less sleep. That is a question about the relationship between two numerical variables, so Amira uses the tools from Two-Variable Data Analysis and Validity: a scatter plot, the correlation coefficient, a least-squares line and residuals. She also builds a contingency table relating two categorical variables (job: yes or no; meets the guideline: yes or no), which gives a second view of Hypothesis 1.

Match the tool to the variable types:

  • two numerical variables: scatter plot, r, r², regression line, residual plot;
  • one categorical and one numerical: side-by-side box plots, group summaries (last lesson);
  • two categorical variables: contingency table, conditional percentages, side-by-side or segmented bar graph.

The data for Hypothesis 2

The 22 students with jobs give these pairs (x = hours of paid work per week, y = school-night sleep in hours). From the example data set:

(6, 8.75), (9, 8.0), (14, 7.25), (16, 7.5), (18, 7.75), (5, 8.75), (15, 7.75), (6, 7.5), (20, 6.25), (12, 8.0), (8, 7.25), (12, 7.5), (8, 8.0), (25, 6.25), (10, 7.0), (22, 7.5), (15, 7.0), (24, 7.25), (10, 6.75), (4, 8.0), (12, 7.0), (20, 6.5)

The sums are: n = 22, Σx = 291, Σy = 163.5, Σxy = 2107.25, Σx² = 4665, Σy² = 1224.875.

02468101214161820222426paid work (hours per week)6.06.57.07.58.08.59.0sleep (hours)ŷ = 8.330 − 0.0679xr ≈ −0.62, n = 22
Scatter plot of sleep against hours of paid work for the 22 students with jobs (example data, made up for teaching), with the least-squares line. The points drift down to the right with a fair amount of scatter.
Worked example

The model investigation, Stage 12: correlation

Calculate r with the computational formula and interpret it.

  1. Numerator: nΣxy − (Σx)(Σy) = 22(2107.25) − 291(163.5) = 46 359.5 − 47 578.5 = −1219.
  2. First bracket: nΣx² − (Σx)² = 22(4665) − 291² = 102 630 − 84 681 = 17 949.
  3. Second bracket: nΣy² − (Σy)² = 22(1224.875) − 163.5² = 26 947.25 − 26 732.25 = 215.
  4. r = −1219 ÷ √(17 949 × 215) = −1219 ÷ √3 859 035 ≈ −1219 ÷ 1964.44 ≈ −0.621.
  5. Interpretation: a moderate negative linear relationship (|r| is between 0.33 and 0.67, the classroom guide from Two-Variable Data Analysis and Validity). Students who work more hours tend to sleep less.
  6. r² ≈ 0.621² ≈ 0.385: about 39% of the variation in sleep among students with jobs is explained by the linear relationship with hours worked. The other 61% comes from other things (homework, activities, habits, measurement error).

r ≈ −0.62 (moderate, negative); r² ≈ 0.39. The prediction of Hypothesis 2 (r < 0) is supported.

Worked example

The model investigation, Stage 13: line of best fit

Find the least-squares line ŷ = a + bx, interpret the slope and intercept, and predict the sleep of a student who works 15 hours a week.

  1. Slope: b = [nΣxy − (Σx)(Σy)] ÷ [nΣx² − (Σx)²] = −1219 ÷ 17 949 ≈ −0.0679.
  2. Means: x̄ = 291 ÷ 22 ≈ 13.227 and ȳ = 163.5 ÷ 22 ≈ 7.4318.
  3. Intercept: a = ȳ − b x̄ ≈ 7.4318 − (−0.067915)(13.227) ≈ 7.4318 + 0.8983 ≈ 8.330.
  4. Line: ŷ = 8.330 − 0.0679x.
  5. Slope in context: each additional hour of work per week is associated with about 0.068 h, or about 4 minutes, less sleep per school night. Ten more hours of work a week goes with about 41 minutes less sleep.
  6. Intercept: a student with a job but close to 0 hours would be predicted to sleep about 8.33 h. Since every job-group student worked at least 4 hours, x = 0 is just outside the data, so treat this cautiously.
  7. Prediction at x = 15: ŷ = 8.330 − 0.0679(15) ≈ 8.330 − 1.019 ≈ 7.31 h. Student 11 worked 15 hours and slept 7.75 h, so the residual is 7.75 − 7.31 ≈ +0.44 h.

ŷ = 8.330 − 0.0679x. About 4 minutes less sleep per school night for each extra weekly hour of work; predicted sleep at 15 h of work ≈ 7.31 h.

−1.0−0.50.00.51.0residual (hours)02468101214161820222426paid work (hours per week)residual = 0
Residual plot for the line ŷ = 8.330 − 0.0679x. The residuals scatter above and below 0 with no curve or fan shape, so a straight line is a reasonable model. All residuals are within about ±0.9 h.

Reading the residual plot

A good linear model leaves residuals that look like random scatter around 0. Watch for:

  • a curve (the relationship is not linear);
  • a fan (spread grows with x, so predictions are less reliable for large x);
  • one large residual or a point far to the side (an outlier or influential point that may change the line).

Amira's residual plot shows none of these, so the linear model is appropriate. She also notes that predictions should stay within 4 to 25 hours of work; predicting the sleep of someone who works 40 hours a week would be extrapolation.

Worked example

The model investigation, Stage 14: contingency table

Using all 40 students, build a contingency table of Job (yes/no) by Meets the 8-hour guideline (yes/no), and compare conditional percentages.

  1. Count from the data: job and meets: 6; job and does not meet: 16; no job and meets: 16; no job and does not meet: 2.
  2. Row totals: job 22, no job 18. Column totals: meets 22, does not meet 18. Grand total 40.
  3. Conditional percentages (within each row): job: 6 ÷ 22 ≈ 27.3% meet; no job: 16 ÷ 18 ≈ 88.9% meet.
  4. Overall, 22 ÷ 40 = 55% meet the guideline, but this hides a huge difference between the groups: students without jobs are about 88.9 ÷ 27.3 ≈ 3.3 times as likely to meet it.

See the table. 27.3% of students with jobs and 88.9% of students without jobs met the 8-hour guideline.

Meets guideline (≥ 8 h)Does not meetTotal% meeting
Job6162227.3%
No job1621888.9%
Total22184055.0%
Contingency table for the example data set (made up for teaching).

Association is not causation

A survey shows association. Amira's data show that work and sleep go together; they do not prove that working causes less sleep. Possible explanations include cause and effect, a common cause (for example, family responsibilities or a long commute could affect both how much a student works and how much they sleep), or reverse cause (students who need less sleep may be the ones who take on more hours). The next lessons on conclusions return to this. Only a randomized experiment could show cause, and assigning students to work would be neither practical nor ethical.

Just for fun

The regression line says each extra hour of work costs about 4 minutes of sleep. Somewhere a cat is reading this and thinking, "Amateurs. I sleep 15 hours and work zero."

Hands-on activity

Your investigation, step 7: relationships

You need: your data, a calculator, a spreadsheet or Desmos, and graph paper.

  1. Decide which pairs of variables in your study answer your hypotheses and what types they are.
  2. For two numerical variables: draw a scatter plot, calculate r and r² (by hand with a table of sums, then check with =CORREL or Desmos), find the least-squares line (check with =SLOPE and =INTERCEPT), and make a residual plot.
  3. Interpret the slope, the intercept and r² in context in full sentences, and give the range of x in which predictions are reasonable.
  4. For two categorical variables: build a contingency table with totals and conditional percentages, and draw a side-by-side bar graph.
  5. Note any outliers or influential points and what happens to r if you remove them (report both; do not delete).
  6. Write one paragraph: "What do the relationships show, and how strong are they?"

Practice with the example data first: check Amira's r, line and table using the 22 pairs above.

Your turn

1

Use Amira's line to predict the sleep of a student who works 10 hours a week.

2

Student 22 worked 25 hours and slept 6.25 hours. Find the residual.

3

Interpret r² ≈ 0.39 in a sentence.

4

Why should Amira not use the line to predict the sleep of someone who works 40 hours a week?

5

What percentage of all 40 students met the guideline?

6

Is a correlation of −0.62 stronger or weaker than one of 0.45? Explain.

More practice: warm-up

1

What is the slope of Amira's line?

2

State the formula for a residual.

3

Which tool fits two categorical variables?

4

Convert 0.0679 h to minutes.

5

What does a negative r mean?

More practice: on your own

1

Check that the line passes through (x̄, ȳ) ≈ (13.227, 7.432).

2

Student 2 worked 6 hours and slept 8.75 hours, the largest positive residual. Find it.

3

Using the contingency table, find P(meets | no job) and P(no job | meets). Explain the difference.

4

Suggest one common-cause explanation and one reverse-cause explanation for the negative correlation.

5

Amira also computed r using all 40 students (0 hours for those without jobs) and got about −0.76. Why might this be stronger than −0.62, and which analysis better answers Hypothesis 2?

Challenge

1

Verify the slope using b = r × (s_y ÷ s_x), given r ≈ −0.621, s_y ≈ 0.682 and s_x ≈ 6.233 for the job group.

2

If the student with 25 hours and 6.25 hours of sleep were removed, would you expect r to become closer to 0 or further from 0? Explain without calculating.

3

Explain why a randomized experiment to test whether working causes less sleep would be impractical or unethical, and describe a stronger observational design Amira could suggest as a follow-up.

Check your understanding

Quiz

1.

For Amira's job group, r ≈ −0.62. This describes a:

2.

r² ≈ 0.39 means:

3.

Using ŷ = 8.330 − 0.0679x, the predicted sleep for 20 hours of work is about:

4.

Which residual plot pattern suggests a linear model is appropriate?

5.

In the contingency table, the percentage of students with jobs who meet the guideline is:

6.

Which conclusion is justified by Amira's survey data?

For parents and teachers

Big idea (E1.4): two-variable tools describe how variables move together: scatter plots, r, r², a least-squares line and residuals for numbers; contingency tables for categories. Interpretation in context, and caution about cause, matter as much as the arithmetic.

How to help: Ask your teen what the slope means in everyday words ("each extra hour of work goes with about 4 minutes less sleep"). Ask, "Does that prove work causes less sleep? What else could explain it?" Check a prediction together with a calculator.

Common difficulties:

  • Mixing up Σx² and (Σx)² in the formulas.
  • Treating r as the slope, or as a percentage.
  • Extrapolating far beyond the data.
  • Claiming cause from a survey.
  • Conditional percentages calculated across the wrong row or column.