I'm coming late to this conversation but I just want to add something that I think might aid understanding. The computation for finding the OLS estimator relies on math from linear algebra involving matrices. It's my understanding there are a few different ways to do this. A = QR shows how to create an orthonormal matrix and an upper triangular matrix. However, in the case of simple linear regression for an ordinary least squares estimate, meaning regression with only one independent and one dependent variable, you can use a shortcut equation in order to figure out the slope and the intercept of the line instead of leaning on the more complicated linear algebra math. In the case of simple linear regression, the slope and intercept follow these neat closed-form equations: the slope can be calculated by multiplying the correlation r by the quotient of standard deviation of y over standard deviation of x. In this below equation, _a_ refers to the slope and _sy_ and _sx_ refer to the standard deviation of _y_ and the standard deviation of _x_, respectively. a = r * ( sy / sx ) The intercept of the line of best fit for ordinary least squares simple linear regression can be calculated easily after you calculate the slope of the line of best fit. You do this by subtracting the slope of the line of best fit from mean of _y_, then multiplying the result by the mean of _x_. In the equation below, _i_ refers to y-intercept and the straight line over the _x_ and _y_ values is a way of referring to the mean of _x_ and _y_ respectively; we refer to these terms as x-bar and y-bar. i = y-bar - r * (sy / sx) * x-bar Our R code looks like this: r_slope <- ( sd(mtcars$mpg) / sd(mtcars$wt) ) * cor(mtcars$mpg, mtcars$wt) r_intercept <- mean(mtcars$mpg) - r_slope * mean(mtcars$wt) I know this only covers the case of simple linear regression with one _x_ and one _y_ but I hope it's helpful in visualizing this case.