[R] orthogonal/perpendicular distance from regression line

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Sat Feb 21 03:05:25 CET 2009

On Fri, 20 Feb 2009, GAF wrote:

> Hi there,
> I am trying to measure orthogonal/perpendicular distances from regression
> lines (i.e. the shortest distance from a given point to my regression line).
> As it sounds rather easy (basically just an orthogonal/perpendicular
> residual) I hoped that there was some function in R that can do that. All
> efforts so far remained unsuccessful, however.
> Does anybody know?

You could do this with [1], but if you are hoping to learn something
statistical by doing this you should probably reconsider, because the
regression line residuals are minimized along the dependent variable axis,
and if the coordinate system is rotated (that is, you look at
deviation from the regression line to the points along a different
direction) then the residuals on that regression line will no longer be

[1] http://mathworld.wolfram.com/Point-LineDistance2-Dimensional.html

Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...2k

More information about the R-help mailing list