Linear Regression is the process of finding a linear equation that best fits the trend of a set of data.
2026-09-12
Linear Regression is the process of finding a linear equation that best fits the trend of a set of data.
This is a scatter plot, while trends are visible, the exact line is difficult to parse.
This is a graph of the price of diamonds in relation to their carat. The blue line represents the linear regression model that predicts this relationship. The correlation shown here is not exceptionally strong.
This is a graph of the height and weight of a set of people. This time, the correlation is stronger, but with a smaller population. ## What forms the line? The line can be represented by the formula: \(y = \beta_{0} + \beta_{1}x\), where \(\beta_{0}\) represents the line’s y-intercept, and \(\beta_{1}\) represents the line’s slope.
As seen earlier, the line almost never fits the data exactly, which means there must be some way of seeing how well the line fits the data.
One way to know this is the “coefficient of determination”, denoted by \(R^2\), which is within the range $0 R^2 $. It represents the strength of the regression model, the closer the one it is, the more accurate the model’s predictions will be.
In R, the following code can be used to find the linear regression of, for example, the women set from earlier:
lm(weight ~ height, data = women)
Call:
lm(formula = weight ~ height, data = women)
Coefficients:
(Intercept) height
-87.52 3.45
There are other regression models, that fit data to other models, but nothing quite hits the same as fitting a relationship to a straight line.