How to create linear regression from starting point?

david2019

New member
Joined
Apr 26, 2019
Messages
4
How would you calculate linear regression from a starting point? The graph below shows the actual linear regression line (yellow/orange), but what if I wanted to start linear regression calculation at y=25 like the black line? The black line (drawn by me) was just a rough estimate of what the actual linear regression from the starting point 25 might look like.

Ofcourse you could add your starting value to the b of y=mx+b, but all that would do is shift the line.
11899

This was a question that was posted on stackexchange, and I did not understand what Mark Fischers answer was. Would someone be able to better explain and/or give an example? (https://math.stackexchange.com/ques...egression-from-starting-point/3203883#3203883 )

I am in university for math and statistics, but thus far have not taken any stats classes so I am a bit lost on the subject.
 
Are you attempting to do this by doing all the calculations manually or by using line-of best fit capabilities on a Graphics Calculator or Excel?
 
If you don't mind, take a look at the stackexchange post by Mark Fischers. This is what I am trying to implement, but am having difficulty deconstructing what he is saying mathematically in a step by step way.
 
There is a way to force a regression line through the origin. That is, the equation will be of the form y=mx rather than y=mx+c.

If you move all your points down 25 units, then do a linear regression in the form y=mx, you will get a line through the origin.

Then move the line (and the points) up 25 units. This will give you the line you require in the form y=mx+25.
 
Thank you for your explanation. I was able to code this pretty quickly.

sum greater then zero = sum of (y-line) greater then line
sum less then zero = sum of absolute value of (y-line) less then line

Original linear regression:

11907

Modified linear regression with what you explained:

So yes, although it does start at y = 25. Linear regression is not calculated in the same way as linear regression guarantees that the sum of (y-line) greater then line and sum of absolute value of (y-line) less then line are the same as show in picture 1.

11908

This graph was produced using the modified linear regression from the above picture with a modified to fit "m" of y = mx + b. This is what an approximation of the graph should look like with a very small error as show by the difference of sum greater then zero and sum less then zero.

11909

Is there any way to achieve this mathematically?
 
Last edited:
I've got no idea about coding but you don't appear to be using the "least-squares" regression line that I am familiar with.
 
If a the regression line is forced to go through a point(x1, y1) then the equation of the regression line would be:

y = (x - x1) * m + y1

Now you should be able to write your program to calculate 'm' and draw the best-fit line.
 
Top