IE241: Introduction to Hypothesis Testing. Topic Slide Hypothesis testing â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦ ..3 Light bulb example â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦ ..4 Null and alternative hypotheses â€¦â€¦â€¦â€¦â€¦â€¦ .. â€¦â€¦â€¦ .5 Two types of error â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦ 8
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
Topic Slide
Hypothesis testingâ€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦..3
Light bulb exampleâ€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦..4
Null and alternative hypothesesâ€¦â€¦â€¦â€¦â€¦â€¦..â€¦â€¦â€¦.5
Two types of errorâ€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦8
Decision ruleâ€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦..â€¦â€¦â€¦.11
test statisticâ€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦11
critical regionâ€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦.12
power of the testâ€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦.â€¦â€¦.17
Simple hypothesis testingâ€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦...18
Neyman-Pearson lemmaâ€¦â€¦â€¦â€¦â€¦â€¦.â€¦â€¦.â€¦â€¦.19
exampleâ€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦..21
Composite hypothesis testing â€¦â€¦â€¦â€¦â€¦...â€¦â€¦â€¦..26
exampleâ€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦..â€¦â€¦â€¦â€¦â€¦29
Likelihood ratio testâ€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦.34
relationship to meanâ€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦.38
Examples of 1-sided composite hypotheses
drug to help sleepâ€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦42
civil service examâ€¦â€¦â€¦....................â€¦â€¦â€¦â€¦..44
difference between two proportions â€¦â€¦â€¦.46
effect of size of nâ€¦â€¦â€¦â€¦..â€¦â€¦â€¦â€¦â€¦â€¦â€¦.51
fertilizer to improve yield of cornâ€¦â€¦â€¦â€¦â€¦â€¦â€¦..55
test of two variancesâ€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦..59
F distribution â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦61
Bayesâ€™ likelihood ratio testâ€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦..â€¦66
exampleâ€¦â€¦â€¦â€¦â€¦â€¦â€¦...â€¦â€¦â€¦â€¦â€¦â€¦â€¦â€¦..â€¦..67
Topic Slide
We said before that estimation of parameters was one of the two major areas of statistics. Now letâ€™s turn to the second major area of statistics, hypothesis testing.
What is a statistical hypothesis? A statistical hypothesis is an assumption about f(X) if X is continuous or p(X) if X is discrete.
A test of a statistical hypothesis is a procedure for deciding whether or not to reject the hypothesis.
Letâ€™s look at an example.
A buyer of light bulbs bought 50 bulbs of each of two brands. When he tested them, Brand A had an average life of 1208 hours with a standard deviation of 94 hours. Brand B had a mean life of 1282 hours with a standard deviation of 80 hours. Are brands A and B really different in quality?
We set up two hypotheses.
The first, called the null hypothesis Ho, is the hypothesis of no difference.
Ho: Î¼A = Î¼B
The second, called the alternative hypothesis Ha, is the hypothesis that there is a difference.
Ha: Î¼A â‰ Î¼B
On the basis of the sample of 50 from each of the two populations of light bulbs, we shall either reject or not reject the hypothesis of no difference.
In statistics, we always test the null hypothesis. The alternative hypothesis is the default winner if the null hypothesis is rejected.
We never really accept the null hypothesis; we simply fail to reject it on the basis of the evidence in hand.
Now we need a procedure to test the null hypothesis. A test of a statistical hypothesis is a procedure for deciding whether or not to reject the null hypothesis.
There are two possible decisions, reject or not reject. This means there are also two kinds of error we could make.
The two types of error are shown in the table below.
If we reject HowhenHois in fact true, then we make a type 1 error. The probability of type 1 error is Î±.
If we do not reject Ho when Ho is really false, then we make a type 2 error. The probability of a type 2 error is Î².
Now we need a decision rule that will make the probability of the two types of error very small. The problem is that the rule cannot make both of them small simultaneously.
Because in science we have to take the conservative route and never claim that we have found a new result unless we are really convinced that it is true, we choose a very small Î±, the probability of type 1 error.
Then among all possible decision rules given Î±, we choose the one that makes Î² as small as possible.
The decision rule consists of a test statistic and a critical region where the test statistic may fall. For means from a normal population, the test statistic is
where the denominator is the standard deviation of the difference between two independent means.
The critical region is a tail of the distribution of the test statistic. If the test statistic falls in the critical region, Ho is rejected.
Now, how much of the tail should be in the critical region? That depends on just how small you want Î± to be. The usual choice is Î± = .05, but in some very critical cases, Î± is set at .01.
Here we have just a non-critical choice of light bulbs, so weâ€™ll choose Î± = .05. This means that the critical region has probability = .025 in each tail of the t distribution.
For a t distribution with .025 in each tail, the critical value of t = 1.96, the same as z because the sample size is greater than 30. The critical region then is |t |> 1.96.
In our light bulb example, the test statistic is
Now 4.23 is much greater than 1.96 so we reject the null hypothesis of no difference and declare that the average life of the B bulbs is longer than that of the A bulbs.
Because Î± = .05, we have 95% confidence in the decision we made.
We cannot say that there is a 95% probability that we are right because we are either right or wrong and we donâ€™t know which.
But there is such a small probability that t will land in the critical region if Ho is true that if it does get there, we choose to believe that Ho is not true.
If we had chosen Î± = .01, the critical value of t would be 2.58 and because 4.23 is greater than 2.58, we would still reject Ho. This time it would be with 99% confidence.
How do we know that the test we used is the best test possible?
We have controlled the probability of Type 1 error. But what is the probability of Type 2 error in this test? Does this test minimize it subject of the value of Î±?
To answer this question, we need to consider the concept of test power. The power of a statistical test is the probability of rejecting Ho when Ho is really false. Thus power = 1-Î².
Clearly if the test maximizes power, it minimizes the probability of Type 2 error
Î². If a test maximizes power for given Î±, it is called an admissible testing strategy.
Before going further, we need to distinguish between two types of hypotheses.
A simple hypothesis is one where the value of the parameter under Ho is a specified constant and the value of the parameter under Ha is a different specified constant.
For example, if you test
Ho: Î¼ = 0 vs Ha: Î¼ = 10
then you have a simple hypothesis test.
Here you have a particular value for Ho and a different particular value for Ha.
For testing one simple hypothesis Ha against the simple hypothesis Ho, a ground-breaking result called the Neyman-Pearson lemma provides the most powerful test.
Î» is a likelihood ratio with the Ha parameter MLE in the numerator and the Ho parameter MLE in the denominator. Clearly, any value of Î» > 1 would favor the alternative hypothesis, while values less than 1 would favor the null hypothesis.
Basically, this likelihood ratio says that if there exists a critical region A of size Î± and a constant k such that
inside A
and
outside A
then A is a best (most powerful) critical region of size Î±.
Consider the following example of a test of two simple hypotheses.
A coin is either fair or has p(H) = 2/3.
Under Ho, P(H) = Â½ and under Ha, P(H) = 2/3.
The coin will be tossed 3 times and a decision will be made between the two hypotheses. Thus X = number of heads = 0, 1, 2, or 3. Now letâ€™s look at how the decision will be made.
First, letâ€™s look at the probability of Type 1 error Î±. In the table below, Hoâ‡’ P(H) =1/2 and Haâ‡’ P(H) = 2/3.
Now what should the critical region be?
Under Ho, if X = 0, Î± = 1/8. Under Ho, if X = 3, Î± = 1/8. So if either of these two values is chosen as the critical region, the probability of Type 1 error would be the same.
Now what if Ha is true? If X = 0 is chosen as the critical region, the value of Î² = 26/27 because that is the probability that X â‰ 0.
On the other hand, if X = 3 is chosen as the critical region, the value of Î² = 19/27 because that is the probability that X â‰ 3.
Clearly, the better choice for the critical region is X=3 because that is the region that minimizes Î² for fixed Î±. So this critical region provides the more powerful test.
In discrete variable problems like this, it may not be possible to choose a critical region of the desired Î±. In this illustration, you simply cannot find a critical region where Î± = .05 or .01.
This is seldom a problem in real-life experimentation because n is usually sufficiently large so that there is a wide variety of choices for critical regions.
This problem to illustrate the general method for selecting the best test was easy to discuss because there was only a single alternative to Ho.
Most problems involve more than a single alternative. Such hypotheses are called composite hypotheses.
Examples of composite hypotheses:
Ho: Î¼ = 0 vs Ha: Î¼ â‰ 0
which is a two-sided Ha.
A one-sided Ha can be written as
Ho: Î¼ = 0 vs Ha: Î¼ > 0
or
Ho: Î¼ = 0 vs Ha: Î¼ < 0
All of these hypotheses are composite because they include more than one value for Ha. And unfortunately, the size of Î² here depends on the particular alternative value of Î¼ being considered.
In the composite case, it is necessary to compare Type 2 errors for all possible alternative values under Ha. So now the size of Type 2 error is a function of the alternative parameter value Î¸.
So Î²(Î¸) is the probability that the sample point will fall in the noncritical region when Î¸ is the true value of the parameter.
Because it is more convenient to work with the critical region, the power function 1-Î²(Î¸) is usually used.
The power function is the probability that the sample point will fall in the critical region when Î¸ is the true value of the parameter.
As an illustration of these points, consider the following continuous example.
Let X = the time that elapses between two successive trippings of a Geiger counter in studying cosmic radiation. The density function is
f(x;Î¸) = Î¸e-Î¸x
where Î¸ is a parameter which depends on experimental conditions.
Under Ho, Î¸ = 2. Now a physicist believes that Î¸ < 2. So under Ha, Î¸ < 2.
Now one choice for the critical region is the right tail of the distribution, X â‰¥ 1
Another choice is the left tail, X â‰¤ .07 for which Î± = .135. That is,
Now letâ€™s examine the power for the two competing critical regions.
For the right-tail critical region X > 1,
and for the left-tail critical region X <.07,
The graphs of these two functions are called the power curves for the two critical regions.
These two power functions are
Note that the power function for X>1 region is always higher than the power function for X<.07 region before they cross at Î¸ = 2. Since the alternative Î¸ values in the problem are all Î¸<2, clearly the region X>1 is superior.
Unfortunately, with two-sided composite alternative hypotheses, there is no best test that covers all alternative values.
Clearly, if the alternative were Î¸a < Î¸o , the left tail would be best, and if the alternative were Î¸a > Î¸o , the right tail would be best.
This shows that best critical regions exist only if the alternative hypothesis is suitably restricted.
So for composite hypotheses, a new principle needs to be introduced to find a good test. This principle is called a likelihood ratio test.
where the denominator is the maximum of the likelihood function with respect to all the parameters, and the numerator is the maximum of the likelihood function after some or all of the parameters have been restricted by Ho.
Consequently, the numerator can never exceed the denominator, so Î» can assume values only between 0 and 1.
A value of Î» close to 1 lends support to Ho because then it is clear that allowing the parameters to assume values other than those possible under Ho would not increase the likelihood of the sample values very much, if at all.
If, however, Î» is close to 0, then the probability of the sample values of X is very low under Ho, and Ho is therefore not supported by the data.
Because increasing values of Î» correspond to increasing degrees of belief in Ho, Î» may serve as a statistic for testing Ho, with small values leading to rejection of Ho.
Now the MLEs are functions of the values of the random variable X, so Î» is also a function of these values of X and is therefore an observable random variable.
Î» is often related to whose distribution is known so it is not necessary to find the distribution of Î».
Suppose we have a normal population with Ïƒ = 1 and we are interested in testing whether the mean = Î¼o. That is,
Letâ€™s see how we would construct a likelihood ratio test.
In this case,
Since maximizing L(Î¸) is equivalent to maximizing log L(Î¸),
so and therefore
Under Ho, there are no parameters to be estimated, so
and Î» then is
This expression shows a relationship between Î» and , such that for each value of Î», there are two critical values of , which are symmetrical with respect to = Î¸o.
So the 5% critical region for Î» corresponds to the two 2.5% tails of the normal distribution given by
So the likelihood ratio test is identical to the t test and serves as a compromise test when no best test is available.
It is because of the concept of power that we simply fail to reject the null hypothesis and do not accept it when the critical value does not fall into the rejection region.
The reason is that if we had a more powerful test, we might have been able to reject Ho.
Now letâ€™s look at some examples.
As an example of a one-sided composite hypothesis test, suppose a new drug is available which claims to produce additional sleep. The drug is tested on 10 patients with the results shown.
We are testing the hypothesis
Ho: Î¼ = 0 vs Ha: Î¼ > 0
The mean hours gained = 1.24 and s = 1.45. So the t statistic is
which has 9 df.
For df = 9 and Î± = .05, the required t = 2.262. Since our obtained t is greater then the required t, we can, with 95% confidence, reject Ho.
So in this case, even with only 10 patients, we can endorse the drug for obtaining longer sleep.
Now letâ€™s take a second example. A civil service exam is given to a group of 200 candidates. Based on their total scores, the 200 candidates are divided into two groups, the top 30% and the bottom 70%.
Now consider the first question in the examination. In the upper 30% group, 40 had the right answer. In the lower 70% group, 80 had the right answer. Is the question a good discriminator between the top scorers and the lower scorers?
To answer this question, we first set up the two hypotheses.
In this case, the null hypothesis is Ho: pu = pl and the alternative is
Ha: pu > pl because we would expect the upper group to do better than the lower group on all questions.
In binomial situations, we must deal with proportions instead of counts unless the two sample sizes are the same.
The proportion of successes p = x/n may be assumed to be normally distributed with mean p and variance
pq/n if n is large.
Then the difference between two sample proportions may also be approximately normally distributed if n is large.
In this situation, Î¼p1-p2 = p1-p2 and
Just as for the binomial distribution, the normal approximation will be satisfactory if each nipi exceeds 5 when p â‰¤ Â½ and niqi exceeds 5 when p > Â½.
The test statistic is
We need the common estimate of p under Ho to use in the denominator, so we use the estimate for the entire group.
So p = 120/200 = 3/5 =.6 and q = .4.
The p for the upper group = 40/60 = .67. The p for the lower group = 80/140â‰ˆ.57.
So inserting our values into the test statistic, we get
Our critical region is t > 1.96 because we have set Î± = .05 as the critical value. Because of the large sample size, t.05 = z.05 .
Because the obtained t = 1.32 is lower than the required t = 1.96, we cannot reject the null hypothesis because the data didnâ€™t allow us to do so.
So, given the data, we conclude that the first question is not a good one for distinguishing between the upper scorers and the lower scorers on the entire test.
Now letâ€™s look at our test problem again. Suppose instead of 200 candidates we tested 500, but kept everything else in the problem the same.
Now we will reject Ho because now t = 2.092, which is greater than 1.96, the critical value of t.
This is why we never accept Ho, but only fail to reject it with the evidence in hand. It is always possible that a more powerful test will provide evidence to reject Ho.
But this leads to another question. If, theoretically, we can always keep increasing sample size, then eventually we will always be able to reject Ho. So why do the test to begin with?
The reality is that you canâ€™t keep increasing n in the real world because there are constraints on time, money, and manpower that prevent having n so large that rejection of Ho is a foregone conclusion.
We usually have to get by with the n we have available.
Furthermore, even if we could get a larger sample size, there is no guarantee that everything else will remain the same.
The mean difference in the numerator could change. So could the variance estimates in the denominator.
So we do the test because there is no other choice.
As another example, consider the application of a fertilizer to plots of farm ground and the effect it has on the yield of corn in bushels. The data are
The average yield for the treated plots = 6.0, with s2 = 0.0711. The average yield for the untreated plots = 5.7 with s2 =0.0267.
The test statistic is
So Ho can be rejected because Î± = .05 and the t.05 = 2.101 with 18 df. When you test the difference between two means, df = nA-1 + nB-1.
So we can conclude that the fertilizer will help produce more bushels of corn.
Now can ask how many extra bushels of corn we will get with the fertilizer. The point estimate is .3, but we can find a 95% confidence interval around this estimate.
In the case of a confidence interval for the difference between two means,
Because the sample size was only 10 for each group, we canâ€™t say with any degree of confidence that the increase in yield is more than .092, but it may be as much as .508.
One caution about using small samples to test the difference between means is that t assumes equality of the two variances. If the samples are large, this assumption is unnecessary.
Now how can we know if the two variances are equal? We can test them.
We already know that each variance is distributed as chi-square. Now how can we test to see if two variances are equal?
The answer is the F test.
The F distribution is a ratio of two chi-square variables. So if s21 and s22 possess independent chi-square distributions with v1 and v2 df, respectively, then
has the F distribution with v1 and v2 df.
The F distribution is
where c is given by
Now letâ€™s do the test to see if our two variances are equal. In the problem, the two variances are .0711 and .0267.
So
and there are 10-1 and 10-1 df. Is 2.66 greater than would be expected if the two variances were equal? To answer this, we must consult the F distribution.
Now it turns out that the critical region in the two tails have critical values that are reciprocals of each other. That is, if
then
Because of this reciprocal property, the procedure is always to place the larger variance over the smaller.
Then we can refer to the F distribution for the .025 critical region to see if the hypothesis of a common variance is to be rejected.
For this case, with 9 and 9 df, the critical value of F = 4.025. There is an FINV function in EXCEL to find critical values for the F distribution.
Since the observed value of 2.66 is less than the critical value of 4.025, we cannot reject the null hypothesis of common variance.
To see the reciprocality, if we had placed the smaller over the larger, we would have as the observed ratio, 1/2.66 = .376.
The critical value would be 1/F = 1/4.025 = .2484. In this case, for the left tail, the observed value should be less than the critical value. But here .376 > .2484, so we would not reject Ho.
Another approach to an admissible test strategy is that developed by Bayes. which turns out to be a likelihood ratio test. Bayesâ€™ formula is used to determine the likelihood of a hypothesis, given an outcome.
This formula gives the likelihood of Hi given the data you actually got versus the total likelihood of every hypothesis given the data you got. So Bayesâ€™ strategy is a likelihood ratio test.
Consider an example where there are two identical boxes. Box 1 contains 2 red balls and Box 2 contains 1 red ball and 1 white ball.
Now a box is selected by chance and 1 ball is drawn from it. What is the probability that it was Box 1 that was selected if the ball that was drawn was red?
Letâ€™s test this with Bayesâ€™ formula.
There are only two hypotheses here, so H1= Box1 and H2 = Box2. The data, of course, = R. So we can find
And we can find
So we can see that the odds of the data favoring Box1 to Box2 are 2:1.
We are twice as likely to be right if we choose Box 1, but there is still some probability that it could be Box 2.
The reason we choose Box 1 is because it is more likely, given the data we have.
This is the whole idea behind likelihood ratio tests. We choose the hypothesis which has the greater likelihood, given the data we have. With other data, we might choose another hypothesis.