Orthogonal Distance Regression plot and regression equation

Hi,
I have a dataset, attached herewith for your reference.
I want to plot the orthogonal distance regression line and get y=mx+c equation in the plot.
Thank you!

 採用された回答

KSSV
KSSV 2019 年 7 月 15 日

1 投票

5 件のコメント

MatLab Code N
MatLab Code N 2019 年 7 月 15 日
Hi KSSV, I had looked into the link you sent but had trouble following it through. I don't see what variables were being plotted to get the regression line. Thank you.
KSSV
KSSV 2019 年 7 月 15 日
A = xlsread('sample_data.xlsx') ;
% Remove NaaN's
idx = isnan(sum(A,2)) ;
A(idx,:) = [] ;
x = A(:,1) ; y = A(:,2) ;
data = [x(:), y(:)];
[U, S, V] = svd(data - repmat(mean(data), size(data, 1), 1), 0);
a = -V(1, end) / V(2, end);
b = mean(data * V(:, end)) / V(2, end);
%
yi = a*x+b ;
%% Plot
hold on
plot(x,y,'.b')
plot(x,yi,'r')
MatLab Code N
MatLab Code N 2019 年 7 月 15 日
Hi KSSV,
In the stackoverflow link, there are Edit 1 and Edit 2 following the section of the code you've used. If I use the edits mentioned in the link, the regression line becomes different. Do you have any idea about it.
Thanks
KSSV
KSSV 2019 年 7 月 15 日
YOu use both...calculate the error....which ever gives you less error proceed with that.
MatLab Code N
MatLab Code N 2019 年 7 月 15 日
What do you mean by that? Shouldn't there be a standard way of calulating the Orthogonal Distance Regression?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

質問済み:

2019 年 7 月 15 日

コメント済み:

2019 年 7 月 15 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by