(upbeat music)
- Hello, I am Professor Rick Jerz,
and I welcome you to this session titled,
Visual Simple Regression Using Tableau.
In this session, we are going to learn
how to do simple regression analysis using Tableau.
Some of what you will learn in this session
mirrors what one might do using Excel.
I think you are going to enjoy what you will learn.
Let's get started.
Let's learn how to do some visual regression analysis
using Tableau.
Recall that regression analysis
involves determining whether one or more
independent variables are related to a dependent variable.
When we explored simple regression analysis,
we learned that a scatter diagram
is a good visual tool to use when we want
to represent visually simple regression data.
In Microsoft Excel, we can create these scatter diagrams
pretty simply and we can even have Excel insert
the linear regressed line and the linear equation.
Let's see what we might be able to do using Tableau.
I have provided to you this Excel file,
called Regression Data, that simply contains
the default data from my Excel models.
In the simple regression data set
we are trying to determine if the number of copiers sold
is related to the number of sales calls
that the sales people make.
In the multiple regression data set
we are trying to see if we can determine
the cost of heating a house based upon the temperature,
inches of insulation, and the age of the home.
In this dataset I have included the predicted
and the residual values from my Excel model.
I begin Tableau and connect to this Excel file.
I drag the simple regression data worksheet
into Tableau's data area.
I also want to work with the multiple regression worksheet
so in order to do this I'm going to click on this
down arrow next to the simple regression data.
Pick new data source.
Add this regression data, once again.
And then drag the multiple regression worksheet
into this area.
This technique allows you to work with more than one
Excel worksheet within one Tableau file.
In one of my previous sessions,
I showed you this technique,
so here I am showing it to you again as review.
The first thing I want to do is to create
a scatter diagram for the simple regression data.
In a previous session, I also showed you
how to create scatter diagrams in Tableau.
So once again, this too is review.
I click on sheet one.
Then I click on the simple regression dataset.
I drag copiers sold to rows.
And sales calls to columns.
This doesn't look very attractive at this point.
It's really not a scatter diagram.
To change this to a scatter diagram,
I click on sales call, and change this to a dimension,
and the I do the same thing for the copiers sold.
I can change the shape of the symbols
to a diamond and finally I have a simple scatter diagram
that duplicates what we were able to do in Microsoft Excel.
I can add a trend line by moving my cursor
into the graph area, right clicking,
and picking trend lines, add a trend line.
I haven't figured out any way to have Tableau
add the linear regressed equation directly on this chart.
But if you move your cursor to this trend line,
it will display the regressed equation,
R-squared, and the P-value.
When I compare these values
to what my Excel model calculates,
hmm, they are not the same.
I wonder why?
Do this.
Click on analysis.
Trend lines.
Describe trend model.
This opens up a dialog box showing you
the details of all of the calculations.
You can compare this with what my model calculates.
And you could compare this to what Excel's data analysis
tool for regression analysis shows.
What I see here is something very interesting.
Tableau shows that there are only eight observations
included in its analysis.
However, if you look at our data,
we have 10 observations.
What is going on?
Well, what is going on is that Tableau is aggregating data.
In our original dataset, we have two observations
for 30 copiers sold and 20 sales calls.
And two observations for 40 copiers sold
and 20 sales calls.
Tableau has combined these into one observation.
We don't want this to happen and there's a simple fix.
In Tableau's menu, click on analysis.
And uncheck aggregate measures.
Now when we hover this trend line,
Tableau's calculations match exactly
what my model calculates.
Of course in Tableau you can do
all kinds of things to change the color or shapes
of these symbols and you can change the characteristics
of the trend line if you wish.
Let me show you a few more things
that we can do within Tableau.
If we go to analysis, trend lines, edit trend lines,
we see that Tableau is applying linear regression analysis
to our data.
If we thought that our data better fit a curved line,
Tableau does offer the ability to fit the data
to a logarithmic, exponential, power, or polynomial curve.
From this dialog box we could also show confidence bands.
These confidence bands represent
the 95% confidence intervals when we use
our regression analysis to predict values.
Let's predict how many copiers we might sell
if we make 25 sales calls.
When I use my Excel model and enter 25 sales calls,
we see that our model predicts
that we would sell 48 copiers.
And if I enter the 95% interval,
we see that the confidence interval
is between 41 and 56 copiers sold.
Let's see if we can verify this with our Tableau model.
I can look and see an imaginary line at 25 sales calls.
Sure enough, I see that our trend line shows,
oh, about 48-and-a-half copiers sold.
With a 95% confidence interval
somewhere close to 41 and 56 copiers sold.
So this is a nice visualization
of confidence intervals and it does show that,
as we get further away from our central data
that we used to build this model,
our confidence intervals get wider.
I should mention to you that I have not
figured out any way to get Tableau to show us
the prediction interval.
Okay, we see that for simple regression analysis
Tableau adds some interesting visualizations
to analyzing this kind of data.
In my next session, I plan to show you
how to use Tableau to visualize multiple regression data.
Before ending this session,
you might want to rename this sheet
to Simple Regression, and make sure to save the file.
(upbeat music)
Thanks for taking time to spend some moments with me.
I hope that you have enjoyed what I have shared with you.
If you ever have any questions,
or need my help, please let me know.
(upbeat music)