QUANTITATIVE ANALYSIS · BEGINNER GUIDE
Simple Linear Regression by Hand: A Small Example
Calculate the slope and intercept for a tiny dataset, then check what the fitted line can and cannot tell you.
Quick answer: In simple linear regression, the least-squares slope is the covariance of x and y divided by the variance of x. The intercept makes the line pass through the sample means. The fitted line summarizes a pattern; it does not prove cause.
What this method answers
The line is ŷ=b₀+b₁x. Least squares chooses b₀ and b₁ to minimize squared residuals. With few observations, one unusual point can strongly change the result.
Use the hand calculation to understand a basic two-variable fit. For real work, use software and inspect residuals, uncertainty, influential observations and the sampling design.
Before running a calculation, write down the population and the exact quantity you want to estimate. A method name alone does not define the question, the comparison or the assumptions.
Steps to follow
- Plot x against y and inspect whether a line is sensible.
- Calculate x̄ and ȳ from the training observations.
- Estimate slope and intercept using least squares.
- Check residuals and avoid unsupported extrapolation.
Keep a record of exclusions, recoding decisions and software settings. That makes the analysis easier to check and repeat.
Worked example
A tutor records study hours and a short quiz score for three learners. The values are invented for arithmetic practice.
| Hours x | Score y |
|---|---|
| 1 | 50 |
| 2 | 60 |
| 3 | 70 |
The means are x̄=2 and ȳ=60. The slope is 10 points per hour in this straight toy sample. The intercept is b₀=ȳ−b₁x̄=60−20=40, so ŷ=40+10x.
Interpret the result carefully
At 2 hours, ŷ=60. The line matches all three constructed points exactly. That perfect fit is a feature of this tiny example, not proof that study time determines scores.
Limit to keep in mind: The arithmetic omits uncertainty, measurement error, nonlinear patterns and confounding. Predictions outside observed hours may be misleading.
When reporting an analysis, include the sample size, estimate, units and uncertainty. Explain why the method fits the sampling and measurement design. Separate planned tests from exploratory checks, and avoid saying that association proves a cause.
Frequently asked questions
Why is the intercept 40?
It is the predicted score at zero study hours; that may not be meaningful.
Does this prove each hour adds 10 points?
No. The example has three invented values and cannot establish cause.
What is a residual?
Observed y minus fitted prediction ŷ for a case.
Does a high R² guarantee good predictions?
No. Validate on representative held-out data.