In this post, let me explain how to use R programming for linear regression.
I am taking the same dataset in R to produce the linear regression.
Run the below codes.
# new value for year 2011
year2011 <- data.frame(Year=2011)
#predict the sales amount.
Before starting with linear regression, let us try to understand the machine learning concepts.
As of today, machine learning is one of the trending technologies as the applications are started to consume real-time data and deliver machine learning services.
As part of machine learning, we have three different types of machine learning models available.
In Supervised Learning, the system tries to learn from the previous examples that are given.
Under supervised learning, we have classification and regression models.
One of the common and simple techniques for predicting a continuous variable is called linear regression.
It assumes a linear relationship between the outcome and the predictor variables.
The linear regression equation can be written as y = b0 + b*x + e, where:
This post covers the linear regression on excel and R studio.
Linear Regression on Excel
Follow the below steps to perform the linear regression in excel
Step 1: Consider you have year wise sales amount. You are in the situation to predict the sales amount for the year 2011.
Step 2: Create a scatter plot like below with Year and Sales Amount
Step 3: Right-click on the line and choose trendline.
Step 4: Display the equation on the trendline by selecting the checkbox on the Format trendline properties.
Step 5: Predict the value using the generated formula for existing values.
Step 6: Predict for the year 2011.
As you can see the values are not 100% correct, we need to adjust the con-efficient and reduce the r2 values to get the perfect result.