Problem of robust fitting using the "robustfit" function
3 次查看(过去 30 天)
显示 更早的评论
I am using the function "robustfit" to fit a plane(3D) but I have a problem:
I do three different calls for this function but I have not the same result those are the calls:
data: x, y, z (vectors)
call-1:
p = robustfit([x y],z)
normal = [p(2) p(3) -1]/ norm([p(2) p(3) -1])
normal = 0.5448273 0.8371124 -0.0490510
call-2:
p = robustfit([y z],x)
normal = [-1 p(2) p(3)]/ norm([-1 p(2) p(3)])
normal = 0.5460477 0.8377283 -0.0065613
call-3:
p = robustfit([x z],y)
normal = [p(2) -1 p(3) ]/ norm([p(2) -1 p(3)])
normal = 0.5451328 0.8374704 -0.0043365
So how can I know which is the correct normal
thank you in advance
0 个评论
回答(2 个)
Matt Tearle
2011-4-28
There really is no "right" answer, because it's a matter of how you view the problem. robustfit uses the residuals to calculate the weighting, but residual means the difference in the observed/predicted response variable. In your case, it looks like the points lie around a plane that is almost vertical ( normal(3) is small in all cases). This means that the residuals will be much greater when looking at z = f(x,y) than when looking at x = f(y,z) or y = f(x,z). Consequently, the weighting for a given point will be different in each formulation. In other words, different points are "outliers" in different formulations. To see this, try:
[p,s1] = robustfit([x y],z);
[p,s2] = robustfit([y z],x);
[p,s3] = robustfit([x z],y);
plotmatrix([s1.w,s2.w,s3.w])
This will plot the weightings against each other. I'm guessing you'll see reasonable correlation between s2 and s3, but not so great with s1.
This means that each formulation will give you a slightly different plane (because it's down-weighting different data points). I'd probably trust the last two, rather than the first.
0 个评论
Massinissa
2011-4-29
1 个评论
Matt Tearle
2011-4-29
But OLS still "weights" in that the objective function to minimize is the sum of the square errors, ie the squared residuals. So you have the same problem: the size of the residuals is different depending on how you look at the fit (z = f(x,y) vs. y = f(x,z) vs. x = f(y,z)). And because OLS is *squaring* the errors, again different points will be more "outlier-ish" than others in the different formulations.
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!