I am looking for the name of a fitting method that will work even if points from multiple dataseries are meshed together.

As far as I understand there are two major methods, least squares and least absolute error; the method I am looking for would be the next step in the direction from LS to LAE:

  • Least Squares fitting: Minimize the square of the distances of all data points to a function. The further a point is, the stronger it's deviation is weighted. May be strongly influenced by outliers. Will always converge to one globally unique solution (at least for simple curves), easy to find with gradient descent methods.

enter image description here

  • Least absolute deviations: Minimize the sum of the distances of all datapoints. All deviations are weighted equal. More robust to outliers, may converge to potentially infinite solutions that all have the same total deviation

enter image description here (generated by hand; images may not be accurate)

  • "Least Square Root" ??? (Google does not really have many hits for this name). I am looking for a function that may converge towards multiple local minima, and weights deviations stronger the closer a point is. Which solution it would converge would depend on the starting parameters. I think a least-square-root of all deviations would do this, but I cannot find any reference to this sort of fit.

enter image description here

Is there an official name for a method like this, and what would it be called? Or is this sort of fit fundamentally not possible with curve fitting methods?

I am not looking for a method that would find all local minima, one local minimum depending on starting parameters would suffice.

(note that in the example pictures the functions were all lines, but ideally I am looking for a method that is able to iteratively fit points towards arbitrary n-dimensional functions)

  • 1
    $\begingroup$ Is this really just an indirect way of asking stats.stackexchange.com/questions/33078/…? $\endgroup$
    – whuber
    Commented Aug 13, 2012 at 16:37
  • $\begingroup$ @whuber: I think the OP is actually asking for regression methods with non-convex, redescending loss functions. I'll try an answer. $\endgroup$
    – user603
    Commented Aug 13, 2012 at 16:59

2 Answers 2


It seems to me you are actually looking for a regression models with re-descending ("far away points are weighted less than close ones") loss function. Such loss functions --for example the Tukey biweight-- lead to highly non-convex optimization problems, meaning that there are, potentially, a finite but factorial-order increasing number of potential solution. Clearly, which ever one you will pick up will depend on your "starting weights" (you initial guess about which observations belong to the model you are looking for).

R has some facilities to fit such models. An example is the lmrob function in the robustbase package. For illustrative reasons I use a univariate example below but in principle the logic extends to higher dimensions.

#constructing the data --one group at a time
#mixing the data

the red points mark the initial guess of <span class=$d+1$ points from the same relationship. The red line is the final fitted regression function" />

Now, as I mentioned, fitting these types of model is actually a highly non-convex problem. The final solutions will depend on the quality of your starting points. In the example above, my "guess" that the original points (marked in red in the plot above) belonged to the same relationship was correct. In general, specially in higher dimensions, this is a highly questionable assumption. None-withstanding this, if your initial guess is correct, the biweight loss function enabled an appreciable gain over the naive solution (the OLS line passing by the 3 initial points).


I forgot to mention that you have a parameter that determines the width of the area for which the bi-weight gives non-zero weights. This is the tuning.psi parameter of the lmrob.control object.

There is a tradeoff between efficiency and the width of the biweight: the wider the biweight, the more points you effectively use, the more efficiency you get. A limiting case is a biweight that never re-descends (maximal width) which would give you the OLS solution. Adjusting the width is done by:


If you set the ctrl$tuning.psi too small, you will get convergence problems. This can be solved by increasing the max.it value of the control object:


There is a whole theory on optimal values of the tunning constant, but it only applies if the sub-population you are targeting has more than half of the observations. I gather this is not the case you are concerned with. If this is the case, I think it is best is to play with to get a handle on it.

  • $\begingroup$ Thanks, this looks very interesting! One thing I noticed is that the tukey biweight function looks kinda similar to the square root I imagined. Other than that, I still have to work through the wikipedia article. In particular I still do not understand how the fitting works, is it still a gradient descent or a does it require other minimum finding techniques? $\endgroup$
    – HugoRune
    Commented Aug 13, 2012 at 22:02
  • $\begingroup$ A form of gradiant descent (IRLS, for numerical stability). But, again, it will only converge to the local minimum that happens to be closest to your starting points. I also added some info to the answer... $\endgroup$
    – user603
    Commented Aug 14, 2012 at 8:13

I have worked on this problem over the last two years. My co-authors and I called it a "data association problem", as part of the problem consists in finding the correct association between data points that belong to the same curve. The other part would be performing the regression itself on both data sets.

As user user603 correctly points out, in general this problem corresponds to a difficult non-convex optimization problem. In your case it may be quite simple, as your data correspond to straight lines. If you simply want to do this - detect lines - you could try the Hough transform.

I worked on the scenario where the data are nonlinear curves, without restrictions, as in this example figure:

data association problem - candy data set

Check out my recent publication "Overlapping Mixtures of Gaussian Processes for the data association problem" if you'd like, it contains much background information on this kind of problem. I have some other articles on this, but they have not been accepted for publication yet.

By the way I'd love to hear where you got this data.

  • $\begingroup$ just out of curiosity, have you tried MM-p-splines? (what MM regression is to linear regression, MM-p-spline are to splines). $\endgroup$
    – user603
    Commented Aug 14, 2012 at 12:29
  • $\begingroup$ My data is not really linear, I just tried to illustrate with a simple example (perhaps I simplified too much). It is actually 3d point clouds, and I am trying to fit geometric shapes to it. I have a gradient-descend approach based on least squares, which works well if the segmentation was able to separate the objects without too many errors, but I am trying to find something that could work without this preprocessing. I considered generalized hough transform, but the hough space would be at least 6-dimensional, and I had mixed results in finding noisy peaks even in 2d hough space in the past. $\endgroup$
    – HugoRune
    Commented Aug 14, 2012 at 12:33
  • $\begingroup$ The publication looks very interesting at first glance, although I lack the statistical background to fully understand most of it. I will try to figure this out, thanks! $\endgroup$
    – HugoRune
    Commented Aug 14, 2012 at 12:55
  • $\begingroup$ See the very similar answer at stats.stackexchange.com/a/34287. $\endgroup$
    – whuber
    Commented Aug 14, 2012 at 13:33
  • $\begingroup$ @user603 I haven't. I did some ad-hoc tests with standard splines but I didn't find a way to overcome the combinatorial problems. I'll check MM-p-splines, thanks for the suggestion. $\endgroup$
    – Steven
    Commented Aug 14, 2012 at 13:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.