Member-only story
Polynomial Regression in R — when to use and how to use
( Sometimes tweaking linear model by few parameters make your model more accurate)

Let’s say we want to perform regression analysis on the non-linear dataset. For example, we can take a look at the level of an employee vs. salary offered dataset available here. You are free to use your own dataset for the problem, the requirement is only that the data should be non-linear. If it is linear, simple linear regression will work just fine. If you are interested in linear regression as well check out my linear regression for busy data scientists tutorial here. The data looks like the following:

Let’s create a linear plot for our data using linear regression. The tutorial for performing simple linear regression is here.

Now it is clear that regression is not doing good in our data, so we need some kind of non-linear model.
So now let’s create additional features for polynomial regression.
> data$Level1 = data$Level^2