# Best-fit plane through a set of lines?

A linear model estimates the best fit line from a set of points, often through minimization of the sum of squared residuals.

By analogy, is there any established method (possibly implemented in R) for fitting a plane to a set of lines (or segments) ? For example, minimizing sum of area (or squared area ?) between residual-lines and the best-fitting plane ?

Thanks.

• Fascinating question. These lines can be oriented any which-way, or are they maybe parallel to some axis? (e.g. you might have a set of lines where each line has y constant but x-varying, and at a given y the line or lines relate z to x). Just idly supposing for a moment, I wonder if there might be any traction in working in the dual-space. I think that we'd probably look at finding a point (dual to the plane) closest to a set of lines (I think duals of lines would be lines). Commented Jan 21, 2016 at 2:31
• When asking, I was thinking specifically about lines that can be oriented in any direction. I just realized that there might be problems with infinite lines, so I edited my question, talking about segments of lines, too, that should represent an easier problem (IMHO) to tackle. Commented Jan 21, 2016 at 2:39
• If your data were segments (and you only considered fit where the segment was), you might consider replacing the segment by some set of points (you might have constant density of points per unit distance or per segment, depending on what you were trying to achieve). But I don't think there's necessarily a problem with infinite lines. Commented Jan 21, 2016 at 2:39
• Gary King did some work on tomography that may be what you're after, or perhaps get you started. I'm looking for a reference now...
– Sycorax
Commented Jan 21, 2016 at 2:43
• @Glen_b You are right the data I am working consists of segments. Because they are not same length, replacing these segments by sets of evenly spaced distance could do the job. However, are'nt all points "from" a given segment correlated (some kind of hierarchy ?) Commented Jan 21, 2016 at 2:59