orthogonal/perpendicular distance from regression line

classic Classic list List threaded Threaded
4 messages Options
GAF
Reply | Threaded
Open this post in threaded view
|

orthogonal/perpendicular distance from regression line

GAF
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?
Thnx and cheers,
Philipp
Reply | Threaded
Open this post in threaded view
|

Re: orthogonal/perpendicular distance from regression line

RKoenker
For the bivariate case:

g  <- function(b,x,y)
         (abs(y - b[1] - b[2] * x))/sqrt(1 + crossprod(b))

url:    www.econ.uiuc.edu/~roger            Roger Koenker
email    [hidden email]            Department of Economics
vox:     217-333-4558                University of Illinois
fax:       217-244-6678                Champaign, IL 61820



On Feb 20, 2009, at 11:12 AM, 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?
> Thnx and cheers,
> Philipp
> --
> View this message in context: http://www.nabble.com/orthogonal-perpendicular-distance-from-regression-line-tp22123179p22123179.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: orthogonal/perpendicular distance from regression line

Jeff Newmiller
In reply to this post by GAF
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
minimized.

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

---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<[hidden email]>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...2k

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: orthogonal/perpendicular distance from regression line

Mark Difford
Hi Jeff,

>> 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,

It should be said that there are valid forms of linear regression where this is not true and it is the orthogonal residuals that are wanted. Perhaps the main case is where there are errors in x and y: indeed, this is how the "lines" (i.e. principal components) are fitted in principal component analysis.

Regards, Mark.

Jeff Newmiller wrote
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
minimized.

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

---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil@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

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Mark Difford (Ph.D.)
Research Associate
Botany Department
Nelson Mandela Metropolitan University
Port Elizabeth, South Africa