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

怎甘沉沦 提交于 2019-11-28 00:11:34

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:

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.

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.

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.

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)

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