Least Trimmed Squares fitting
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
Is there any toolbox or written code for least trimmed square in Matlab?
채택된 답변
Matt J
2021년 6월 16일
0 개 추천
If you don't have too many unknown parameters to fit, you could implement it easily with fminsearch.
댓글 수: 7
How can I use the number of the trimming point in this function?
I have this data set.
x = (1:10)';
y = 10 - 2*x + randn(10,1);
y(10) = 6; y(6) = 15; y(4) = -10; y(1) = -10;
plot(x,y,'or')
Here, it is possible to remove 4 points. I do not know how to do this part.
About fminsearch, I use this
M = [ones(size(x)),x];
p0 = M\y;
errfcn = @(p,y,M) sum((y-M*p).^2);
p1 = fminsearch(@(p) errfcn(p,y,M),p0);
hold on
plot(x,y-M*p1,'.-')
I want to find the regression line, that removes this data y(10) = 6, y(6) = 15, y(4) = -10, y(1) = -10.
x = (1:10)';
y = 10 - 2*x + randn(10,1);
y(10) = 6; y(6) = 15; y(4) = -10; y(1) = -10;
%%Initial guess
in=abs(y-movmedian(y,3))<=2;
p0=polyfit(x(in), y(in),1);
%%Optimize
k=4; %number to trim
p=fminsearch(@(p)trimlsq(p,x,y,k), p0);
%%Plot
xs=linspace(min(x),max(x),100);
plot(x,y,'o',xs, polyval(p,xs),'--')

function fval=trimlsq(p,x,y,k)
r=abs(polyval(p,x)-y);
rtrim=maxk(r,k);
fval=norm(r)^2-norm(rtrim)^2;
end
NA
2021년 6월 17일
Thank you as always. For initial guess, I don't understand why you choose this way
%%Initial guess
in=abs(y-movmedian(y,3))<=2;
p0=polyfit(x(in), y(in),1);
NA
2021년 6월 17일
If x is matrix
x = [-122.9115,0.0000,-0.0000;-70.9142,0.0000,-0.0000;122.8232,-0.0000,0.0000;...
0.0000,109.3731,-112.7629;0.0000,63.1032,-65.0589;0.0000,-116.0692,119.4565;...
0,111.5914,0;0,0,109.0116]
y = [0.1415;0.1756;-0.9547;-4.5564;-0.6909;3.8466;5.6495;8.4522];
For initial guess
y = sparse(y);
x = sparse(x);
in = abs(y-movmedian(sparse(y),3))<=2;
p0 = polyfit(x(in), y(in),size(x,2)-1); % estimate 3 unknown variable
% or
% p0 = x\y;
p = fminsearch(@(p)trimlsq(p,x,y,1), p0);
In this way, I could not get good regression
Matt J
2021년 6월 17일
Why would you choose k=1?
Why would you choose k=1?
Removing more than 1 row from the x make the matrix rank deficient.
Matt J
2021년 6월 17일
I don't understand the meaning of x being a matrix when y is not.
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기
참고 항목
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
