Finally, we're going to be looking at the ANOVA process, which provides us with a statistical test
to determine whether two or more population means are equal to one another.
Now this ANOVA word comes from analysis of variance.
We just take the and the O and the VA to create ANOVA, but if you hear ANOVA, just think analysis
of variance.
What we're trying to do is analyze the variance within and between samples from different populations.
So the simplest way to get our arms around ANOVA is to work through an example.
Let's say that we manage all of the customer service call centers for a large company and we have one
customer service center in the northeast, one in the Northwest and one in the Southeast.
And what we want to know is whether mean call time differs across these three different call centers.
Now, the issue here comes back to this idea of variance.
Let's just focus in for a second on the call center in the northeast.
We know that if we take samples of calls from that Northeast call center, we're going to get a bunch
of different samples, each of which has its own mean and standard deviation, which means there's variance
among samples within the Northeast call center.
There's also variance within the Northwest call center and variance within the southeast call center.
And then, of course, we could have variance between the different call centers depending on which
sample we pick from each center.
So what we're trying to do here is analyze how much of the variance is coming from within the sample
that we take from a call center versus between the samples that we take from each call center.
Now, the set of hypotheses that we're going to be testing is always here that the null hypothesis is
that the three means are equivalent.
So the mean from the Northeast call center is equal to the mean from the Northwest call center, which
is equal to the mean from the southeast call center.
In other words, mean call time for the entire population of calls coming out of the Northeast call
center is equivalent to mean call time for the entire population of calls coming out of the northwest
call center.
And those are both equivalent to population mean for the southeast call center.
So by default here, this is our null hypothesis, which means then that our alternative hypothesis,
what we're trying to analyze is whether there's actually any difference in call time across call centers.
So if we say in our null hypothesis that call times are all equivalent, our alternative hypothesis
is that these call times are not equivalent.
What we've done to try to investigate this set of hypotheses is we've taken a sample from each of the
call centers of ten call times each.
Let's say that these call times are in minutes, and now we want to use a statistical test to see if
the call times are different across call centers.
So to use ANOVA to do this, the first thing that we need to figure out is how many different groups
we have and how many different data points we have within each group.
So here we have three groups, the northeast, northwest and southeast.
So we'll say that M is equal to three.
We've taken a sample of ten calls from each call center.
So within each group we have an equal ten.
The sample size is N equals ten.
So we have M equals three groups, each containing N equals ten data points.
Our next step then, is to calculate the mean within each group.
So for the Northeast group here, we add up these ten data points and then divide by ten to find the
mean of the Northeast.
So we could think about this here as our sample mean, we could call it x bar for the Northeast.
We do the same thing for the Northwest.
And so we have a sample mean for the northwest and we do the same thing for the southeast.
So we have a sample mean for the southeast.
So mean call time in the northeast is 3 minutes mean call time in the northwest is 6 minutes mean call
time in the southeast is 4 minutes.
Now, of course, just like with all of these statistical tests, the fact that the sample means are
different doesn't tell us that we can reject the null and lend support to the alternative hypothesis
that the population means are different.
Just because the sample means are different doesn't automatically mean the populations are different.
We need to show with statistical significance that these sample means are different enough such that
we can justify making a conclusion that the associated population means are likely to be different as
well.
Now, once we have the mean within each group and remember, we can use this analysis of variance process
on any number of groups as long as we're using two or more groups.
So this is a one way ANOVA that we're performing on three groups.
There are also two way ANOVA and lots of other ANOVA variations, but right now we're just going to
focus on one way ANOVA as we happen to be using three groups here and we'll look at how to work through
an example with this particular kind of test.
Now back to the means that we.
We've calculated we have the sample mean for each group.
The next thing we need to find is this grand mean.
And if you remember before, when we talked about combinations of random variables, we said that the
mean of the sum was equal to the sum of the means.
So to find this grand mean, all we have to do is take the mean of these three sample means so we can
take three plus six is nine plus four is 13.
13 divided by three Sample means is 4.33 repeating so the grand mean is 4.3, three or four and a third.
We could also have found this value by adding up all 30 data points here.
Three groups times ten data points each is 30 data points.
We could have added up all 30 of these individual values and divided by 30, and we would have found
this exact same value for the grand mean so we can find it either of those two ways.
But since we have to calculate the mean of each group anyway, it's a little faster to find the means
first and then just add these means together.
Divide by the number of means to get this grand mean.
So this is part one of our ANOVA process.
We have three more parts.
First, we're going to find total sum of squares.
Then we're going to find what's called sum of squares within and then sum of squares between.
And then we'll talk about how to bring all of those parts together.
So looking at total sum of squares here, these are the calculations already done for us in software
in a spreadsheet.
But the formula that we use to find all of these values is this one here.
So we take the sum of each individual data point minus the grand mean.
So we'll say sum x, sub data point minus the grand mean, and then we square that quantity and then
we add up all those squared values here.
So you can see that we're getting a sum of squares.
The fact that we use the grand mean reminds us that we're calculating here total sum of squares.
In other words, we take this first value from the Northeast here too, and we subtract the grand mean,
the value we get.
We've recorded right here in our table, -2.33.
If we look at the last value for the Northeast three down here, we take three -4.33 and we get -1.33.
And we've recorded that here in our table.
If we take the first value for southeast, we take five minus the grand mean 4.33 and we get 0.67.
And then if we look at the last value for the southeast here we take four minus the grand mean 4.33
and we get -0.33.
So this whole left side of the total sum of squares table gets us all of these values right here, just
the x abi minus the grand mean values.
The right side of this table is what we get when we square those values.
So we're just taking -2.33 and squaring it to get this 5.44 or down in the lower right here we're taking
-0.33 and squaring it to get positive 0.11.
So we square all of those values.
That gives us now this value each squared value and then to find the sum, the whole thing.
Here, we add up everything from this right hand side, all 30 of these squared values, and we get
this value right here, 196.667 or 196 and two thirds.
That is our total sum of squares value.
And we should know also that the degrees of freedom for total sum of squares is always m times n minus
one, where m in our case is three and is equal to ten.
So M is the number of groups and is the sample size.
That's our degrees of freedom for total sum of squares.
Now we need sum of squares within, and the calculation here is really similar here.
Basically the idea is that we're taking each data point, so we'll call each data point X and we subtract
from that the mean for its own data set.
So we'll just call this the mean x sub pi.
And once we find each of those differences, we square those values and then we add them all up.
In other words, we take each data point.
So looking here at the Northeast, we start at the top of that column.
So the first data point for the Northeast is two.
We subtract from that.
This data sets own mean.
It's mean is three.
The mean for the Northeast is three.
So we take two minus three.
That's a negative one.
We square that, we get a positive one.
And so you see those two values recorded here, negative one for the first value for the Northeast and
then the square of it.
Positive one here on the right hand side, if we take the last value in the Southeast sample.
So this four at the bottom of the Southeast column, we take four, we subtract its own mean.
The mean for the Southeast is four.
So we take four minus four and we get a difference of zero.
We square that value and we still get zero.
And we see those two zeros recorded here at the bottom of the Southeast column and then the bottom of
this southeast column.
These are the differences.
These are the squared values.
So to get this whole left hand side of this sum of squares within chart, we find these differences
to get this whole right hand side.
We square those differences and we record those values here on the right hand side.
Then we add up all 30 of these squared values.
We take the sum of those squares and the sum of squares is therefore this entire value here or in this
specific example, 150 the degrees of freedom for sum of squares within is m times quantity and minus
one.
And then the last thing we have to do is calculate sum of squares between.
So for sum of squares between, for every single data point, we take the mean for the set and we subtract.
The grand mien.
And then we square those values and then we take the full sum.
In other words, for the first data point here for the Northeast, the two at the top of the Northeast
column, we don't actually use this to at all, but since we're looking at a data point for the Northeast,
we need to use the mean for the Northeast.
So the mean is three.
So for this data point right here, we take the mean associated with that group.
The mean is three we subtract the grand mean of 4.33.
So three -4.33 is -1.33.
And we see that value right here recorded in the left hand side of the sum of squares between table.
And then we square that -1.33 and we get a positive 1.77 and we see that positive squared value here.
Now realize that we're always going to get the same value for every data point in the Northeast Group
because we're always using the same mean for the Northeast and the same grand mean.
We're just making this calculation ten times for all of the ten data points in the Northeast sample.
So this northeast column over here where we find this difference right here, we see that same value
in the entire Northeast column, that -1.33.
The same is true for the entire Northwest column.
So even though we have these ten data points here, we're always just using the mean for the Northwest,
which is six.
We take six minus the grand mean of 4.33 and we get 1.67 and we see that value being recorded for every
data point in the sample for the Northwest.
So we see the same value repeated ten times for northeast, the same value repeated ten times for the
Northwest and the same value repeated ten times for the Southeast.
And then we square all those values to get the right hand side of this table, to get this part of our
calculation.
And so, of course, we see identical values throughout the entire Northeast column, through the entire
Northwest column and through the entire Southeast column.
And then we sum up all 30 of these values on the right hand side of the sum of squares between table
to get this entire value here.
Or in our specific case, the sum there is 46.67, and the degrees of freedom for sum of squares between
is a minus one.
Now, that was a lot of numbers that we just threw out, but really the concept that's being conveyed
here is actually pretty simple.
If we just go back for a second to this sum of squares within chart, basically this whole middle area
in red here, all we're trying to look at is the amount of variance within each of these individual
groups.
If we focus in here on just the Northeast, we know the mean of the Northeast is three and then we have
ten data points for the Northeast.
So if we want to think about finding the total variance in this Northeast sample, we would just take
each of the data points for Northeast.
We would subtract the mean for the Northeast.
We square that value and we essentially have a square error.
We have a certain amount of variance for each of these data points when we do that same thing.
So we can think about the sum of everything in this column right here as all of the variance within
the Northeast Group.
Everything in this column is all of the variance within the Northwest Group.
And everything in this column is all of the variance within the Southeast Group.
So if we then add up all three of those together, we're sort of getting a figure or an idea of the
total variance that we see within inside of each of these individual groups.
So the point then is that this calculation is giving us a picture into the variance inside of each group.
This calculation is giving us a picture into the variance in between these three groups.
And then this is total variance.
And what we notice is that in fact the sum of.
Some have squares within and some have squares between is equivalent to total sum of squares.
When we add 150 to 46 and two thirds, we get 196 and two thirds.
So these two variances add up to total variance.
Furthermore, the degrees of freedom will add up the same way.
So if we add up the degrees of freedom for sum of squares within and sum of squares between, we will
get the degrees of freedom.
For total sum of squares.
We'll see that here.
If we take m times n minus one plus degrees of freedom from sum of squares between M minus one.
If we then expand this, we get m n minus m plus m minus one.
We get these two values to cancel minus M and plus m, and we get m n minus one or the degrees of freedom
for total sum of squares.
Now, once we have these three values, for total sum of squares, sum of squares within and sum of
squares between, we can calculate our test statistic value.
And when we use this process of ANOVA on a one way analysis of variance, we will use an F statistic
which we calculate this way, where we take sum of squares between divided by its own degrees of freedom,
and then we look at the ratio between that and sum of squares within divided by its own degrees of freedom.
So in our case, if we plug in what we already know here, we said that sum of squares between was 46
and two thirds, so 46.667 approximately.
Remember, in our case we have three groups.
So M is equal to three.
M minus one is two.
That's our degrees of freedom for sum of squares between and then sum of squares within we have as 150
and then we divide that by its own degrees of freedom.
MX times n minus one while M is three, KN is ten.
So here we get ten minus one or nine, nine minus three is 27.
And when we use a calculator to find this value, we get approximately 4.200.
So what we have here with this F statistic is actually a ratio of chi squared distributions.
We talked about chi squared tests before the numerator of our F statistic formula here is actually a
chi squared distribution with M minus one degrees of freedom, and the denominator of our F statistic
is actually a chi squared distribution with m times n minus one degrees of freedom, which means that
the F distribution is just a ratio of two chi squared distributions.
Now, when it comes to calculating this F statistic, what we can say is that if the numerator is significantly
larger than the denominator, so in our case our numerator is approximately 23, our denominator is
approximately five.
If we're just doing rough math here, if the numerator is significantly larger, what that means is
that more variation is explained by the variation between groups than by the variation within groups.
Here we're dividing essentially this idea of the variation between groups by essentially this idea of
the variation within groups.
So we can see because 23 is significantly larger than five, that may be what this f statistic is telling
us is that we can explain more of the variation as a difference between groups then within the groups
themselves or just noise in the data.
Whereas if we have the opposite scenario, if the denominator here is significantly larger than the
numerator, then that means that we find more variation within the groups themselves as opposed to between
the groups, which might mean that there isn't necessarily a huge difference between the groups and
therefore that we might have trouble rejecting the null hypothesis.
It'll be easier for us to reject the null hypothesis when the numerator here is larger than the denominator,
because when the numerator is larger than the denominator, we're going to have a larger F statistic
and the larger the F statistic, the more likely it is that we can reject the null and therefore lend
support to our alternative hypothesis.
But no matter what we have in the numerator and denominator of our F statistic, what it really comes
down to is the actual F statistic that we calculated in this case about 4.2.
Our next step is to look up the critical value in our F table.
Let's assume here that at the beginning, when we set up our hypothesis statements that we chose a significance
level, an alpha value of five.
So alpha is 0.05.
There's a different F table for every level of significance alpha.
So if we choose alpha equal to 0.05, then we need to go find an F table for alpha equals 0.05.
These are very easy to find online.
You can quickly find one for alpha equals 0.05, for alpha equals 0.1, all of the common alpha values.
So this table here is an F table for.
This alpha value here.
Alpha is 0.05.
And what we have to do then is cross reference the degrees of freedom in our numerator with the degrees
of freedom in our denominator.
In other words, we're looking at two compared to 27.
Now I've modified this table so that you can see the beginning of at the top of it, where both the
degrees of freedom are equal to one.
So this is always the top left hand corner of the table.
And then I've skipped a bunch of rows to jump down to the rows where we can see that the denominator
degree of freedom is 27.
So in our case, denominator degrees of freedom is 27.
We see that here and numerator degrees of freedom is two.
So we find that here and we just find their intersection in our F table for this particular alpha level.
And we see that we get a critical value of 3.35 for all we have to do now is compare our F statistic
to the critical value.
In our case, 4.2 is greater than the critical value of 3.354.
And whenever the F statistic that we calculate is greater than the critical value, as always, that
means that we can reject the null hypothesis, which means that we do in fact lend support to the alternative
hypothesis that there is actually a statistically significant difference between these three groups
and that the differences that we're seeing is not just caused by variation within the groups or noise
within the data.
If we get to this point and we realize that we don't have a statistically significant F statistic,
we can try to increase the value of the F statistic.
We can try to do that either by increasing sample size or we can try to do that by reducing the variation
within each of these groups.
Oftentimes that can mean breaking groups down into more homogeneous categories.
Maybe, for instance, in our Northeast office there are two divisions one division that handles only
English speaking calls and another division that handles calls from international language speakers.
We could hypothesize maybe that the international calls take longer because they have to be routed to
the appropriate call center representative who can speak that language.
So maybe the fact that there's those two departments within this Northeast office is causing more variation
in this Northeast data, and we can reduce some of that variation if we segment those two divisions
into separate groups, something like that.
So those are a couple of things we can look at if we don't find significance when we calculate this
F statistic and we want to try running the whole test again, Keep in mind, of course, that we walked
through this whole process by hand.
We used a spreadsheet to calculate these numbers, but ultimately what it came down to was calculating
this F statistic by hand and then looking up our F statistic in comparison to a critical value that
we found in a table.
Typically, though, that's not the way that we run this ANOVA process.
Of course, typically these days we're going to do this whole thing with software, which means we'll
be able to feed in just our raw data and the software will immediately be able to give us all of this
information we spent time calculating.
We'll be able to get the mean for each group, the grand mean, and instantly see total sum of squares,
sum of squares within and sum of squares between.
We'll know immediately the value of our F statistic and the software.
Instead of looking this statistic up in an F table, it'll calculate automatically the probability,
the p value of finding an F value that's greater than or equal to the F statistic that we found.
If that probability is less than or equal to the alpha value that we set, then the conclusion will
be that we can reject the null.
But even if we're using software, this is what's actually going on behind the scenes.
So this ANOVA process is extremely powerful.
There are many different ways that we can use it.
This is just one example of a one way ANOVA with three groups, but while it is extremely powerful,
it does of course also have its own limitations.
For example, this F test that we ran told us that we could reject this null hypothesis, which means
that we can lend support to the idea that the population means are in fact different.
That mean call time is different across these three call centers.
But notice that what it didn't tell us is which means we're different.
So we don't know if we should conclude that mean call time is different for each of these call centers.
Or maybe just that.
For example, the Northeast and the Southeast have similar mean call times and maybe the Northwest is
the only call center that happens to be an outlier.
Maybe that's the only call center that's causing us to make this conclusion that the population means
are different, that they're not the same.
So to actually figure out which of these call centers is causing the difference, we might need to run
another set of tests.
But at the very least, this analysis of variance process and understanding of this process gives us
a great place to start.