(upbeat music)
- Hello, I am Professor Rick Jerz
and I welcome you to this session
titled Multiple Regression Using Tableau.
In this session we are going to learn
how to explore multiple regression analysis using Tableau.
Multiple regression is a complex
and demanding statistical analytical technique.
Let's see how Tableau might help.
I think you are going to enjoy this session.
Let's get started.
I begin Tableau and in this case,
I'm going to connect to my Excel file
that contains multiple regression.
In my Excel model I have used a defined name range
to define this input matrix data entry area
of my multiple regression model.
In Tableau, I see this defined name range
and I'm going to drag this into my work area for Tableau.
This defined name range includes the entire data table area
of this model and it contains a number of columns
that I don't need.
I will simply hide these columns in Tableau.
There we go.
Now I have the data that I want to work with.
Before I go much further I'm going to save this file
and call it Multiple Regression.
Okay, I'm ready to begin my visualizations on sheet one.
I might as well rename this sheet
Multiple Regression Analysis right now.
Doing exactly the same steps that I did
for simple regression analysis,
I can drag Cost to Rows, Age to Columns,
switch both of these variables to Dimensions,
change the shape of the marker
and I might as well turn aggregate measures off right now.
I can add a trend line, change its color,
and I have quickly created a SCADA diagram
for the one independent variable age versus heating cost.
Now here's the fun part,
I can very quickly add insulation and Temp to Columns,
change them over to Dimensions
and very quickly I can see how these three variables
all relate to cost.
I can add confidence levels to all of these charts
by picking analysis from the menu,
trend lines, edit all trend lines,
and confidence intervals.
Tableau is providing me a pretty powerful visualization
of these independent variables
versus the dependent variable that would take
a lot more effort to do in Microsoft Excel.
If we right click on the model
and choose Trend Lines, Describe Trend Models,
Tableau displays some data for each of these graphs.
I do want to warn you that this is not the same data
that is shown in my Excel summary data.
For example, the P values do not match.
The data that Tableau is showing us
is for each individual independent variable
plotted against the dependent variable.
In my Excel model, the summary area
shows us P values for all of these independent variables
taken together, meaning in aggregate.
So be careful.
Another thing that you should be careful to not do
is to visually interpret the slopes
of each of these regressed lines.
For example, you might want to say that temperature
has the greatest effect on cost.
But we can't do this because the X axis scales
for each of these independent variables
is not the same.
Remember that when you are producing graphics from data
that by changing the scale of data,
you can dramatically overemphasize or underemphasize
the variables of interest.
Tableau does not support 3D graphs yet.
And actually, we would need a 4D graph
to properly display our three independent variables.
But even though Tableau does not have 3D graphs,
we can use 2D graphs creatively
to represent more than two variables.
Let me show you another way
that we could visualize this kind of data.
I begin by duplicating this multiple regression sheet.
I will remove insulation and temperature from Columns.
Then I add insulation to Size
and temperature to Color.
I will change the color scheme
so that red reflects warmer temperatures,
green cooler, and I will change the symbols to circle
and slightly adjust the size.
You might see that this is an interesting visualization
where we have combined three independent variables
in this 2D work space
and we used color and size for two
of the independent variables,
creating these kinds of visualizations
is where Tableau stands out among its competitors.
What we can see is that when temperatures are warmer,
heating costs go down.
We can also see that having more insulation
in a home also somewhat reduces heating cost.
Yep, pretty cool.
Another interesting this that we can do with Tableau
is to see if we can use it
to test some of the assumptions
for using multiple regression analysis.
For example, the first assumption
is that there is a linear relationship
and we have learned that we can use a scatter diagram
to plot the dependent variable
against each independent variable.
Well, we have already done this
with our multiple regression visualization.
If we hover at the regressed line for the temperature
versus cost regressed line,
we will see a R value of .65.
The coefficient of correlation
is the square root of this value
which is about .8.
This suggests a pretty strong linear relationship.
We can do the same thing for the age
versus cost regressed line
and see that its coefficient of determination is .29.
Its coefficient of correlation therefore, is about .56.
Yep, a fairly strong relationship,
not as strong as temperature versus cost.
For the insulation independent variable,
the R value is not quite as strong, .06.
So, its coefficient of correlation is only around .25.
The strength of this linear relationship
is a little weak and it suggests
that we might want to explore this insulation variable
a little bit more.
One thing that we could quickly do
in Tableau is to edit the regressed line
and pick one of these other model types,
Logarithmic, Exponential, Power, or even Polynomial.
We could compare the R value for these other model types
to the linear regressed line model type
and see if any of these other models types
produce a stronger coefficient of correlation.
I actually did this and compared R values
for these other model types
and found that the biggest R value
is still for the linear relationship.
It is just that this linear relationship
is not the strongest.
The second assumption, homoscedasticity,
states that the variation of residuals
are the same, meaning constant.
And we are told that we can use a scatter diagram
by plotting the predicted versus residuals.
There should be no trend or correlation.
We can create this plot very quickly in Tableau.
I drag predicted to Columns,
residuals to Rows,
I set both of these to be Dimensions,
just like we have done before.
I turn off aggregate measures
and I add a trend line.
For this data, we do not see any trend,
and if I hover at the trend line,
I see that the coefficient of determination is nearly zero.
The third assumption is that the residuals
are normally distributed.
We are told to use a frequency diagram
to plot the residuals.
The residuals should be normally distributed.
In an earlier session, we learned how to create
frequency diagrams for continuous data.
The first thing that we need to do is create bins.
I do this by clicking on Residuals, then Create Bins.
I will pick a Bin Size of 20.
I then drag Residuals (bin) to Columns
and Number of Records to Rows.
The resulting frequency diagram seems to show
that the residuals are normally distributed.
The fourth assumption is that the independent variables
should not be correlated.
My Excel model calculates the VIF.
Visually, we could plot each independent variable
against each other and we can also calculate the correlation
for each of these independent variable plots.
The correlation should be less than .7.
Since Tableau shows the coefficient of determination,
it should be less than .49.
In Tableau, we can very quickly create these plots.
I can create a plot for age versus insulation,
then another plot for age versus temperature,
and last, a plot for insulation versus temperature.
By adding trend lines to each of these graphs,
I can hover the trend line
and see that the coefficient of determination
is less than .49.
Our last assumption is that successive residuals
should be independent.
This is referred to as autocorrelation.
We are told that we can use a scatter diagram
like we did in the first assumption
and there should not be any pattern
of negative or positive trend,
meaning that the slope should equal zero.
If, for example, our plot of predicted versus residuals
looks something like this,
we would be violating this autocorrelation assumption
because there is a pattern.
In this case, a negative trend seems apparent.
Well, in our plot of homoscedasticity,
we plotted the predicted versus residuals values.
And when we look at it,
it does not seem to have any trend.
If I wanted to explore whether or not
there is trend a little bit better,
what I would do is change the marks
from dots to a line.
Nope, this line doesn't seem to have any apparent trend.
Well, we are done testing all of these assumptions.
This is pretty cool to be able to do this using Tableau.
Remember that the more you practice using Tableau,
the better you get at it.
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)