Regression analysis

Intermediate

What you need first. Nothing else on this path comes first. This page is part of Statistical inference.

In regression, regression analysis is the estimation of how a response moves with one or more predictors, together with the reliability of that estimate. Regression analysis estimates how a response moves with one or more predictors, and it attaches a measure of reliability to that estimate and to the predictions that follow from it.

The estimated variable is the response, often written YY. The variables used to explain it are the predictors, often written XX. The estimate is a mathematical relation fitted to a sample. The reliability is a separate question: how far that relation would move if the sample were drawn again, and how far a new response could sit from the fitted value. The relation by itself does not answer the reliability question, and a reliable fit inside the observed range of the predictors does not, by the algebra alone, say what would happen if a predictor were set to a new value by an intervention.[1][2]

Regression analysis

Regression analysis
Fact Value
Topic Statistical inference
Listed on Statistical inference
Worked example 1

Motivating example

A product’s sales are recorded against the budgets spent on television, radio, and newspapers. A consultant is asked what marketing plan would raise sales next year. Before any coefficient is quoted, the data have to answer a short list of questions. Is there an association between budget and sales at all? If the evidence is weak, spending more is not supported by these records. If there is an association, how tight is the prediction: given a budget, are sales predictable, or only slightly better than a guess? Which of the three media contribute, once money has been spent on all three? How precisely is each medium’s contribution estimated? How precisely can a future sales figure be predicted? Is a straight line enough, or does the relation bend? Do the media interact, so that money split across television and radio sells more than the same money spent on one of them? Linear regression is the tool James, Witten, Hastie, and Tibshirani use to organise those questions. The fitted line, or the fitted plane, is the estimate. The standard errors, the residual scale, and the checks on the shape of the residuals are the reliability.[2]

A smaller version of the same problem uses one predictor and three points, so that every sum can be written by hand. The inputs are x=0,1,2x=0, 1, 2 and the responses are y=1,3,3y=1, 3, 3. A line is wanted for how yy moves with xx inside this sample. The line will be a summary of the three points. It will not, by being a line, be a causal effect of setting xx.

Definition

A regression analysis starts from a sample of joint observations and estimates a relation that predicts the response from the predictors. When the response depends on a single predictor the analysis is simple. When several predictors enter, it is multiple. When the relation is linear in the unknown coefficients, it is linear regression, whether the picture against one raw predictor is a straight line or a curve. Dodge’s statement of the scope is that simple regression is the case of one predictor, multiple regression is the case of more than one, and linear regression is the case in which the relation between response and predictors is linear.[1]

The working model for a straight line is

Y=β0+β1x+ε.Y=\beta_0+\beta_1 x+\varepsilon.

The coefficients are unknown. The line people overlay on a scatterplot is an estimate of that relation, not the relation itself. The estimate is exact only in constructed cases, such as a price computed from a formula. In data, the points form a cloud around the line. OpenIntro’s illustration is a share price that sits on a perfect line, set against family income and financial aid, where income is useful and the prediction is far from perfect.[3][2]

Simple linear regression is the one-predictor straight line. Multiple linear regression keeps a mean that is linear in the coefficients and adds predictors. Both are usually fitted by ordinary least squares, the minimiser of the sum of squared residuals. Polynomial least squares stays inside that class and lets the mean bend by adding powers of a predictor: the mean is curved in xx and linear in the coefficients. Nonlinear regression is the step outside the class, when a coefficient sits inside the mean function, the normal equations are not linear, and the least-squares solution is iterative. Dodge’s example of that step is a mean in which two rate coefficients sit inside exponentials.[2][1]

Properties

For fixed inputs x1,…,xnx_1,\ldots,x_n, not all equal, and responses y1,…,yny_1,\ldots,y_n, the least-squares slope and intercept minimise ∑i(yi−b0−b1xi)2\sum_i(y_i-b_0-b_1 x_i)^2. The minimiser is

β^1=∑i(xi−xˉ)(yi−yˉ)∑i(xi−xˉ)2,β^0=yˉ−β^1xˉ.\hat\beta_1=\frac{\sum_i(x_i-\bar x)(y_i-\bar y)}{\sum_i(x_i-\bar x)^2},\qquad \hat\beta_0=\bar y-\hat\beta_1\bar x.

The fitted line passes through (xˉ,yˉ)(\bar x,\bar y). That identity is the first normal equation. It is not a statement that the mean response equals the sample mean of yy at every xx.

On the three-point sample, xˉ=1\bar x=1 and yˉ=7/3\bar y=7/3. The centred sum of squares of xx is

Sxx=(0−1)2+(1−1)2+(2−1)2=2,S_{xx}=(0-1)^2+(1-1)^2+(2-1)^2=2,

and the centred sum of products is

Sxy=(0−1)(1−73)+(2−1)(3−73)=43+23=2.S_{xy}=(0-1)\bigl(1-\tfrac73\bigr)+(2-1)\bigl(3-\tfrac73\bigr)=\tfrac43+\tfrac23=2.

