Multiple regression analysis explained, with an example
Regression analysis fits an equation that predicts a response, such as surface roughness, from one or more predictors, such as feed rate and cutting speed. Each coefficient tells you how much the response changes when one predictor moves by one unit and the others stay put, and its p-value tells you whether that change is distinguishable from noise. With more than one predictor it is called multiple regression.
When to use it
- You want to know which process settings drive a quality characteristic, and by how much.
- You need a prediction equation, for example to choose settings that hit a target or to estimate a value you cannot measure directly.
- You have historical data with several candidate inputs and want to separate their effects, which separate scatterplots cannot do.
- You ran a designed experiment and want a model for the response optimizer.
For one predictor, the fitted line plot shows the same fit as a picture. For categorical factors with unbalanced data, see the general linear model.
How it works
The model says the response is a constant plus a weighted sum of the predictors plus random error:
y = β₀ + β₁x₁ + β₂x₂ + … + βₖxₖ + εLeast squares chooses the coefficients b₀ to bₖ that make the sum of squared residuals (observed minus fitted) as small as possible. In matrix form, with X holding a column of ones and one column per predictor:
b = (XᵀX)⁻¹ XᵀyFrom the residuals you get the error sum of squares SSE, with n − p degrees of freedom (n rows, p coefficients including the constant). Everything else follows:
- S, the standard deviation of the residuals, is √(SSE / (n − p)). It is the typical prediction error, in the response's units.
- SE Coef is each coefficient's standard error; T = Coef / SE Coef, and the p-value comes from the t distribution with n − p degrees of freedom.
- R² is the share of the variation explained, and R²(adj) penalizes extra terms:
R² = 1 − SSE/SST R²(adj) = 1 − (SSE/(n − p)) / (SST/(n − 1))- The ANOVA table tests all predictors at once: F = (SSR / (p − 1)) / (SSE / (n − p)).
- VIF (variance inflation factor) shows how much correlation between predictors inflates each standard error. Values near 1 are ideal; above 5 to 10, the coefficients become unstable.
To choose which terms to keep, stepwise methods add or remove one term at a time, either by p-value (a common choice is α = 0.15 to enter and to remove) or by an information criterion. This article uses these forms, which drop a constant that cancels when you compare models fitted to the same data:
AICc = n·ln(SSE/n) + 2p + 2p(p + 1)/(n − p − 1) BIC = n·ln(SSE/n) + p·ln(n)Lower is better. BIC penalizes extra terms more than AICc, so it tends to pick smaller models. To compare every possible model at once, use best subsets.
Example
A turning cell wants to predict surface roughness Ra (µm) on a shaft. An engineer runs 18 parts at different feed rates (mm/rev), cutting speeds (m/min) and coolant concentrations (%):
| Run | Feed | Speed | Coolant | Ra | Run | Feed | Speed | Coolant | Ra |
|---|---|---|---|---|---|---|---|---|---|
| 1 | 0.10 | 150 | 4 | 0.93 | 10 | 0.30 | 250 | 6 | 2.32 |
| 2 | 0.15 | 200 | 6 | 1.28 | 11 | 0.10 | 150 | 8 | 0.99 |
| 3 | 0.20 | 250 | 8 | 1.56 | 12 | 0.15 | 200 | 4 | 1.28 |
| 4 | 0.25 | 150 | 6 | 2.05 | 13 | 0.20 | 250 | 6 | 1.58 |
| 5 | 0.30 | 200 | 8 | 2.42 | 14 | 0.25 | 150 | 8 | 2.06 |
| 6 | 0.10 | 250 | 4 | 0.68 | 15 | 0.30 | 200 | 4 | 2.44 |
| 7 | 0.15 | 200 | 8 | 1.27 | 16 | 0.15 | 150 | 6 | 1.40 |
| 8 | 0.20 | 250 | 4 | 1.69 | 17 | 0.20 | 200 | 4 | 1.53 |
| 9 | 0.25 | 150 | 6 | 2.09 | 18 | 0.25 | 250 | 8 | 1.94 |
The model with all three predictors:
| Term | Coef | SE Coef | T | P | VIF |
|---|---|---|---|---|---|
| Constant | 0.3833 | 0.0976 | 3.93 | 0.002 | |
| Feed | 7.666 | 0.229 | 33.41 | < 0.001 | 1.08 |
| Speed | −0.001488 | 0.000368 | −4.04 | 0.001 | 1.04 |
| Coolant | 0.0034 | 0.0093 | 0.37 | 0.717 | 1.06 |
S = 0.0626 µm, R² = 98.83%, R²(adj) = 98.58%.
| Source | DF | SS | MS | F | P |
|---|---|---|---|---|---|
| Regression | 3 | 4.6195 | 1.5398 | 393.46 | < 0.001 |
| Error | 14 | 0.0548 | 0.00391 | ||
| Total | 17 | 4.6743 |
Coolant has a p-value of 0.717: within this range it adds nothing you can detect. Removing it gives:
Ra = 0.4034 + 7.685·Feed − 0.001505·Speedwith S = 0.0607 µm, R² = 98.82% and R²(adj) = 98.66%. Both criteria prefer the smaller model: AICc falls from −93.23 to −96.41 and BIC from −92.74 to −95.46. For a part cut at 0.20 mm/rev and 200 m/min, the model predicts Ra = 1.639 µm, with a 95% prediction interval of 1.506 to 1.772 µm for a single part.
How to read the results
- Coefficients are rates. Feed's 7.685 means each extra 0.01 mm/rev adds about 0.077 µm of Ra. Speed's −0.001505 means 100 m/min faster lowers Ra by about 0.15 µm. Compare predictors by their effect over the range you use, not by raw coefficient size.
- The p-value tests one term, given the others. A large p-value means the data cannot separate that term's effect from zero, given the others; it does not mean the input never matters.
- S beats R² for practical use. R² near 99% sounds impressive; S = 0.06 µm tells you how far a prediction is likely to miss.
- Check the residuals. The residuals-versus-fits plot should show a shapeless band around zero. Here two of 18 standardized residuals are slightly beyond ±2 (runs 6 and 8, at −2.28 and 2.23), about what chance produces. A curve means a missing term (such as Feed²); a funnel means the spread changes with the level. Also look at a normal probability plot of the residuals and at their order in time.
- Prediction interval versus confidence interval. The confidence interval for the mean Ra at these settings (1.609 to 1.670 µm) is much narrower than the prediction interval for one part. Use the prediction interval when you compare against a specification.
Common mistakes
- Extrapolating. The equation holds only inside the region you tested. At 0.40 mm/rev it may be badly wrong.
- Reading cause from happenstance data. Historical data can link a predictor to the response because both follow a third variable. A designed experiment settles cause.
- Ignoring correlated predictors. With high VIFs, coefficients can flip sign from one sample to the next. Remove one of the related predictors, or use partial least squares.
- Dropping terms by p-value alone. Keep a term that physics or a hierarchy (a squared term needs its linear term) says belongs.
- Skipping the residual plots. A high R² does not show that the model's form is right.
Frequently asked questions
What is a good R² value?
It depends on the process and measurement noise. Compare S with the tolerance or the gage repeatability instead: a model cannot predict better than the gage measures.
What is the difference between R², adjusted R² and predicted R²?
R² never falls when you add a term. Adjusted R² falls when a term adds less than its cost in degrees of freedom. Predicted R² refits the model with each row left out and checks how well it predicts that row (98.22% here), so it exposes overfitting best.
Should I use stepwise, AICc or BIC?
All three are aids, not answers. Stepwise by p-value is simple but can miss good combinations. AICc favors prediction; BIC favors a smaller model. When they disagree, prefer the model that makes engineering sense and validate it on new data.
How many data points do I need?
A rough rule is 10 to 15 rows per estimated term, more when the noise is large. Spread the predictors over the range of interest.