Simple linear regression is a method used to solve for a variable, usually ‘y’, with the formula: \[ y = \beta_0 + \beta_1(x) \].
Simple linear regression is a method used to solve for a variable, usually ‘y’, with the formula: \[ y = \beta_0 + \beta_1(x) \].
Take the function \(y = 10 + 5x\)
To solve for an arbitrary point on the line, say when the x axis is at 5, we insert 5 as the x. This results in \(y = 10 + 5(5)\) making \(y = 35\) when \(x = 5\) giving us the point (5,35).
With two points we can calculate the slope, or in this case because we already know the slope is 5, we may use it along with the 2 points we now know (the y-intercept and (5,35) to graph the remaining points on the line.)
Now again using ggplot2
This time we will attempt to solve for \(x\) (i.e. \(y\) is given to us.) \[20 = 4 + 4x\]
This gives us our first point, (4,20). With one point and our slope of 4 that was given to us, we can calculate other points and chart the line.