The slope is 2/2=12/2=1. The intercept is 7/3−1⋅1=4/37/3-1\cdot 1=4/3. The fitted values are 4/34/3, 7/37/3, and 10/310/3. The residuals are −1/3-1/3, 2/32/3, and −1/3-1/3, and the residual sum of squares is

(−13)2+(23)2+(−13)2=19+49+19=23.\bigl(-\tfrac13\bigr)^2+\bigl(\tfrac23\bigr)^2+\bigl(-\tfrac13\bigr)^2=\tfrac{1}{9}+\tfrac{4}{9}+\tfrac{1}{9}=\tfrac{2}{3}.

The horizontal line at the mean 7/37/3 has residual sum of squares 8/38/3. The fitted slope removes 22 from that sum, from 8/38/3 down to 2/32/3. The fraction removed is (8/3−2/3)/(8/3)=3/4(8/3-2/3)/(8/3)=3/4. That fraction is a description of these three points. It is not a probability, and it is not a licence to extend the line past x=2x=2.[3][1]

Squared error charges a residual of 44 sixteen times as heavily as a residual of 11, and four times as heavily as a residual of 22. Absolute error would charge the residual of 44 only four times the residual of 11, and twice the residual of 22. The two criteria fit different lines. Least squares is the usual choice because a residual twice as large is treated as more than twice as serious, and because the resulting line is the one statistical software returns by default.[3]

Statistical use

The questions that organise a regression are the advertising questions: whether a relation is visible, how tightly it predicts, which predictors contribute, how precisely each contribution is estimated, how precisely a new response can be predicted, and whether a straight line is enough. A weak association is a reason to doubt that changing a budget will move the response in the way a fitted slope suggests. A strong association is still an association in the sample. Reading it as the effect of an intervention requires a design that supports the intervention.[2]

Quote a slope as a change in fitted height per unit of the predictor inside the observed range. The intercept is the fitted height at x=0x=0. If x=0x=0 is far from the values that were used, that intercept is an extrapolation. A prediction for a new response at a new xx is a different object from an estimate of the mean response: the new response adds one error on top of the uncertainty in the fitted line. Outside the observed range the same algebra still prints a number. OpenIntro’s warning is that a linear model is a modelling framework, and the behaviour outside the window of the data is not supplied by the fit.[3][2]

The conditions collected for a least-squares line are a linear trend, residuals whose shape is not dominated by a few points, a spread that does not trend with the fit, and observations that are not a time series in disguise. Those conditions are checks on the summary. They are not a proof of cause. A nonlinear trend is a reason to leave the straight line, for a polynomial in the predictor or for a mean that is nonlinear in the coefficients, rather than a reason to quote the straight slope as if the bend were not there.[3][1]

Whatever the variant, a generalised linear model changes the response distribution and the link, and ridge regression keeps a linear mean while shrinking coefficients when the predictors are many or nearly redundant. The reliability question remains: residual analysis is the usual check that the fitted relation is not an artefact of one or two points.[1]

Worked example

For x=0,1,2x=0, 1, 2 and y=1,3,3y=1, 3, 3, the least-squares line is y^=4/3+x\hat y=4/3+x. The fitted values are 4/34/3, 7/37/3, and 10/310/3. The residual sum of squares is 2/32/3. The line passes through the mean point (1,7/3)(1, 7/3). At x=1x=1, which is inside the observed inputs, the fitted mean is 7/37/3. At x=4x=4, which is outside the observed inputs, the same formula prints 4/3+4=16/34/3+4=16/3. That number is an extrapolation. Nothing in the three points says the mean is still linear there.

The absolute residuals are 1/31/3, 2/32/3, and 1/31/3, and they sum to 4/34/3. The squared residuals sum to 2/32/3. The largest residual, 2/32/3, contributes 4/94/9 of the squared sum and only 2/32/3 of the absolute sum. Squaring is what makes that middle point the expensive one.[3][2]

Your turn. Fit a least-squares line to the two points (1,2)(1, 2) and (3,6)(3, 6). Give the slope, the intercept, and the residual sum of squares.

The mean of xx is 22 and the mean of yy is 44. The centred sum of squares of xx is 22, and the centred sum of products is 44, so the slope is 22 and the intercept is 00. Both points lie on y=2xy=2x, and the residual sum of squares is 00.

Common misconceptions

The slope is not a causal effect of changing the predictor. The advertising budgets were chosen, and even then unmeasured differences can sit in the errors. In an observational series the same algebra produces a slope and does not produce an intervention. OpenIntro’s observational studies make the same point for a different design: an association, such as sunscreen use with skin cancer, can run through a confounder, and the fitted slope does not name it.[3][2]

Least squares minimises vertical squared gaps, not absolute gaps and not horizontal gaps. Predicting xx from yy swaps the roles and produces a different line. A model such as β1/(β1−β2)\beta_1/(\beta_1-\beta_2) times a difference of exponentials is a curve in xx and is not linear in the parameters, so the closed form above does not apply. Calling that curve a polynomial, or calling a polynomial nonlinear least squares, swaps the two neighbouring fits.[1][4]

