least squares regression in 3space robjohn is giving me a hand with this, but in case anybody else knows...
I need to do a least-squares regression for linearity on a set of coordinates in 3space. If the dataset is linear, I need to see if it is close to vertical or horizontal. How could I do this?
Many thanks in advance
Joe Stavitsky

Typically, vertical would say all the $(x,y)$ coordinates are the same and horizontal would say all the $z$ coordinates are the same.  So you could just look at the standard deviations of the coordinates of all the points to assess vertical or horizontal.  That doesn't check if the points lie on an arbitrary line.
The discussion you cite was indeed to give a plane-that was the hypothesis.  If you find a relation like $ax+by+cz=k$ you get a plane, as one equation reduces the dimension of the space by one.  If you believe your points lie on a line in 3-space, you have two options.  A standard linear regression (where one coordinate is fixed and you minimize the sum squared error in the other direction) may well work for you, and you can just do two regressions, one $x$ vs $y$ and another $x$ vs $z$.  If the equations you get are $y=m_yx+b_y, z=m_zxb_z$, the line is then $(0,b_y,b_z)+k(1,m_y,m_z)$.  If you want orthogonal distance regression, I believe (but didn't follow the derivation to confirm) the link you have is applicable, but you want the line to be in the direction of the maximum singular value, still through the centroid.
