Introduction to Regression Analysis [using Excel] | by Pranav Kaushik | Towards Data Science

Not familiar with tools like Python or R?
It’s perfectly fine! You can still perform a regression analysis using Excel. And you don’t need to have any programming knowledge to do that.
Excel is undoubtedly a very powerful tool when it comes to data analysis. You can do data cleaning, perform analysis using pivot tables, design visuals and much more.
If you’re looking to explore more on data analysis using Excel, here are a few excellent resources you can check out.
Data cleaning: 10 Super Neat Ways to Clean Data in Excel Spreadsheets
Data analysis: Introduction to Data Analysis using Excel
Pretty amazing right!
But wait. There’s more!
Excel has an add-in called “Data Analysis ToolPak” that allows you to perform various statistical operations, including Regression just with the click of a button.
Now that we’ve talked enough about Excel, let’s move on to Regression.
I’m simple terms; Regression is the process of determining the relationship between the dependent variable and a set of independent variables.
Consider the following example:
This table shows the relationship between the advertising cost spent on TV with the respective sales revenue.
Now if you need to find the relationship between the two variables, the most straightforward way is to plot a scatter plot which looks like this.
Observing the plot, we can say that there is a positive relationship between the ad spent on TV and sales revenue.
That’s a sign of positive correlation.
Now, let’s say that we need to quantify the relationship. How will you do that?
Again, it’s pretty simple. Just draw a line that best fits all the points shown in the scatter plot, and the line equation will give you the relationship between variables.
Sales = 0.0555*(TV) + 6.9748
That’s the basic idea of Regression. It is quantifying the relationship between variables by fitting all points using a function.
The method used to determine the best fitting line is out of the scope of this article. But if you’re interested, it’s done by a technique called ordinary least squares.
The example that we just saw is called simple linear Regression which involves only one independent variable or feature (advertising cost on TV).
But the same concept of Regression can be expanded to multiple independent variables or features, which is called multiple linear Regression.
For example, check out this table.
Here, we have advertising costs spent on TV, radio and newspaper along with the respective sales revenue.
We won’t be able to visualise the relationship on a 2D plane, but the concept of linear Regression can still be applied to determine the best fitting function for all these points.
And the function will be of the form:
Sales = 0.0544*(TV) + 0.1070*(Radio) + 0.0003*(Newspaper) + 4.6251
So this is the basic idea behind Regression.
Now let’s look at how to implement Regression using Excel.
The first step is the add data analysis toolpak
Data Analysis ToolPak is not available by default, and you need to activate the add-in separately.
To activate, go to File -> Options -> Add-ins and then activate the Analysis ToolPak. Once you’ve activated the add-in, it should appear under the Data tab of your toolbar.
Once you’ve added data analysis toolpak and download the data in an Excel file, move to the next step.
To perform the Regression, go to Data Analysis Tools and select Regression from the available options. Once you choose Regression, the following window should appear.
Enter the range of the dependent variable in the Input Y Range and range of independent variables in the Input X Range. And then press, OK.
You’ve successfully completed performing Regression using Excel!
Now let’s look at how to interpret the results.
Once you’ve performed Regression, your result page should look something like this.
If you take a look at the third table, there is the first column named coefficients. This column gives the values of the coefficient of each variable in the multiple linear regression equation.
Sales = 0.0544*(TV) + 0.1070*(Radio) + 0.0003*(Newspaper) + 4.6251
The other measures that have been calculated on the tables are used to compare the performance, statistical significance and other factors. These measures require a good understanding of statistics, and hence I haven’t discussed all that in this introductory article.
Once you’ve performed Regression, there are two things that you can do.
Analyse the relationship between variablesBuild a predictive model
Analyse the relationship between variables
Build a predictive model
Since we already talked about analysing the relationship between variables, let’s look at how to build a predictive model.
A predictive model is nothing but a process of predicting the value of the dependent variable by providing values for the independent variables.
So again, our multiple linear regression equation is the predictive model function where if we enter the values of the independent variables, we can get the predicted value of Sales.
For example, if you want to predict the sales revenue for the following combination of advertising spends,
TV = 100
Radio = 200
Newspaper = 500
Enter the values into the multiple linear regression equation. This will give you a sales revenue of 31.6377 which is the predicted revenue.
I hope that you would have got a good understanding of what Regression is, implementation using Excel, analysing the relationship and building predictive a model.
And of course, this is just an introduction of Regression, and there are a lot of other concepts that you can explore once you’re familiar with the basics covered in this article.
You can download the excel file containing the data and steps covered in this article here.