2
$\begingroup$

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

  • 0
    Look up orthogonal distance regression.2012-05-11
  • 0
    @J.M. this discussion http://mathforum.org/library/drmath/view/63765.html seems to say final output is a plane, not a line.2012-05-11
  • 0
    I haven't read through the link (sorry), but if you have a plane in ${\mathbb R}^3,$ then you can extract the unit vector in the direction of the normal to the plane: $\vec n.$ Indeed, if the plane is vertical or horizontal, then you can see that immediately from $\vec n.$2012-05-11
  • 0
    I am afraid the discussion I posted is over my head mathwise; could sombody post some pseudocode maybe? Thanks again2012-05-11
  • 0
    I think [Principle component analysis](http://en.wikipedia.org/wiki/Principal_component_analysis) is what you want. Essentially what you want is that the line passes through the centroid in the direction of maximal variance; the line you want corresponds to the first PCA vector, shifted to pass through the centroid.2012-05-11

3 Answers 3