How to calculate Total least squares in R? (Orthogonal regression) [closed]

安稳与你 提交于 2019-12-17 16:37:27

问题


I didn't find a function to calculate the orthogonal regression (TLS - Total Least Squares).

Is there a package with this kind of function?

Update: I mean calculate the distance of each point symmetrically and not asymmetrically as lm() does.


回答1:


You might want to consider the Deming() function in package MethComp [function info]. The package also contains a detailed derivation of the theory behind Deming regression.

The following search of the R Archives also provide plenty of options:

  • Total Least Squares
  • Deming regression

Your multiple questions on CrossValidated, here and R-Help imply that you need to do a bit more work to describe exactly what you want to do, as the terms "Total least squares" and "orthogonal regression" carry some degree of ambiguity about the actual technique wanted.




回答2:


Two answers:

  1. gx.rma in the rgr package appears to do this.
  2. Brian Ripley has given a succinct answer on this thread. Basically, you're looking for PCA, and he suggests princomp. I do, too.



回答3:


I got the following solution from this url:

https://www.inkling.com/read/r-cookbook-paul-teetor-1st/chapter-13/recipe-13-5

   r <- prcomp( ~ x + y )
   slope <- r$rotation[2,1] / r$rotation[1,1]
   intercept <- r$center[2] - slope*r$center[1]

Basically you performa PCA that will fit a line between x and y minimizing the orthogonal residuals. Then you can retrieve the intercept and slope for the first component.




回答4:


For anyone coming across this question again, there exists a dedicated package 'onls' by now for that purpose. It is similar handled as the nls package (which implements ordinary least square algorithms)



来源:https://stackoverflow.com/questions/6872928/how-to-calculate-total-least-squares-in-r-orthogonal-regression

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!