0
wget -qO- https://i.stack.imgur.com/AQGsm.gif | tail -c +43

Using the above data (the plot of the data is shown below), I got the following error.

R> lad(y ~ x, data=f)
Error in lad(y ~ x, data = f) :
  l1fit: optimal solution is probably non-unique.

I am not sure how to diagnose what part of the data causes the problem. Could anybody show me how to diagnose where the problem is?

Also, a solution among all non-unique solutions is better than nothing. How to obtain a solution in this case?

enter image description here

EDIT: I see a discussion here. It seems that the problem is that either the slope or the intercept or both can be any number within a range. For this particular example, I can just live with the middle point within that range or those ranges. But how to obtain such range(s) with lad?

Is it possible to force least absolute deviations (LAD) regression to return the 'median' value when infinite solutions are possible?

BTW, I tried rq as well. Although, it does not stop with an error, it does not return the median in this case. But I want the median to be returned.

R> f = data.frame(y = sort(runif(2)))
R> rq(y ~ 1, data = f)
Call:
rq(formula = y ~ 1, data = f)

Coefficients:
(Intercept)
  0.5513419

Degrees of freedom: 2 total; 1 residual
Warning message:
In rq.fit.br(x, y, tau = tau, ...) : Solution may be nonunique
R> f$y
[1] 0.5513419 0.7989032
kjetil b halvorsen
  • 63,378
  • 26
  • 142
  • 467
user1424739
  • 424
  • 2
  • 9
  • 1
    Some related discussion: https://stats.stackexchange.com/questions/275931/is-it-possible-to-force-least-absolute-deviations-lad-regression-to-return-the – Sycorax Aug 13 '21 at 03:53

0 Answers0