i

R Programming Complete Tutorial

Mathematical Computation

In the case of mathematical computation of Regression prediction, we will follow the following steps:

  • We already know the Linear regression equation:y=b0+b1x

  • First, we will find the b0 and b1 coefficient values.

  • Finally, predict y, using b0 and b1.

Example: We have a data set containing x and y variable (column). Let’s calculate the coefficients (bo and b1) from this and finally predict y using coefficients and x.

Mathematical Calculation:

Result: From this above table, we can easily calculate b0 and b1 using the formula mentioned earlier. Finally, we can predict y from b0, b1, and x.

Mathematical prediction using R:

Now we are taking the same dataset with the name height and weight. We will run a simple linear regression and finally predict the weight using height.