Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fitting a line that passes through the origin (0,0) to data

I have a set of points (x,y) and I need to find the line of best-fit that passes through the origin using MATLAB.

like image 532
dr_rk Avatar asked Sep 19 '12 13:09

dr_rk


People also ask

Does a regression line pass through 0 0?

The regression line is forced to pass through the origin (0, 0). Therefore, unless your regressors are standardized or mean-centered, it's not a good idea to set the intercept to 0 when fitting the model.

Does the line of best fit go through 0?

A line of best fit can only be drawn if there is strong positive or negative correlation. The line of best fit does not have to go through the origin.

What does it mean for a line to pass through the origin?

If the line cuts directly through the origin, this means that at one point, one of these coordinates is equal to zero.


2 Answers

The best fit line, in general, passes through the centroid of the data (average the x's and average the y's). So find the centroid and plot the line from the origin through the centroid.

like image 108
David Chandler Avatar answered Sep 23 '22 07:09

David Chandler


if you have the "Curve Fitting Toolbox" you can use

f = fit( x, y, 'a*x' );
like image 32
Daniel Avatar answered Sep 26 '22 07:09

Daniel