A high fraction of residual sum of squares removed, such as the 3/43/4 on the three-point line, is not a high probability that the line is the population mean. It is the fraction of the sample’s squared variation about yˉ\bar y that the line captured. Three points can be captured tightly by a line that is the wrong shape one step past the largest xx.

Connections

A regression line is a summary of association in the sample that produced it. Neighbouring tools that answer different questions are a confidence interval for a coefficient or a mean, a prediction interval for a new response, and the sampling distribution of the coefficient estimators. Polynomial least squares is the linear fit that adds powers. Nonlinear regression is the iterative fit that does not. Ordinary least squares is the criterion shared by the linear cases, simple or multiple. The conditions on the residuals remain the check that the summary is worth reporting.[3][2]

Check yourself

Try these questions before opening an answer.

Several predictors, still linear

A mean uses three predictors and is linear in the coefficients. Why is that still linear regression, even if the picture against one raw predictor is not a straight line?

Linearity is judged in the coefficients. Each predictor multiplies its own coefficient. A power of one predictor is still a linear term of that kind. A coefficient sitting inside the mean function is the nonlinear case.

How squaring charges a large residual

One residual is 4 and another is 2. By what factor does squared error charge the larger residual, relative to the smaller, and how does that compare with absolute error?

Squared error charges 16 against 4, a factor of four. Absolute error charges 4 against 2, a factor of two. The two criteria fit different lines.

A slope is not yet an intervention

A fitted slope is positive inside the observed range of a predictor. What further condition is required before that slope is read as the change from setting the predictor to a new value?

The design has to support that intervention. The fit is a summary of the sample. An observational association can run through a confounder, and the algebra does not name it.

History

Determining a line through inconsistent observations was an astronomical problem in the eighteenth century. Boscovich, around 1755–1757, asked for a line whose residuals sum to zero and whose absolute residuals have the smallest possible sum, and he applied a geometric solution to the lengths of five meridians. Laplace, in 1789, gave an algebraic form of those two conditions. Gauss and Legendre, working separately, developed least squares, the squared-error criterion that became the standard fit. Legendre published it in 1805. Gauss had been using it earlier and a dispute over priority followed in 1809. An American, Robert Adrain, was working with the same criterion without knowledge of either. The word regression, in the linear sense used now, comes from Galton’s studies of heredity. In 1875 he sorted sweet-pea seeds into seven groups by weight, grew them, and found each group of offspring centred near a value pulled toward the population mean. From 1885 he used the word regression for that linear return.[1][4]

See also

Line chart · Apriori algorithm · Asymptotic analysis · Average treatment effect · Base rate · Bayesian inference · Bayesian model · Bayesian probability

Glossary and index

References

  1. ^ a b c d e f g h a. (pp. 450–452) b. (p. 450) c. (p. 373) d. (p. 304) e. (p. 452) f. (p. 452) g. (p. 373) h. (pp. 450–451) Dodge, Yadolah (2008). The Concise Encyclopedia of Statistics. Springer. https://doi.org/10.1007/978-0-387-32833-1
  2. ^ a b c d e f g h i a. (pp. 59–60, Ch. 3) b. (pp. 59–60, Ch. 3) c. (p. 61, §3.1) d. (p. 266, §7.1) e. (pp. 59–60, Ch. 3) f. (pp. 59–60, Ch. 3) g. (p. 61, §3.1) h. (pp. 59–60, Ch. 3) i. (pp. 59–61, Ch. 3) James, G., Witten, D., Hastie, T. & Tibshirani, R. (2013). An Introduction to Statistical Learning: with Applications in R (1st ed.). Springer, New York. https://doi.org/10.1007/978-1-4614-7138-7
  3. ^ a b c d e f g h a. (Ch. 8, §8.1.1) b. (Ch. 8, §8.2.2) c. (Ch. 8, §8.2.2) d. (Ch. 8, §8.1.1 and §8.2.6) e. (Ch. 8, §8.2.3) f. (Ch. 8, §8.2.2) g. (Ch. 1, §1.3.4) h. (Ch. 8, §8.2.3) Diez, D. M., Çetinkaya-Rundel, M. & Barr, C. D. (2019). OpenIntro Statistics (4th ed.). OpenIntro. https://www.openintro.org/book/os/
  4. ^ a b a. (§4.1.4.1) b. (§4.1.4.1) NIST/SEMATECH (2002). NIST/SEMATECH e-Handbook of Statistical Methods, §4.1.4.1: Linear Least Squares Regression. National Institute of Standards and Technology. https://www.itl.nist.gov/div898/handbook/pmd/section1/pmd141.htm
Cite this page
Plain text
StatWiki (2026). "Regression analysis." StatWiki. Last updated 2 December 2026. https://www.statwiki.io/articles/regression-analysis.html
BibTeX
@misc{statwiki_regression_analysis,
  author = {{StatWiki}},
  title = {{Regression analysis}},
  year = {2026},
  url = {https://www.statwiki.io/articles/regression-analysis.html},
  urldate = {2026-12-02},
  note = {StatWiki, last updated 2 December 2026}
}