# How princomp() works?

I always used lm() to check the linear regression for two series. That function returns a coefficient(beta) that i can use doing:

y = beta*x


Today I found the princomp() function, that calculate the Total Least Squares.

It should be good for me (more accurate). I've done some tests using princomp(), like:

r <- princomp( ~ x + y)

My problem is: How to interpret its results.

How can I get the coefficient? (with "coefficient" i mean, the number that i have to use to multiply the X value to give a numer similar to y)

Could someone help me?

(I'm using R)

THANK YOU!

-
 One moment guys, i'm a bit confused. look at: zoonek2.free.fr/UNIX/48_R/09.html This is called PCA (Principal Component Analysis, aka "orthogonal regression" or "perpendicular sums of squares" or "total least squares") so i think we are talking about TLS with princomp() No? – Dail Jul 18 '11 at 6:55 No; those are two different things, see wikipedia article about PCA. The fact it is used here is a hack (I don't know how exact, but I'm going to check it); that's why the complex extraction of coefficients. – mbq♦ Jul 18 '11 at 7:12 And please register your account not to lose it again; I have merged your two current ones. – mbq♦ Jul 18 '11 at 7:14 A related question: stats.stackexchange.com/questions/2691/… and a blog post is referenced by one of the answers: cerebralmastication.com/2010/09/… – Jonathan Jan 7 at 19:00

princomp is running principal component analysis instead of total least squares regression. As far as I know there is no R function nor package that does TLS; at most there is Deming regression in MethComp.
Yet, please treat this as a suggestion that it is most likely not worth it.

-
 I thought Deming in the MethComp package was TLS - what's the difference? – mark999 Jul 18 '11 at 7:05 You must give it the ratio of errors on x and y; pure TLS optimises this. – mbq♦ Jul 18 '11 at 7:17 Thanks for the explanation. – mark999 Jul 18 '11 at 7:45

Based on the naive GNU Octave implementation found here, something like this might (grain of salt, it's late) work.

tls <- function(A, b){

n <- ncol(A)
C <- cbind(A, b)

V <- svd(C)\$v
VAB <- V[1:n, (n+1):ncol(V)]
VBB <- V[(n+1):nrow(V), (n+1):ncol(V)]
return(-VAB/VBB)
}

-