BUS 110 · Business Math and Statistics for Accountants
Correlation and Regression
Measure how two quantities move together, fit a least squares line by hand, read r and r-squared and avoid mistaking correlation for cause.
Key takeaways
- A scatter plot is the first step, because it shows the direction, strength and shape of a relationship.
- The correlation r runs from −1 to 1 and measures how closely points follow a straight line.
- Least squares regression picks the line that makes the sum of squared prediction errors as small as possible.
- The slope is the predicted change in y for each one-unit increase in x.
- Correlation alone does not show that one thing causes the other.
Omar runs a small candle workshop, and his electricity bill keeps surprising him. Some months it is modest. Other months it makes him wince. He has a hunch that the bill follows the number of hours his wax melters run. Next month he plans 700 machine hours. What should he budget for power?
A hunch is a start. A line drawn through real data is better. In this lesson you will measure how tightly two quantities move together, and then build an equation that predicts one from the other. Those two skills are correlation and regression.
Accountants use them to split costs into fixed and variable parts, to forecast sales and to spot numbers that look out of line.
Look first: the scatter plot
Omar gathers five months of records. Let x be machine hours in hundreds, and y the electricity bill in thousands of dollars. (A real study should use more months. Five keeps the arithmetic visible.)
| Month | x (hundreds of hours) | y (bill, $ thousands) |
|---|---|---|
| 1 | 2 | 5 |
| 2 | 4 | 7 |
| 3 | 6 | 8 |
| 4 | 8 | 11 |
| 5 | 10 | 14 |
The variable you use to predict, x, is the explanatory or independent variable. The one you want to predict, y, is the dependent variable.
Plot them. The points rise from left to right in a fairly straight path. That is a positive relationship. Falling points would be negative. A shapeless cloud would suggest little linear connection. A curve would warn you that a straight line is the wrong tool.
Dots are actual months. The line is y = 2.4 + 1.1x, built in the worked example below.
Correlation: one number for "how tight"
The correlation coefficient, r, measures the strength and direction of a straight-line relationship.
- r = 1: every point sits exactly on a rising line.
- r = −1: every point sits exactly on a falling line.
- r = 0: no straight-line tendency.
It has no units, so changing from dollars to thousands of dollars leaves r alone. It also does not tell you how steep the line is. A gentle slope with tight points can have a higher r than a steep slope with scattered ones.
Worked example: fitting the line
We want the line y = a + bx. Here a is the intercept, the predicted y when x is 0, and b is the slope. If lines feel rusty, revisit linear equations and cost lines.
Step 1: find the means. The x values total 30, so the mean is 6. The y values total 45, so the mean is 9.
Step 2: measure each distance from the means, then multiply and square.
| x − 6 | y − 9 | Product | (x − 6)² | (y − 9)² |
|---|---|---|---|---|
| −4 | −4 | 16 | 16 | 16 |
| −2 | −2 | 4 | 4 | 4 |
| 0 | −1 | 0 | 0 | 1 |
| 2 | 2 | 4 | 4 | 4 |
| 4 | 5 | 20 | 16 | 25 |
| Total | 44 | 40 | 50 |
Step 3: compute the slope and intercept.
b = sum of products ÷ sum of (x − mean)² = 44 ÷ 40 = 1.1
a = mean of y − b × mean of x = 9 − 1.1 × 6 = 2.4 The line is y = 2.4 + 1.1x.
Step 4: compute r.
r = 44 ÷ √(40 × 50) = 44 ÷ √2000 = 44 ÷ 44.72 ≈ 0.984 That is a very strong positive correlation.
Step 5: translate into dollars. Each extra 100 machine hours adds a predicted 1.1 thousand dollars, or $1,100. That is $11 per machine hour. The intercept, $2,400, estimates the monthly cost that would remain with the melters idle: lights, office equipment and base charges.
Step 6: predict. For 700 hours, x = 7.
y = 2.4 + 1.1 × 7 = 10.1, or $10,100.
Residuals: how wrong was the line?
A residual is the actual value minus the predicted value.
| x | Actual y | Predicted y | Residual |
|---|---|---|---|
| 2 | 5 | 4.6 | 0.4 |
| 4 | 7 | 6.8 | 0.2 |
| 6 | 8 | 9.0 | −1.0 |
| 8 | 11 | 11.2 | −0.2 |
| 10 | 14 | 13.4 | 0.6 |
The residuals add to zero, as they always do for a least squares line with an intercept. Their squares are 0.16, 0.04, 1.00, 0.04 and 0.36, totaling 1.6. Least squares means no other straight line gives a smaller total than 1.6 for these points.
R-squared: how much is explained
Without knowing hours, your best guess for any month would be the average bill, 9. The squared misses from that guess total 50. With the line, they total only 1.6.
R² = 1 − 1.6 ÷ 50 = 0.968
About 97% of the variation in these bills is accounted for by the straight-line relationship with hours. For a one-variable line, R² is just r squared: 0.984² ≈ 0.968.
At 700 hours: $2,400 + $7,700 = $10,100.
This split is exactly what managers need for cost behavior and budgets. Spreadsheets compute it with functions such as SLOPE, INTERCEPT, CORREL and RSQ. Cost accounting goes further in estimating cost behavior with data.
A worked check: what the line says about next quarter
Omar's landlord now offers a flat power deal: $9,500 a month, whatever the hours. Should he take it? The line can help, as long as you read it with care.
At 600 hours, the predicted bill is 2.4 + 1.1 × 6 = 9.0, or $9,000. The flat deal would cost $500 more. At 700 hours, the prediction is $10,100, so the flat deal would save $600. The crossover is where the two costs match.
2,400 + 11 × hours = 9,500
11 × hours = 7,100
hours ≈ 645 Above about 645 hours, the line favors the flat price. Below it, paying by use looks cheaper. But remember the residuals. One of the five months missed by $1,000, which is larger than either gap just computed. Omar should look at his expected hours over a whole year, not one month, and ask for more history before signing anything long.
A rough measure of the typical miss is the standard error of the estimate. Divide the sum of squared residuals by n − 2, because two numbers (a and b) were estimated from the data, and take the square root.
√(1.6 ÷ (5 − 2)) = √0.533 ≈ 0.73, or about $730 So a prediction of $10,100 should be read as "around ten thousand, give or take many hundreds." With only five months, the real uncertainty is wider still.
More than one driver
Power bills might depend on machine hours and on how cold the month was. Multiple regression fits an equation with several explanatory variables at once, such as y = a + b₁ × hours + b₂ × cold days. Each slope then estimates the effect of one variable while the others are held steady.
This helps untangle mixed influences, but it is no magic wand. Each added variable needs more data. Adding variables almost never lowers R², even when they are nonsense, so a high R² with a long list of drivers and a short history means little. Variables that move closely together, such as machine hours and labor hours in a small shop, make the separate slopes unstable.
Stay inside the fence
Omar's data cover 200 to 1,000 hours. Predicting within that range is interpolation. Predicting far outside it, say 3,000 hours, is extrapolation, and it is risky. A second melter, a different rate tier or overtime shifts could change the pattern entirely. The intercept is also an extrapolation here, since no month had zero hours. Treat the $2,400 as an estimate, not a fact about an idle workshop.
One unusual point can also drag a line. Imagine a month when a faulty heater ran all night. Check outliers against the story behind them before deciding what to do, and report any point you leave out.
Reading a scatter plot like an accountant
Before you trust any fitted line, check four things on the picture.
Shape. Do the points hug a straight path, or do they bend? If costs climb slowly and then jump when a second shift starts, one line misses the story. Fit separate lines for separate ranges, or use a curve.
Spread that changes. If the points are tight at low hours and fan out at high hours, predictions are shakier at the high end. The single "give or take" figure above hides that.
Odd points. A point far from the pack can tilt the line a lot, especially when it sits at the far left or right. Find out what happened that month.
Clusters. Two separate clumps can create a high correlation that vanishes inside each clump. Suppose Omar's summer months all sit at low hours and cheap power, and winter months at high hours and expensive power. The line may mostly be separating seasons.
A careful analyst writes the finding in a sentence: "Over 200 to 1,000 machine hours, each extra 100 hours was associated with about $1,100 more in electricity, and the line fit five months closely." The words "associated with" are chosen on purpose. They report the pattern without claiming a mechanism.
Accountants and the high-low shortcut
Cost accountants sometimes use a quick two-point method before they fit a full line. Take the highest and lowest activity months and divide the change in cost by the change in activity. For Omar, the extremes are 200 and 1,000 hours with bills of $5,000 and $14,000.
Variable cost per hour = (14,000 − 5,000) ÷ (1,000 − 200) = 9,000 ÷ 800 = $11.25
Fixed cost = 5,000 − 11.25 × 200 = $2,750 That is close to the least squares answer of $11 per hour and $2,400 fixed, and it took thirty seconds. But it ignores the three middle months entirely. If either extreme month was strange, the answer is off. Least squares uses every point, which is why it is usually preferred when you have the data and a spreadsheet.
The common mistake: correlation is not cause
Ice cream sales and sunburns tend to rise together. Ice cream does not burn anyone. Warm sunny weather drives both. A hidden third factor like that is a confounding variable.
When two things correlate, consider several explanations.
- x causes y.
- y causes x. Higher sales may lead to more advertising, not the reverse.
- A third factor drives both.
- It is coincidence, especially with few points or after searching many pairs.
For Omar, a physical reason supports the link: melters draw power while they run. Yet winter might raise both orders and heating costs, which would inflate the slope. Plotting bills by season would help check. A controlled change, assigned deliberately or at random, is far stronger evidence of cause than a pattern spotted afterward. Whether a slope differs reliably from zero is a question for the tools in testing a claim with data.
Words to know
Correlation coefficient a number from −1 to 1 measuring the strength and direction of a linear relationship.
Regression line an equation fitted to data to predict one variable from another.
Slope the predicted change in y for a one-unit increase in x.
Standard error of the estimate a measure of the typical size of the residuals around the fitted line.
Residual the actual value minus the value the line predicts.
R-squared the share of variation in y accounted for by the fitted relationship.
Extrapolation predicting beyond the range of the data used to fit the line.
Confounding variable a hidden factor that influences both variables.
Check yourself
- What does r = −0.9 tell you about two variables?
- For the line y = 500 + 8x, predict y when x = 250 and explain what 8 means.
- Using Omar's line, predict the bill for 500 machine hours.
- A month has 800 hours and an actual bill of $11,500. What is the residual under Omar's line?
- If r = 0.7, what is R², and what does it mean?
- Why might a strong correlation between advertising and sales not prove that advertising raised sales?
Show the answers
- A strong negative linear relationship: as one variable rises, the other tends to fall.
- y = 500 + 8 × 250 = 2,500; each one-unit increase in x adds a predicted 8 to y.
- x = 5, so y = 2.4 + 1.1 × 5 = 7.9, or $7,900.
- The prediction at x = 8 is $11,200, so the residual is 11,500 − 11,200 = $300.
- R² = 0.49, meaning about 49% of the variation in y is accounted for by the straight-line relationship.
- Higher sales may lead to bigger ad budgets, a third factor such as the holiday season may drive both, or it may be chance.