Porisma

Choose the response and fit a line

Distinguish the two regression directions and their residuals.

From association to a regression model

Decide which coordinate is the response before fitting. Regression of y on x minimises squared vertical residuals on the usual axes; regression of x on y minimises squared horizontal residuals. Rearranging a fitted line does not generally fit the other response.

Linear regression fits a line to observed paired data. Check the scatter and coefficient before deciding whether a straight-line model is suitable; the usual fitting method is least squares. There are two directions: regression of yy on xx and regression of xx on yy. A model can support estimation and, with appropriate assumptions, inference about population parameters; a fitted line alone does not establish those assumptions.

The source compares the two lines on the same axes: when r≈0r\approx0, their directions differ markedly; near r≈1r\approx1 they almost coincide, also near r≈−1r\approx-1. Two regression directions preserves both schematic comparisons. This describes the same dataset and fixed axis scales; the visual angle also depends on axis scaling. Later source pages supply the residual definitions, coefficients and conditions for choosing the appropriate direction.

Fit the response coordinate: two least-squares problems

For regression of yy on xx, write y=a+bxy=a+bx, with xx explanatory and yy response. Plot xx horizontally and yy vertically. Each residual is the vertical difference between an observed yiy_i and its prediction at the same xix_i:

ei=yi−(a+bxi),S=∑i=1nei2=∑i=1n(yi−a−bxi)2.e_i=y_i-(a+bx_i),\qquad S=\sum_{i=1}^{n}e_i^2=\sum_{i=1}^{n}(y_i-a-bx_i)^2.

Choose a,ba,b to minimise SS. It is the sum of squared residuals, not a signed total residual or the sum of perpendicular distances. The source calls SS “Total residual”; the precise objective is the sum of squares. It depends on both aa and bb.

b=SxySxx=∑(x−xˉ)(y−yˉ)∑(x−xˉ)2=∑xy−(∑x)(∑y)/n∑x2−(∑x)2/n,b=\frac{S_{xy}}{S_{xx}}=\frac{\sum(x-\bar x)(y-\bar y)}{\sum(x-\bar x)^2}=\frac{\sum xy-(\sum x)(\sum y)/n}{\sum x^2-(\sum x)^2/n}, a=∑yin−b∑xin=yˉ−bxˉ,y−yˉ=b(x−xˉ).a=\frac{\sum y_i}{n}-b\frac{\sum x_i}{n}=\bar y-b\bar x,\qquad y-\bar y=b(x-\bar x).

Thus aa is the yy-intercept and bb the gradient/regression coefficient. For defined rr, the gradient and correlation have the same sign. The yy-on-xx line passes through (xˉ,yˉ)(\bar x,\bar y) and requires Sxx>0S_{xx}>0. Use the calculator for complete paired data; MF27 formulas are useful when calculator use is not permitted or only sufficient summary information is given.

Fit x as the response

For regression of xx on yy, take yy as explanatory and xx as response and write x=c+dyx=c+dy. On the same conventional axes, its residuals are horizontal:

ei=xi−(c+dyi),S=∑i=1n(xi−c−dyi)2.e_i=x_i-(c+dy_i),\qquad S=\sum_{i=1}^{n}(x_i-c-dy_i)^2. d=SxySyy=∑(x−xˉ)(y−yˉ)∑(y−yˉ)2=∑xy−(∑x)(∑y)/n∑y2−(∑y)2/n,d=\frac{S_{xy}}{S_{yy}}=\frac{\sum(x-\bar x)(y-\bar y)}{\sum(y-\bar y)^2}=\frac{\sum xy-(\sum x)(\sum y)/n}{\sum y^2-(\sum y)^2/n}, c=xˉ−dyˉ,x−xˉ=d(y−yˉ).c=\bar x-d\bar y,\qquad x-\bar x=d(y-\bar y).

This line also passes through (xˉ,yˉ)(\bar x,\bar y) and requires Syy>0S_{yy}>0. The two source residual schematics are retained in Vertical and horizontal residuals. Swapping regression direction changes the quantity minimised; rearranging one fitted equation does not generally produce the other fitted regression. If d=0d=0, the reverse line is x=xˉx=\bar x and cannot be written as a single-valued yy function.

The eight-observation example fits both lines, sketches them on the same axes, and uses their intersection to recover the means. Keep full coefficients for this calculation; premature rounding changes the intersection.

Fit both responses with an imperfect dataset

For observations (1,1),(2,2),(3,2),(4,5)(1,1),(2,2),(3,2),(4,5), use a calculator to fit y on x and x on y. For an observational prediction of x when y=3, compare the reverse fit with rearranging the forward fit. Identify which residual direction each fit minimises; do not derive the fitting formulae.

After your attempt: compare the reasoning

Both sample means are 2.5. The forward line is y=−1/2+(6/5)xy=-1/2+(6/5)x, while the reverse line is x=5/6+(2/3)yx=5/6+(2/3)y. At y=3, the reverse-fit estimate is 17/6≈2.833317/6\approx2.8333. Rearranging the forward line gives 35/12≈2.916735/12\approx2.9167, a different estimate.

The forward line minimises squared y residuals; the reverse line minimises squared x residuals. For this observational prediction of x from y, use the x-response fit. A controlled-input calibration question can have a different modelling setup, so identify the role of the variables rather than choosing a line from the letter being requested alone.

Diagrams for this unit

Open 2 diagrams

Try these examples

Open an example in chapter practice. Try it first, then read its solution. Use “Learn this step” to return to this unit.