In the last lesson we worked with
just one sample. But, in this lesson we're going to compare two different
samples. We're going to be talking about independent samples and dependent
samples. We'll be talking about using the Z test, testing proportions and
using the t-test. Before we get started talking about
two sample tests, let's just remind you of the five-step process of hypothesis
testing. Tthe steps are going to be the same although we're going to be computing
different statistics. We're going to be introducing you eventually to the F
statistic in the chi-square. We've used already the Z and the T, but how we
compute the Z. is going to be different depending on whether we have
one sample or two samples. But the other four steps are always going to
be the same. First we're going to state the null in the alternate hypothesis.
Remember the null hypothesis is what's assumed to be true, it's the status quo.
The alternate is what you're trying to prove. Then you select a level of
significance, which in most cases is going to be 0.05 or 0.01, but remember
anything from 0.1 and smaller can be a statistically significant level of
significance. Next, you're going to identify the test statistic are you
going to use, either the T or Z We'll be introducing
other late, but remember for right now we use the Z if we know the population
standard deviation or if we're doing a proportion. We use the T if we don't know
the population standard deviation. Then finally if we're going to formulate the
decision rule which is the critical value. We're going to look up the
critical value of the z or the T that we're comparing what we compute to. Then
we're going to compute it and we make our decision as to whether
we reject or do not reject the null hypothesis based on comparing the
computed test statistic the computed F the computed T the computer Z to the critical value. The general rule is
if what we compute is smaller than the critical value then we're going to not
reject the null hypothesis. There are some reasons that we might
want to compare two populations but what we're going to be doing a two sample
test. So with the slides that you see here, we're wanting to see if
there's a difference between the value of the residential real estate sold by
males versus females or in the college example maybe we want to compare the
test scores males versus females. So we're going to be comparing two
different samples as I just said. Remember the five steps to hypothesis
testing are going to be the same. However when we actually compute the
test statistic, how we do that will be dependent upon what we're actually
testing. In this case we're testing two samples. So this is the formula that
we're going to be using for a two sample comparison of sample means when we
know the population standard deviation. In this case we have X bar 1 minus X
bar 2 divided by the square root of the variance of population 1 divided by
the sample size 4 1 plus the variance of population 2 divided by the sample size.
Here's an example of how we're going to run through a Z test of
two samples. Assume we have a grocery store and they're wanting to see if
the self-checkout is faster than the standard checkout. We have the sample
mean of the standard checkout and the sample mean of the u-scan or the self
checkout. We also know the population standard deviation of both of
those and then we have the sample size given to us. So once we have this
information then it's very easy for us to go ahead and compute the z-score.
But first we're going to have to go through all the steps of the hypothesis
testing procedure. We need a critical value so we can compare what we
compute to the critical value to determine whether or not we're going to
reject or not reject the null hypothesis. We're ready to go through the
five steps of the hypothesis test. The first step is to state the null and the
alternative hypothesis. Remember they're trying to prove to us that though you
know we should be using the self-checkout because it's quicker than
using the standard checkout. So the alternate hypothesis is that the
standard checkout takes longer than the self checkout. The null hypothesis is
that it doesn't take longer. There is no difference or it
isn't longer. So the null hypothesis is that standard checkout is not longer
or could be equal to or not longer and the alternate hypothesis is that standard
checkout is longer. Now we have level of significance. We're going to use
the 0.01. We want only a 1% chance of making a type 1 error. Then we're going
to determine the appropriate the statistic and because we know the
population standard deviation we're going to use the Z test. Step four is to formulate the decision
rule, up the critical value. The
value we're going to compare what we compute to. This is a one tailed
test because we're only looking in one direction because we're trying to
prove that it takes longer or greater than. The significance level is 0.01
so if we were to look that up in the Z table we would end up with a critical Z
value of 2.33. That's what we're going to compare the Z value
that we're about to compute to. Now we're actually ready to
compute the Z value and remember we use this formula when we're comparing the
means of two different samples. We know the population standard
deviation of each of these different populations so we run through the
calculations and we end up with a computed z of 3.13. So
we compare that to our critical value of 2.33. The result is we're going to
reject the null hypothesis because the Z value we computed is greater than the
critical value. It's out in the tail. It's in the reject area. If it were smaller
than the critical value we would not reject the null. So we can say with at
least a level of significance of 0.01 or another words only a 1% chance of
being wrong that it appears the standard check out method is longer. So
we could say probably the u-scan method is a little bit faster at least
according to the sample that we've taken. Now we need to explore how to do a
two sample test of proportions. Remember a proportion is a ratio so
some some things that you might be comparing such as is there a
difference in the proportion of male students versus female students who pass
this statistics class final? Is there a difference between the proportion of
workers that call in sick at one plant versus another? Again we're looking at a
proportion, we're looking at a yes/no kind of thing, pass or fail, afraid of
flying not afraid of flying, yes/no kinds of things. Even with a
proportion we use the five-step test of hypothesis. But we're
going to use a different formula to compute our Z value. As we get
ready to compute our Z for two sample proportion tests we're going to introduce
you to the pooled proportion. You could look at this formula and see it's pretty simple. We're just going to have the number of
those who answered yes for x1 and the number of who answered yes for x2 divided by the total in both of them.
So instead of just having each proportion we're going to pool the
proportions together and that will be come vital in computing the Z that
you'll see on the next slide. Here you see the formula that we use to
compute the Z of a two sample test proportions. You can see as the slide
shows in a little red circle that we have to use the pooled
proportion. So we computed that first. After we've computed the pooled proportion
the formula is relatively simple: the proportion for sample one -
proportion for sample two divided by the square root and again use the pooled
proportion times one - and you can read the formula for yourself. This is very
easy to set this up in Excel or even a calculator. Now that we've introduced you to
the formula, let's go ahead and run through an example. In this example
a perfume company wants to see whether younger women or older women
prefer this particular perfume they're testing. So it gets a
proportion yes they do or no they don't so how many young women preferred
over how many young women were sampled how many older women preferred it over
how many older women were sampled. Again we're going to see if there's a
difference in the proportions Now that we've set up the
scenario we're back to the five step hypothesis testing procedure. The five
steps are always going to be there, the only thing that's going to be different,
as I said many times before, is how we compute the test statistic. So
step one is to state the null in the alternate. In this case we're assuming
there is a difference. So there is a difference versus there isn't
a difference. So the null hypothesis is that there is no difference whatsoever
between the younger women in proportion and the older women proportion. The
alternate or what we're trying to prove is that there is a difference. If so, we may want to to market this either to the older women or the younger women. We set a level of significance of 0.05.
so in this case we need to formulate the decision rule or establish
the critical value. This is a two-tailed test because we're assuming
there is no difference. We're trying to prove that there is a difference. So
in this case we have 0.025 on either tail. So our critical value for Z is 1.96.
You can see in the slide a couple of excel functions that you can use to also
compute the critical values. The next step is to actually compute the
Z statistic. So we did the sample and we found the proportions for the
proportion one we found 19 of 100 preferred it and on proportion 262 over
200. So then we pool the proportion together and you can see that the pooled
proportion is 19 plus 62 divided by 100 plus 200. We just take them all
together we end up with the pooled proportion of 0.27. We use that along
with the individual proportions for sample1 and sample2. We end up with
a computed Z of -2.21. Next, we compare the
Z value that we computed, -2.21, to the our critical value.
We can see that it is more negative, or that it falls outside do not reject area. So
in this case we would reject the null hypothesis. We have talked about doing two
sample tests. When we know the population standard deviation we use
the Z. When we're dealing with proportions we're going to also use the Z.
However, if we are working with two samples and we do not know the
population standard deviations we're going to use the T. The five-step
hypothesis testing procedure is going to be the same, but this time we're going to
use a different formula. We're going to use the T statistic and a formula to
compute the T with two samples. Here is the computation for
a T when we're working with two samples. You can see that we have to
first pool the sample standard deviations. We can do that pretty
easily with Excel. Then once we have the pooled standard two sample
deviations we can go ahead and compute the T. We'll step through
an example here but it honestly makes a lot more
sense just to use Excel. The Excel data analysis tool will do this for us very
very quickly very easily. But, we'll go ahead and step through it longhand
to show you. Then, we'll do it in Excel as well. So here is our
example. A lawnmower manufacturer has two different ways of assembling. We're taking the measurements of how long it takes to assemble the lawn mower
using this one method versus the other. We're going to try to see is there a
difference between these two methods. The five-step
hypothesis testing procedure: Fist, state the hypothesis. The alternate is that there
is no difference between these two procedures. The alternate is there is
a difference. So this is a two-tailed test because we can go either
direction it might be slower, or it might be faster, but there is a difference. We're
going to use a significance level of 0.1. We're going to use the t-test
because we do not know the population standard deviations. Then we're going to have to
figure out the critical value or state the decision rule. It's a two-tailed test with a significance level
is 0.1. That means we're going to have .05 percent on each tail we come up
with a critical value of -1.833 and 1.833. Well here's how we came up with that critical value of 1.833. The degrees of freedom which are n1 plus n2 minus 2. There were 5 in the first sample and 6 in the other. We
have two samples so that's why we subtract 2. After the
degrees of freedom we find the level of significance column. This is a two tail
so we're looking at the .1 level of significance two-tailed degrees of
freedom of nine. We end up with that critical value of 1.833. Here's how we would compute
this manually if we wanted to. The first step is to compute the means. So the mean
of sample one is four. As we can see 20 divided by 5. For the mean
of sample two is five, 30 divided by 6. Next
we're going to compute the standard deviation. Now I just want to remind you
that the standard deviation if you're computing it manually is simply the sum
of the squared differences between between each value and the mean and then
we're going to divide that by n minus one because this is a sample. Once we have the standard deviation for each sample then we can
compute the pooled sample standard deviation. You see the formula on this slide. It is simply the sample size of n1 minus 1 times the the variance of
the sample. Remember the variance is the standard deviation squared. So once we have the pooled sample standard deviation we can go ahead and
compute the T. Computing the t-score manually,
once I have the pooled sample standard deviations I can go ahead and compute
the T. We have X bar 1 minus X bar 2 divided by the square root of the pooled
sample standard deviations times 1 over the sample size of sample 1 plus 1
divided by the sample size so 2. Once we've done that done that longhand
we end up with a T score of negative .662. We can look very
quickly and see that this is is not more negative or more positive than 1.833.
So in this case we do reject the null hypothesis. We are going to conclude that there is no
difference between the assembly methods. Now you will see the real reason I
rushed over that formula. In computing that T score for two
samples it's very easy to do in Excel. With the data analysis feature you just select the t-test to sample assuming equal variances and you can see the result in this slide. Excel computes the T for us as well as
the pooled variance. Excel also gives you the critical values of one
tail and two tail test. You'll also notice that Excel also reports a p-value. We haven't talked about the
p-value too much so far, but Excel easily computes the p-value. The p value allows you to compare the probability of making a type 1 error versus what you are after.
Remember we wanted a .1 significance level or a only a 10%
chance of making a type 1 error. We've ended up with a p-value here of
0.5 to 5 so this is telling us there's more than a 50% chance of making a type
1 error, so definitely we do not want to assume that our alternative hypothesis
is correct. We're not going to reject the null. When we're comparing the means of
two samples we need to also understand whether or not we're talking about
dependent or independent samples. So far we've been using independent samples, which means they're not related
to each other. A dependent sample is essentially when we're looking at the
same sample and doing kind of a before and after study. Maybe we're looking at a
sample before they've taken the stats class and after they've taken the stats
class and then we'll give them the same test to see if they did better
after taking the class. So we'll go ahead and run through an example of a dependent sample and I'll just say it right off the bat that this is something you
want to do in Excel if you can. Using the data analysis feature it's much easier
than doing it manually. So here's the scenario. We're
going to use for dependent sample. So there's a sample of 10 houses that have
been appraised and they've been appraised by two different companies. We're going to try to see is there a difference between the one company and
the other company appraising the same house. We're going to be using the .05 significance level. This computation really isn't
too bad. To compute the T of dependent samples we're simply going to
take the mean of the differences. Then we're going to divide that by the
standard deviation of the differences which is also divided by the square root
of n the number of pairs. We'll go ahead and compute that manually just to show
you how it works and then we'll also show you how to do it in Excel. Once again we go through the same
five-step process of testing hypothesis. We state the null and the alternate.
The null hypothesis is there is no difference between the two companies. The
alternate is that there is a difference. Again it could be one company does it
less lower price or higher price, but again just a difference. .05 is the
significance level. To find the critical value in the
next step our degrees of freedom, because these are dependent samples there's
essentially only one sample. S it's n minus 1. The degrees of freedom is 9
because there were 10 houses that we are looking at. Using the 0.05
significance level for a two-tailed test, so our critical value comes out to be 2.262. Here's how we actually compute
the T involving paired dependent sample. First we compute with the mean of the
differences which in this case is 4.6. We then come up with a standard deviation
of the differences which is 4.402. Finally then we can go ahead and compute
the T. We come up with a T of 3.305 and that is greater than the critical value
we came up with. So we are going to reject the null hypothesis and
assume there is a difference between these two appraisal companies. Now
as you can see with this slide, there is also an Excel data analysis test that
will allow you to do this. This is the t-test to sample from means.
It works just like the other one. Just put the input range the output
range your alpha level, the level of significance, and an output range. In
this case you can see that it does indeed compute the T stat and it also
gives you the critical values and also the p value.