Linear regression calculator with steps: the default example
The workspace starts with eight students' study hours and quiz scores: , , , , , , , and . The least-squares line minimises the sum of squared vertical distances from the points to the line. Its slope and intercept come from
Here , , , and , so
The fitted model is . In context: each extra hour of study is associated with about 4.48 more quiz points on average, and a student who studies 0 hours would be predicted to score about 46.9 — an intercept that is outside the data and should be interpreted cautiously. Note that the line passes through ; that is always true for least squares.
Fit LinReg(ax+b) to the points (1, 3), (2, 5), (3, 6), (4, 9) and (5, 11). Use the line to predict ŷ at x = 7.
STAT → 1: Edit, x in L1 and y in L2, then STAT → CALC → 4: LinReg(ax+b). Evaluate a · 7 + b.
Simple linear regression model: formula, slope and y-intercept
A simple linear regression model has one independent variable x (the predictor) and one dependent variable y (the response): ŷ = a + bx. The calculator on this page finds a and b by ordinary least squares, minimizing the sum of the squared residuals Σ(y − ŷ)². That gives the linear regression formula:
- slope: b = r · sy / sx
- y-intercept: a = ȳ − b · x̄
Here r is the correlation and sx, sy are the standard deviations of the x and y values. Watch the naming: the 84-series LinReg(ax+b) writes the line as y = ax + b, so its a is the slope, while LinReg(a+bx) uses the textbook order. The results of the regression are the same line either way.
To calculate the linear regression by hand for (1, 2), (2, 4), (3, 5), (4, 4), (5, 6): x̄ = 3 and ȳ = 4.2, Σ(x − x̄)(y − ȳ) = 8 and Σ(x − x̄)² = 10, so b = 0.8 and a = 4.2 − 0.8 · 3 = 1.8. The least squares regression line is ŷ = 1.8 + 0.8x. A linear regression prediction at x = 6 is 1.8 + 4.8 = 6.6, an estimate of the value of y that is also an extrapolation, because 6 lies outside the data.
For inference on the slope, the standard error uses n − 2 degrees of freedom (here 3), because two parameters were estimated. The model assumes the observations are independent of one another, with residuals that are roughly normal and have constant spread.
Linear regression analysis vs multiple regression
This is a simple linear regression calculator: one predictor. Multiple regression models y with several predictors (ŷ = b₀ + b₁x₁ + b₂x₂ + …) and needs statistical software or a spreadsheet; any multiple regression calculator also has to watch for predictors that are highly correlated with each other, which makes individual slopes unstable. Logistic regression is different again: it is used when the response is a yes/no outcome rather than a number. For a response variable based on one numeric x, find the linear regression here and then check the residual plot.
Residual plot: the check most people skip
A high does not mean a line is the right model. Plot residuals against :
| x | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|---|---|---|---|---|---|---|---|---|
| y | 52 | 55 | 61 | 64 | 70 | 72 | 79 | 83 |
| ŷ | 51.333 | 55.810 | 60.286 | 64.762 | 69.238 | 73.714 | 78.190 | 82.667 |
| e | 0.667 | −0.810 | 0.714 | −0.762 | 0.762 | −1.714 | 0.810 | 0.333 |
The residuals bounce above and below zero with no curve and no widening spread, so a linear model is appropriate. Three patterns should make you stop:
- A curve (U or arch): the relationship is not linear; try QuadReg or a transformation.
- Fanning: residuals spread out as grows, so predictions are less reliable for large . This is common with incomes and populations.
- One huge residual: an outlier; check it for a data-entry error before removing anything.
Self-check: r ≈ 0.9789 looks strong, yet the residuals form a U — switch the model to quadratic.
The standard deviation of the residuals, , says a typical prediction misses by about one point.
1-Var statistics for the same data
Before fitting any model, summarise each variable. For the eight quiz scores, 1-Var Stats returns:
| Output | Value | Meaning |
|---|---|---|
| 67 | Mean | |
| Σx, Σx² | 536, 36 760 | Sum and sum of squares |
| Sx | 11.0065 | Sample standard deviation (divides by ) |
| σx | 10.2956 | Population standard deviation (divides by ) |
| n | 8 | Count |
| minX, Q1, Med, Q3, maxX | 52, 58, 67, 75.5, 83 | Five-number summary (median of each half) |
Use Sx for a sample (almost every class problem); use σx only when the list is the entire population. Mixing them up is one of the most common lost points in statistics homework.
Self-check: x̄ = 67, Sx ≈ 11.0065, σx ≈ 10.2956 and Med = 67.
Keystroke reference: STAT → CALC workflow
| Task | TI-84 style key sequence | GraphingCalc84 |
|---|---|---|
| Enter data | STAT → 1: Edit → L1, L2 | Paste x, y pairs, one per line |
| Summary stats | STAT → CALC → 1: 1-Var Stats | Summary panel |
| Linear fit | STAT → CALC → 4: LinReg(ax+b) | Model: LinReg (ax+b) |
| Quadratic fit | STAT → CALC → 5: QuadReg | Model: QuadReg |
| Exponential fit | STAT → CALC → 0: ExpReg | Model: ExpReg |
| Show r and r² | STAT DIAGNOSTICS: ON | Always shown |
| Residual plot | 2ND Y= → Plot2, Ylist: RESID | Residual plot toggle |
A frequent handheld error is ERR: DIM MISMATCH, which means L1 and L2 have different lengths — usually one value was skipped or typed twice. Pasted data here is parsed in pairs, so a line missing its y-value is flagged instead.
Correlation is not causation, and r is not everything
A strong correlation between study time and scores is plausible, but the data cannot rule out a lurking variable such as prior grade or interest in the subject. Only a randomized experiment supports a causal claim. Also remember that measures linear association only: data lying perfectly on the parabola for has . The NIST/SEMATECH e-Handbook of Statistical Methods has an excellent chapter on regression diagnostics, including residual analysis.
Next steps
If you are preparing for the AP exam, the AP Statistics calculator toolkit covers LinRegTTest, confidence intervals and how to report calculator output on free-response questions. To find probabilities rather than fit lines, use the normal distribution calculator.
Exponential regression in one paragraph
ExpReg fits by running a linear regression on and transforming back, so every y-value must be positive. The base is the growth factor per unit of : means an 8% increase per step, and a 10% decrease. Judge the fit with a residual plot on the original scale, exactly as for a line.