# Deming regression

In statistics, Deming regression, named after W. Edwards Deming, is an errors-in-variables model that tries to find the line of best fit for a two-dimensional data set. It differs from the simple linear regression in that it accounts for errors in observations on both the x- and the y- axis. It is a special case of total least squares, which allows for any number of predictors and a more complicated error structure.
Deming regression is equivalent to the maximum likelihood estimation of an errors-in-variables model in which the errors for the two variables are assumed to be independent and normally distributed, and the ratio of their variances, denoted δ, is known. In practice, this ratio might be estimated from related data-sources; however the regression procedure takes no account for possible errors in estimating this ratio.
The Deming regression is only slightly more difficult to compute than the simple linear regression. Most statistical software packages used in clinical chemistry offer Deming regression.
The model was originally introduced by Adcock (1878) who considered the case δ = 1, and then more generally by Kummell (1879) with arbitrary δ. However their ideas remained largely unnoticed for more than 50 years, until they were revived by Koopmans (1936) and later propagated even more by Deming (1943). The latter book became so popular in clinical chemistry and related fields that the method was even dubbed Deming regression in those fields.

## Specification

Assume that the available data (y$_i$, x$_i$) are measured observations of the "true" values (y$_i$*, x$_i$*), which lie on the regression line:
    ${\begin{aligned}y_{i}&=y_{i}^{*}+\varepsilon _{i},\\x_{i}&=x_{i}^{*}+\eta _{i},\end{aligned}}$
where errors ε and η are independent and the ratio of their variances is assumed to be known:
    $\delta ={\frac {\sigma _{\varepsilon }^{2}}{\sigma _{\eta }^{2}}}.$
In practice, the variances of the $x$ and $y$ parameters are often unknown, which complicates the estimate of $\delta$. Note that when the measurement method for $x$ and $y$ is the same, these variances are likely to be equal, so $\delta =1$ for this case.
We seek to find the line of "best fit"
    $y^{*}=\beta _{0}+\beta _{1}x^{*},$
such that the weighted sum of squared residuals of the model is minimized:
    $SSR=\sum _{i=1}^{n}{\bigg{\frac {\varepsilon _{i}^{2}}{\sigma _{\varepsilon }^{2}}}+{\frac {\eta _{i}^{2}}{\sigma _{\eta }^{2}}}{\bigg )}={\frac {1}{\sigma _{\epsilon }^{2}}}\sum _{i=1}^{n}{\Big(y_{i}-\beta _{0}-\beta _{1}x_{i}^{*})^{2}+\delta (x_{i}-x_{i}^{*})^{2}{\Big )}\ \to \ \min _{\beta _{0},\beta _{1},x_{1}^{*},\ldots ,x_{n}^{*}}SSR$
See Jensen (2007) for a full derivation.

## Solution

The solution can be expressed in terms of the second-degree sample moments. That is, we first calculate the following quantities (all sums go from i = 1 to n):
    ${\begin{aligned}{\overline {x}}&={\tfrac {1}{n}}\sum x_{i}&{\overline {y}}&={\tfrac {1}{n}}\sum y_{i},\\s_{xx}&={\tfrac {1}{n}}\sum (x_{i}-{\overline {x}})^{2}&&={\overline {x^{2}}}-{\overline {x}}^{2},\\s_{xy}&={\tfrac {1}{n}}\sum (x_{i}-{\overline {x}})(y_{i}-{\overline {y}})&&={\overline {xy}}-{\overline {x}}\,{\overline {y}},\\s_{yy}&={\tfrac {1}{n}}\sum (y_{i}-{\overline {y}})^{2}&&={\overline {y^{2}}}-{\overline {y}}^{2}.\end{aligned}}\,$
Finally, the least-squares estimates of model's parameters will be
    ${\begin{aligned}&{\hat {\beta }}_{1}={\frac {s_{yy}-\delta s_{xx}+{\sqrt {(s_{yy}-\delta s_{xx})^{2}+4\delta s_{xy}^{2}}}}{2s_{xy}}},\\&{\hat {\beta }}_{0}={\overline {y}}-{\hat {\beta }}_{1}{\overline {x}},\\&{\hat {x}}_{i}^{*}=x_{i}+{\frac {{\hat {\beta }}_{1}}{{\hat {\beta }}_{1}^{2}+\delta }}(y_{i}-{\hat {\beta }}_{0}-{\hat {\beta }}_{1}x_{i}).\end{aligned}}$

## Orthogonal regression

For the case of equal error variances, i.e., when $\delta =1$, Deming regression becomes orthogonal regression: it minimizes the sum of squared perpendicular distances from the data points to the regression line. In this case, denote each observation as a point $z_{j}=x_{j}+iy_{j}$ in the complex plane (i.e., the point $(x_{j},y_{j})$ where $i$ is the imaginary unit). Denote as $S=\sum {(z_{j}-{\overline {z}})^{2}}$ the sum of the squared differences of the data points from the centroid ${\overline {z}}={\tfrac {1}{n}}\sum z_{j}$ (also denoted in complex coordinates), which is the point whose horizontal and vertical locations are the averages of those of the data points. Then:
* If $S=0$, then every line through the centroid is a line of best orthogonal fit.
* If $S\neq 0$, the orthogonal regression line goes through the centroid and is parallel to the vector from the origin to ${\sqrt {S}}$.
A trigonometric representation of the orthogonal regression line was given by Coolidge in 1913.

### Application

In the case of three non-collinear points in the plane, the triangle with these points as its vertices has a unique Steiner inellipse that is tangent to the triangle's sides at their midpoints. The major axis of this ellipse falls on the orthogonal regression line for the three vertices. The quantification of a biological cell's intrinsic cellular noise can be quantified upon applying Deming regression to the observed behavior of a two reporter synthetic biological circuit.
When humans are asked to draw a linear regression on a scatterplot by guessing, their answers are closer to orthogonal regression than to ordinary least squares regression.

## York regression

The York regression extends Deming regression by allowing correlated errors in x and y.