Implementing deming regression
In this recipe, we will implement deming regression, which means we will need a different way to measure the distance between the model line and data points.
Note
Deming regression goes by several names. It is also known as total regression, orthogonal distance regression (ODR), and shortest-distance regression.
Getting ready
If least squares linear regression minimizes the vertical distance to the line, deming regression minimizes the total distance to the line. This type of regression minimizes the error in both y and x values.
See the following diagram for a comparison:

Figure 8: Difference between regular linear regression and deming regression; linear regression on the left minimizes the vertical distance to the line, and deming regression on the right minimizes the total distance to the line
To implement deming regression, we have to modify the loss function. The loss function in regular linear regression minimizes the vertical distance. Here, we want to minimize...