You might have already read what linear regression is, so now let’s hop on to the equation part
Linear Regression Equation
The lower the mean squared error (mse), the better the line will be considered the best fit. Because mse cannot be 0 (which is practically impossible in most circumstances but not all), we must obtain the mse minimal value by simplifying the equation.
the equation for mse simplified,
Expanding the equation of MSE
Where,
n= the total number data points present
r= the correlation value of the dataset
sₓ and sᵧ = the standard deviation of all the y values and x values respectively
x̅̄ and y̅ = the mean value of x and y values respectively.
As r2 (0 to 1) it could lead to the term sᵧ²(1 — r²) to be 0 and sᵧ cannot be 0, This term of assistance isn’t really useful when formulating the linear regression equation.
If (msₓ-rsᵧ)² = 0, then m = r(sᵧ/sₓ), where m can alternatively be represented as mᵧₓ.
If (y̅ — b — mx̅̄)² = 0, then, y̅ = b + mx̅, or b = y̅ — mᵧₓx̅̄, where b can alternatively be represented as bᵧₓ ( sounds as b y on x ).
putting bᵧₓ and mᵧₓ in the main linear equation, it would look something like this,
Deriving the Regression Equation
- The slope is simply the correlation divided by the standard deviation ratio.
- The intercept resembles the classic linear equation with x and y representing the respective means. And x is referred to as xi since Y will be the unknown line for the input of x.
This is a graphic illustration of how the regression line will eventually look.
![](https://i0.wp.com/thecorrelation.in/wp-content/uploads/2021/12/New-Project.png?fit=96%2C96&ssl=1)