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?
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?
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