These are sequential steps which need to be followed while building a linear regression model:
1. Start off by dividing the data into train and test sets, this step is vital because you will be building the model on the train set and evaluating its performance on the test set.
- You can do this using the sample.split() function from the “catools” package. This function gives an option of split-ratio, which you can specify according to your needs.
2. Once, you are done splitting the data into training and test sets, You can go ahead and build the model on the train set.
- The “lm()” function is used to build a model.
3. Finally, you can predict the values on the test set, using the “predict()” function.
- The final step would be to find out the RMSE, the lower the RMSE value, the better the prediction.