Intro statistics · Two quantitative variables
Linear regression and correlation practice problems
Many regression questions on an intro stats final follow the same routine: look at the scatterplot, measure the correlation, fit the line, use it, then check it. This guide walks through that routine one step at a time, with a small tool that shows how one unusual point can change everything. Then come four fully worked examples and fifteen practice problems you can check as you go.
The six-step routine (each step links to its section)
- Look: describe the scatterplot
- Measure: correlation r and r²
- Fit: the least-squares line
- Interpret: slope and intercept in context
- Predict: and know when not to
- Check: residuals and the residual plot
Then: outliers and influential points · reading software output · worked examples · practice · FAQ
Step 1 Look: describe the scatterplot
Before you calculate anything, plot the data. Put the explanatory variable (the one you think helps predict) on the x-axis and the response on the y-axis. Then describe four things. A handy way to remember them is DFSO:
| Feature | Question to ask | Typical words |
|---|---|---|
| Direction | As x goes up, does y tend to go up or down? | Positive, negative, or no clear direction |
| Form | Do the points follow a straight line or a curve? | Linear, curved, clusters |
| Strength | How tightly do the points hug that form? | Strong, moderate, weak |
| Outliers | Are any points far from the overall pattern? | Name them and say how they stand out |
Here is the small data set we will use for the first few steps: five students, the hours they spent on practice problems before a quiz, and their quiz score out of 10.
| Student | A | B | C | D | E |
|---|---|---|---|---|---|
| Hours of practice, x | 1 | 2 | 4 | 5 | 8 |
| Quiz score, y | 3 | 5 | 6 | 6 | 10 |
Description: there is a strong, positive, linear relationship between hours of practice and quiz score, with no obvious outliers. Students who practiced more tended to score higher. (With only five points, “no obvious outliers” is about all you can say.)
Step 2 Measure: correlation r and r²
The correlation coefficient r puts a number on the direction and strength of a linear relationship. The facts you need:
- Range: r is always between −1 and 1. The sign gives the direction. Values near −1 or 1 mean the points sit close to a line; values near 0 mean no linear pattern.
- No units: r is unitless. Switching from hours to minutes, or from dollars to euros, does not change it. Swapping x and y doesn’t change it either.
- Linear only: r can be close to 0 for a strong curved pattern (think of a U shape). Always look at the plot first.
- Not resistant: one outlier can push r a long way up or down. The tool below shows how much.
- Not causation: a strong r tells you two variables move together. It does not tell you one causes the other.
The formula your course probably shows is r = (1 ⁄ (n − 1)) Σ [(x − x̄) ⁄ sx] [(y − ȳ) ⁄ sy]: multiply each point’s two z-scores, add them up, and divide by n − 1. In practice you will usually get r from a calculator or software, so the skill that gets tested is reading it.
Correlation is not causation
Towns that sell more ice cream have more drownings. Ice cream doesn’t cause drowning: hot weather drives both. A variable like temperature that affects both x and y, and isn’t in your analysis, is called a lurking variable. A well-designed randomized experiment can give strong evidence of cause and effect. With observational data, a strong r is a reason to look further, not proof.
r² is the share of variation explained
Square r and you get the coefficient of determination, r². It tells you what fraction of the variation in y is explained by the linear relationship with x. The rest is left over in the residuals. For the quiz data, r = 0.967, so r² = 0.935: about 93.5% of the variation in quiz scores is explained by the linear relationship with practice hours.
Template sentence: “About [r² as a %] of the variation in [y in context] is explained by the linear relationship with [x in context].” Note that r² is never negative, so it can’t tell you the direction. For that you need the sign of r or of the slope.
Try it: what one unusual point does
The eight blue dots below show a strong positive pattern. Pick one extra point to add (shown as an orange square) and watch r, r² and the slope. The changes show why outliers and influential points get their own exam questions.
No extra point: r = 0.959, r² = 0.920, slope = 1.298, intercept = 3.286.
What to notice: the middle outlier cuts r from 0.96 to 0.56 but leaves the slope where it was (it happens to sit at the mean of x, so it only lifts the line). The far point that follows the trend changes the slope only a little (1.30 to 1.42) and actually makes r stronger. The far point that breaks the trend drags the whole line down, and the slope falls from 1.30 to 0.14. That last one is an influential point.
Step 3 Fit: the least-squares line
The least-squares regression line is the line that makes the sum of the squared residuals as small as possible. Write it as
ŷ = b0 + b1x
where ŷ (“y-hat”) is the predicted y. You can get the slope and intercept from five summary numbers: x̄, ȳ, sx, sy and r.
b1 = r · (sy ⁄ sx)
b0 = ȳ − b1 x̄
Two facts fall out of these formulas. The slope always has the same sign as r. And the line always passes through the point (x̄, ȳ). Some books write the line as ŷ = a + bx. It’s the same line; only the letters change.
Step 4 Interpret the slope and intercept in context
A common exam mistake is leaving out the context or the word “predicted.”
| Number | Template | Quiz data (ŷ = 2.4 + 0.9x) |
|---|---|---|
| Slope b1 | For each additional 1 [unit of x], the predicted [y] increases (or decreases) by about b1 [units of y]. | Each extra hour of practice is associated with a predicted quiz score about 0.9 points higher. |
| Intercept b0 | When [x] is 0, the predicted [y] is b0 [units of y]. | A student who did no practice is predicted to score 2.4. Treat this with caution: nobody in the data did fewer than 1 hour. |
| r | There is a [strong/moderate/weak], [positive/negative] linear relationship between [x] and [y]. | r = 0.967: a strong, positive linear relationship. |
| r² | About [r²]% of the variation in [y] is explained by the linear relationship with [x]. | About 93.5% of the variation in quiz scores. |
When the intercept means nothing
The intercept is just where the line crosses x = 0. It only has a real meaning when x = 0 makes sense and is near the range of the data. Predicting adult weight from height gives an intercept for a person 0 inches tall. That number is needed to place the line, but it describes nobody. On an exam, “the intercept has no practical meaning here because x = 0 is outside the data (or impossible)” is a clear answer.
Step 5 Predict, and know when not to
To predict, plug an x value into the line. For a student with 6 hours of practice: ŷ = 2.4 + 0.9(6) = 2.4 + 5.4 = 7.8 points.
Extrapolation means predicting for an x outside the range of the data. The line was only checked on the x values you have, and nothing promises the pattern continues beyond them. For a student with 15 hours of practice, the line predicts 2.4 + 0.9(15) = 15.9 points, on a quiz that is out of 10. That impossible answer is the classic sign of extrapolation. Predictions inside the data range (here, 1 to 8 hours) are called interpolation and are much safer.
Step 6 Check: residuals and the residual plot
A residual is how far a point sits from the line, measured straight up or down:
residual = observed y − predicted y = y − ŷ
A positive residual means the point is above the line (the line under-predicted). A negative residual means the point is below the line (the line over-predicted). For the least-squares line, the residuals always add up to 0.
| Student | x | y | ŷ | Residual y − ŷ |
|---|---|---|---|---|
| A | 1 | 3 | 3.3 | −0.3 |
| B | 2 | 5 | 4.2 | 0.8 |
| C | 4 | 6 | 6.0 | 0.0 |
| D | 5 | 6 | 6.9 | −0.9 |
| E | 8 | 10 | 9.6 | 0.4 |
| Sum | 0.0 |
A residual plot puts x (or ŷ) on the horizontal axis and the residuals on the vertical axis, with a line at 0. Here is how to read one:
- Random scatter around 0, no pattern: a straight line is a good fit.
- A curve (U shape or arch): the relationship isn’t linear, so a straight line is the wrong model.
- A fan (spread grows or shrinks across the plot): the line’s predictions are much less reliable at one end. Many courses call this unequal (non-constant) variance.
- One point far from 0: an outlier in y.
Outliers vs influential points
These two get mixed up a lot. They are related but not the same.
| Term | What it means | In the tool above |
|---|---|---|
| Outlier | A point far from the overall pattern. In regression, usually a point with a large residual. | (4.5, 22): huge residual, slope unchanged, r drops a lot. |
| High-leverage point | A point with an x value far from the rest. It has the potential to move the line. | (16, 26) and (16, 6) both have far-out x values. |
| Influential point | A point that noticeably changes the slope (or intercept) when you remove it. | (16, 6): the slope falls from 1.30 to 0.14 when it is added. |
The practical test: fit the line with and without the point. If the slope changes a lot, the point is influential. Report both fits rather than quietly deleting the point.
Reading regression output from software or a calculator
Statistics software and graphing calculators print the same few numbers in slightly different layouts. Here is a typical table for n = 25 students, predicting exam score from hours of sleep the night before:
| Term | Coef | SE Coef | T | P |
|---|---|---|---|---|
| Constant | 41.60 | 8.95 | 4.65 | < 0.001 |
| Sleep (hours) | 4.20 | 1.25 | 3.36 | 0.003 |
R-sq = 32.9%
- Coef column: the intercept b0 (the “Constant” row) and the slope b1 (the row named after x). The line is ŷ = 41.60 + 4.20x.
- SE Coef: the standard error, roughly how much that estimate would vary from sample to sample.
- T: the estimate divided by its standard error. For the slope, t = 4.20 ⁄ 1.25 = 3.36.
- P: the p-value for testing whether that coefficient is 0. The slope row is the one you want: it tests H0: β1 = 0 (no linear relationship) against Ha: β1 ≠ 0, with n − 2 = 23 degrees of freedom.
- R-sq: r² as a percent. Here r = +√0.329 ≈ 0.574. The sign of r matches the slope, so r is positive.
The intercept row’s p-value tests whether the intercept is 0. That is rarely an interesting question, so intro courses usually ignore it. For more on reading the P column, see what a p-value means.
Worked examples
Example 1: The full routine from raw data
Problem. Use the quiz data above (x = 1, 2, 4, 5, 8 hours; y = 3, 5, 6, 6, 10 points). Find r, the least-squares line, and r², then predict the score for 6 hours of practice.
- Means: x̄ = (1 + 2 + 4 + 5 + 8) ⁄ 5 = 20 ⁄ 5 = 4. ȳ = (3 + 5 + 6 + 6 + 10) ⁄ 5 = 30 ⁄ 5 = 6.
- Deviations: x − x̄ = −3, −2, 0, 1, 4. y − ȳ = −3, −1, 0, 0, 4.
- Three sums: Σ(x − x̄)² = 9 + 4 + 0 + 1 + 16 = 30. Σ(y − ȳ)² = 9 + 1 + 0 + 0 + 16 = 26. Σ(x − x̄)(y − ȳ) = 9 + 2 + 0 + 0 + 16 = 27.
- Correlation: r = 27 ⁄ √(30 × 26) = 27 ⁄ √780 = 27 ⁄ 27.93 = 0.967.
- Slope: b1 = 27 ⁄ 30 = 0.9. (Check with the other formula: sx = √(30 ⁄ 4) = 2.739, sy = √(26 ⁄ 4) = 2.550, and r · sy ⁄ sx = 0.967 × 2.550 ⁄ 2.739 = 0.90.)
- Intercept: b0 = ȳ − b1x̄ = 6 − 0.9(4) = 2.4. So ŷ = 2.4 + 0.9x.
- r²: 0.967² = 0.935. (Exactly 27² ⁄ (30 × 26) = 729 ⁄ 780 = 0.9346.)
- Prediction: ŷ = 2.4 + 0.9(6) = 7.8 points. Six hours is inside the 1 to 8 hour range, so this is interpolation, not extrapolation.
Answer: r = 0.967, ŷ = 2.4 + 0.9x, r² ≈ 93.5%, and a predicted score of 7.8 for 6 hours.
Example 2: From summary statistics, with a residual
Problem. For 40 used cars of the same model, age x (years) has x̄ = 5 and sx = 2.5. Price y (thousands of dollars) has ȳ = 18 and sy = 6. The correlation is r = −0.85. Find the line, interpret the slope, and find the residual for a 4-year-old car that sold for $22,000.
- Slope: b1 = r · sy ⁄ sx = −0.85 × 6 ⁄ 2.5 = −0.85 × 2.4 = −2.04.
- Intercept: b0 = ȳ − b1x̄ = 18 − (−2.04)(5) = 18 + 10.2 = 28.2. So ŷ = 28.2 − 2.04x.
- Slope in context: each extra year of age is associated with a predicted price about $2,040 lower.
- r²: (−0.85)² = 0.7225, so about 72% of the variation in price is explained by the linear relationship with age.
- Predicted price at 4 years: ŷ = 28.2 − 2.04(4) = 28.2 − 8.16 = 20.04, or $20,040.
- Residual: y − ŷ = 22 − 20.04 = 1.96, or +$1,960. The car sold for about $1,960 more than the line predicts, so it sits above the line.
Extrapolation check: the line predicts 28.2 − 2.04(20) = −12.6 for a 20-year-old car, a negative price. If the data only go up to about 10 years, don’t use the line out there.
Example 3: Reading the output and testing the slope
Problem. Use the sleep and exam-score output above. Write the line, interpret the slope, test H0: β1 = 0 at α = 0.05, and say what r² means.
- Line: ŷ = 41.60 + 4.20x, where x is hours of sleep and ŷ is predicted exam score.
- Slope: each extra hour of sleep is associated with a predicted exam score about 4.2 points higher.
- Test statistic: t = b1 ⁄ SE = 4.20 ⁄ 1.25 = 3.36, with df = n − 2 = 23.
- p-value: the two-sided p-value is 0.003 (from the table, or from a t distribution with 23 df).
- Decision: 0.003 < 0.05, so reject H0. There is convincing evidence of a linear relationship between sleep and exam score in the population these students represent.
- r²: about 32.9% of the variation in exam scores is explained by the linear relationship with sleep. The other 67% comes from other things.
- Causation? No. This is observational data. Students who sleep more might also, say, manage their time better. That’s a possible lurking variable.
Example 4: Is that point influential?
Problem. Using the eight points in the tool (x = 1 to 8), a ninth point at (16, 6) is added. With it, ŷ = 7.961 + 0.141x and r = 0.193. Without it, ŷ = 3.286 + 1.298x and r = 0.959. Describe the point.
- Leverage: its x value, 16, is twice the largest of the other x values, so it has high leverage.
- Effect: adding it changes the slope from 1.298 to 0.141 and r from 0.959 to 0.193. That’s a big change, so it is influential.
- Residual: under the line fit without it, the point’s residual would be 6 − (3.286 + 1.298 × 16) = 6 − 24.05 = −18.05. It is far off the pattern, too.
- What to do: check it for a data-entry error. If it’s real, report both fits, and don’t claim the relationship is weak based on one point.
Practice: fifteen regression and correlation problems
Type an answer or pick an option, then press Check (or Enter in a number box). You’ll get feedback right away, and every problem has a full solution you can open. Round to the number of decimals each problem asks for; small rounding differences are accepted.
1. A study of college students finds r = −0.70 between weekly hours of screen time and GPA. What percent of the variation in GPA is explained by the linear relationship with screen time? Type a percent, like 25 for 25%.
Show solution 1
49%. r² = (−0.70)² = 0.49. The negative sign tells you the direction (more screen time, lower GPA) but disappears when you square. r² is always between 0 and 1.
2. For 30 students, hours studied (x) has x̄ = 6 and sx = 3.5. Exam score (y) has ȳ = 72 and sy = 11.2. The correlation is r = 0.62. Find the slope b1 of the least-squares line. Round to 3 decimal places.
Show solution 2
b1 = 1.984. b1 = r · sy ⁄ sx = 0.62 × (11.2 ⁄ 3.5) = 0.62 × 3.2 = 1.984. Each extra hour of study is associated with a predicted score about 1.98 points higher.
3. For 30 students, hours studied (x) has x̄ = 6 and sx = 3.5. Exam score (y) has ȳ = 72 and sy = 11.2. The correlation is r = 0.62. Using your slope from the last problem, find the intercept b0. Round to 2 decimal places.
Show solution 3
b0 ≈ 60.10. b0 = ȳ − b1x̄ = 72 − 1.984(6) = 72 − 11.904 = 60.096. The line is ŷ = 60.10 + 1.984x. (If you rounded the slope to 1.98 first you get 60.12, which is also accepted.)
4. Same students: ŷ = 60.10 + 1.984x. Predict the exam score for a student who studied 8 hours. Round to 1 decimal place.
Show solution 4
About 76.0 points. ŷ = 60.10 + 1.984(8) = 60.10 + 15.87 = 75.97. Eight hours is two hours above x̄, so the prediction is about 2 × 1.984 ≈ 4 points above ȳ = 72.
5. A beach stand records the daily high temperature x (°F) and the number of ice cream cones sold y on 40 summer days. Temperatures ranged from 60 °F to 95 °F. The least-squares line is ŷ = −150 + 6.4x. Which is the correct interpretation of the slope?
Show solution 5
Answer: C. Slope = (change in predicted y) per 1 unit of x, in context and with units: about 6.4 more cones predicted for each 1 °F warmer.
6. Same stand: ŷ = −150 + 6.4x, with temperatures from 60 °F to 95 °F. What does the intercept −150 tell you?
Show solution 6
Answer: B. The intercept is the prediction at x = 0. Here that is far outside the observed temperatures (extrapolation), and −150 cones is impossible. Saying so, with the reason, is the full-credit answer.
7. For 120 teenagers, the correlation between daily hours of screen time and nightly hours of sleep is r = −0.82. Which statement is correct?
Show solution 7
Answer: D. The size of r (0.82) says strong; the sign says negative. It doesn’t give a percent (that’s r² ≈ 67%) and it doesn’t prove causation.
8. For apartments in one city, ŷ = 350 + 1.10x, where x is size (square feet) and ŷ is predicted monthly rent in dollars. An 800-square-foot apartment rents for $1,200. What is its residual, in dollars?
Show solution 8
Residual = −$30. ŷ = 350 + 1.10(800) = 350 + 880 = $1,230. Residual = y − ŷ = 1,200 − 1,230 = −30. A negative residual means the line over-predicted: this apartment rents for $30 less than the line predicts for its size, so it sits just below the line.
9. Three residual plots from three different data sets are shown below (each is described in text under it). Which one supports using a straight-line model?
Show solution 9
Answer: Plot A. A good residual plot looks like a shapeless band around 0. Plot B’s curve says the relationship isn’t linear. Plot C’s fan says the spread changes with x.
10. Look again at Plot C (the fan shape). What does it tell you about the linear model?
Show solution 10
Answer: B. A fan means unequal (non-constant) spread. The line may still describe the trend, but predictions at the wide end are much less precise, and the usual t test for the slope assumes even spread.
11. A model built from children aged 3 to 10 predicts height (cm) = 80 + 6.0 × age (years). Using it, a 30-year-old would be predicted to be 260 cm tall. What went wrong?
Show solution 11
Answer: C. The line was fit on ages 3 to 10 only. There is no reason to think it holds at 30, and it clearly doesn’t. Only predict inside (or very near) the range of x values you have.
12. Across 50 cities, the number of public libraries and the number of crimes reported each year have r = 0.91. A council member says building libraries causes crime. What is the best response?
Show solution 12
Answer: D. Population drives both variables. Dividing by population (libraries per person, crimes per person) would be a better comparison. Even then, observational data can’t prove causation.
13. In a data set of 30 points, removing one point with an unusually large x value changes the slope of the least-squares line from 2.1 to 0.4. How is that point best described?
Show solution 13
Answer: B. Its x value is far from the rest (high leverage), and it changes the slope a lot (influential). Check it for errors, and report the fit with and without it.
14. Use the regression output below. Compute the t statistic for testing H0: β1 = 0 (the “?” in the table). Round to 2 decimal places.
| Term | Coef | SE Coef | T | P |
|---|---|---|---|---|
| Constant | 5.10 | 1.40 | 3.64 | 0.002 |
| Advertising | 0.84 | 0.30 | ? | 0.012 |
Show solution 14
t = 2.80. t = b1 ⁄ SE(b1) = 0.84 ⁄ 0.30 = 2.80, on n − 2 = 20 − 2 = 18 df. The two-sided p-value for t = 2.80 with 18 df is about 0.012, matching the table.
15. Same output: the slope row has P = 0.012. At α = 0.05, what is the right conclusion?
Show solution 15
Answer: C. p = 0.012 < 0.05, so reject H0. That is evidence of a linear relationship, not proof that advertising causes sales: these are observational days unless spending was randomly assigned.
Score: 0 of 15 correct.
Frequently asked questions
What is the difference between correlation and regression?
Correlation (r) is one number that measures the direction and strength of a linear relationship between two quantitative variables. Regression goes further: it fits a line, ŷ = b₀ + b₁x, that you can use to describe how y changes with x and to make predictions. The slope and r always have the same sign.
How do you find the slope of the regression line from r?
Multiply r by the ratio of the standard deviations: b₁ = r × (sy ⁄ sx), where sx and sy are the standard deviations of x and y. Then find the intercept with b₀ = ȳ − b₁x̄. For example, r = 0.62, sx = 3.5 and sy = 11.2 give b1 = 0.62 × 3.2 = 1.984.
What does r squared mean?
r squared (the coefficient of determination) is the fraction of the variation in y that is explained by the linear relationship with x. If r = −0.70, then r² = 0.49, so about 49% of the variation in y is explained by the line. It is never negative and does not show direction.
What is a residual in statistics?
A residual is observed y minus predicted y (y − ŷ). A positive residual means the point is above the regression line, and a negative residual means it is below. For the least-squares line, the residuals add up to zero.
What is the difference between an outlier and an influential point?
An outlier is a point far from the overall pattern, usually with a large residual. An influential point is one that noticeably changes the slope or intercept when you remove it. Influential points usually have x values far from the rest of the data (high leverage). A point can be one without being the other.
Why is extrapolation dangerous?
The regression line is only supported by the range of x values in the data. Outside that range the pattern may bend or stop, so predictions can be badly wrong or even impossible, like a negative price or a quiz score above the maximum.
Does a strong correlation mean one variable causes the other?
No. With observational data, a strong correlation can come from a lurking variable that affects both, from chance, or from cause running the other way. A well-designed randomized experiment can give strong evidence of cause and effect.
Keep practicing
Try 3 days free3-day free trial, no card needed.
Related guides
Sources and fact checks
Definitions, formulas and interpretation rules were checked against these references. Every number on this page was recomputed in code: means, sums of squares, r, the slopes and intercepts, residuals, and the t-test p-values from the t distribution. All data sets are made up for teaching.
- OpenStax Introductory Statistics 2e, Chapter 12: Linear Regression and Correlation
- OpenStax 12.2: Scatter plots
- OpenStax 12.3: The regression equation (least squares, r, r²)
- OpenStax 12.4: Testing the significance of the correlation coefficient
- OpenStax 12.5: Prediction (and the danger of extrapolation)
- OpenStax 12.6: Outliers