Calculating Error with the Help of the MSE Equation on the Simple Linear Regression Lines
Hello everyone, in this writing, I am trying to explain what is the meaning of error and how we can calculate it thanks to the MSE equation. The topic titles that I will follow are as follows:
- What is a simple linear regression?
- What is the error?
- MSE Equation
- What is a simple linear regression?
Simple linear regression is a linear function that expresses the relationship between the independent variable and the dependent variable.
We need to find b1 and b0 values so much close to the actual values that the error is minimal. These terms are representing that:
bo is the point that intersects with the y-axis.
b1 is a slope of the line.
x1 is an independent variable and y is a dependent variable that is changing with the independent value, x.
This formula above generates the predicted model. The sample model is as follows:
2. What is the error?
The error is calculating with the help of this equation:
The means of calculating the error formula is subtracting from actual y values to predicted y values. For example on the graph, images of the error as follows:
As it can see, sometimes we can also find the error may be negative. This is a problem in reaching the model error because we need to sum all the errors to reach the model error so that some errors will be disappeared during the addition. That’s why we are able to use the MSE equation below to solve this problem:
3. MSE Equation
The equation means mean squared error. With the aid of the MSE equation, some errors that come up negative will not be disappeared because the square operation will protect the negative values during the addition. If we further the MSE equation, we can find equations for b0 and b1 values. Progress happens as follows:
To find b0 and b1 values, we can differentiate easily. If we differentiate, the equations become like these:
In spite of being able to calculate like this, these operations take so much time. Luckily we have got programs that doing operations for us fast and easily! In my next writing, I will mention a program called is JupyterLab and demonstrate its implementations.
Thanks for reading!