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!

 Réponse acceptée

KSSV
KSSV le 15 Juil 2019

5 commentaires

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.
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')
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
YOu use both...calculate the error....which ever gives you less error proceed with that.
What do you mean by that? Shouldn't there be a standard way of calulating the Orthogonal Distance Regression?

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by