Hypothesis testing and its types of errors

, محدث •0•0Comment iconComment iconComment iconComment icon

Type I and type II errors in hypothesis testing, with a worked example: null hypothesis, α, β, power, significance level, one- and two-tailed tests.

Writer image

تمت الترجمة بواسطةEditorial

Writer image

تمت المراجعة بواسطةEditorial

تحرير المادة

One of the problems solved by statistical inference is testing a hypothesis. That is, given a statement about a population, usually about one of its parameters, we want to know whether the results of a sample contradict that statement or not.

The goal of statistical hypothesis testing is, therefore, to provide a method that lets us check whether the sample data bring evidence that supports a formulated statistical hypothesis or not.

The central idea of hypothesis testing is to assume the hypothesis in question is true and check whether the observed sample is "plausible" under those conditions.

An example: where do the bolts come from?

A manufacturer uses, as one of the components of the machines it produces, an imported bolt that must meet certain requirements. One of them is tensile strength. These bolts are made in a few countries, and the technical specifications vary from country to country. Country A's catalogue states that the mean tensile strength of its bolts is 145 kg, with a standard deviation of 12 kg. For country B, the mean is 155 kg and the standard deviation 20 kg.

A lot of these bolts, of unknown origin, will be auctioned at a very attractive price. To decide whether to make an offer, the manufacturer needs to know which country produced the bolts. The auctioneer's notice states that, shortly before the auction, the mean strength x̄ of a sample of 25 bolts from the lot will be disclosed. What decision rule should the manufacturer use to say whether the bolts are from country A or country B?

The simplest way would be to choose the country whose mean is closest to the sample mean. To do this, we take the midpoint between the two means:

Midpoint = (145 + 155)/2 = 150

If x̄ is less than 150, we say the bolts are from A; if it is greater, from B. Suppose the sample mean is 148: by our rule, we would say the bolts are from A. Could we be wrong? In other words, is it possible for a sample of bolts from B to have a mean of 148? Yes, it is possible. That is why we need to study the types of error we can make and their probabilities.

The types of error

Let's take origin B as the hypothesis to be tested (the null hypothesis, defined in the next section). With the midpoint rule, there are two possible errors:

  • Type I error: saying the bolts are from A when, in reality, they are from B. It happens when the lot is from B but the sample mean comes out below 150 kg.
  • Type II error: saying the bolts are from B when, in reality, they are from A. It happens when the lot is from A but the sample mean comes out above 150 kg.

In general, a type I error is rejecting the null hypothesis when it is true (a false positive), and its probability is called α. A type II error is not rejecting the null hypothesis when it is false (a false negative), with probability β. The image below is a humorous way to remember the difference: with the null hypothesis 'not pregnant', telling a man he is pregnant is a type I error, and telling a pregnant woman she is not is a type II error.

The types of error
The types of error

In a lab test, the null hypothesis is 'the patient does not have the disease'. The test comes back positive for a healthy person. Which error was made?

Loading icon

Answer: Type I error, because a true null hypothesis was rejected — the person was healthy (H0 true) and the test concluded the opposite: it is a false positive. A type II error would be the test coming back negative for someone who is ill.

The null hypothesis and the probability of each error

Let's define the two hypotheses:

H0 (null hypothesis): the bolts are from origin B, with mean 155 and standard deviation 20.

H1 (alternative hypothesis): the bolts are from origin A, with mean 145 and standard deviation 12.

When H0 is true, that is, when the bolts are from B, the sample mean x̄ is approximately normally distributed with mean 155 and standard deviation 20/√25 = 4. A type I error happens if x̄ falls below 150:

P(type I error) = P(reject H0 | H0 true) = P(x̄ less than 150 | μ = 155)

= P(Z less than (150 − 155)/4) = P(Z less than −1.25) = 0.1056 = 10.56%

When H1 is true (bolts from A), x̄ has mean 145 and standard deviation 12/√25 = 2.4. A type II error happens if x̄ falls above 150:

P(type II error) = P(do not reject H0 | H1 true) = P(x̄ greater than 150 | μ = 145)

= P(Z greater than (150 − 145)/2.4) = P(Z greater than 2.08) = 0.0188 = 1.88%

These probabilities are clearer in the table:

Actual origin of the boltMean strength < 150Mean strength > 150
ANo errorType II error
1.88%
BType I error
10.56%
No error

If the bolts are really from B (second row) and the sample mean is greater than 150 (second column), we will say they are from B and make no error. If the mean x̄ is less than 150 (first column), we will say they are from A and make an error, whose probability in this case is 10.56%. The interpretation of the first row, for bolts really from A, is analogous.

If we choose another cut-off value instead of 150, only the probabilities of type I and type II errors change: moving the cut-off towards 145 lowers α and raises β, and vice versa. So there is a point where the two errors are equal, that is, a rule where the chance of wrongly ruling against A is the same as wrongly ruling against B. It is the value c that equalizes the two standardized distances, (155 − c)/4 = (c − 145)/2.4, which gives c = 148.75 kg. At this point, z = 1.5625 and α = β ≈ 5.9%.

In the bolt example, if the manufacturer changes the cut-off from 150 to 152 (says A below 152 and B above), what happens to the errors?

Loading icon

Answer: α increases and β decreases — with the cut-off closer to 155, it becomes easier for a sample from B to fall below it (type I error) and harder for a sample from A to exceed it (type II error). For the same sample size, reducing one error increases the other.

Fixing the type I error: the significance level

We saw that, once the cut-off value is chosen, we can find the probability of each error. We can also go the other way: fix one of the errors, usually α, and find the decision rule that corresponds to it. This fixed α is the test's significance level.

For example, with α = 5%:

P(type I error) = P(Z less than −1.645) = 5%

−1.645 = (x̄c − 155)/4, so x̄c = 155 − 1.645 × 4 = 148.42

So the decision rule will be:

“If the mean of the lot studied is below 148.42, we say the lot is from A; otherwise, we say it is from B.”

- Decision rule

With this rule, the probability of a type II error will be:

P(type II error) = P(x̄ greater than 148.42 | μ = 145) = P(Z greater than (148.42 − 145)/2.4) = P(Z greater than 1.425) ≈ 7.7%

The probability of correctly detecting that the lot is from A, 1 − β ≈ 92.3%, is called the power of the test.

Still with the bolts, the manufacturer wants α = 1% (z = 2.326). What does the decision rule become?

Loading icon

Answer: Say A if x̄ is less than 145.70 — the cut-off is 155 − 2.326 × 4 = 145.70. The price of a smaller α is a much larger β: P(x̄ greater than 145.70 | μ = 145) = P(Z greater than 0.29) ≈ 38.6%.

When the alternative hypothesis is not known

Fixing α is the most widely used procedure because, in general, the decision is not just between two known populations. The bolts could come from other countries, with other mean strengths. Suppose the manufacturer is only interested in making an offer if the bolts are from origin B. What decision rule should it adopt? The hypotheses are now:

H0: the bolts are from origin B (μ = 155 and σ = 20)

H1: the bolts are not from origin B (μ unknown)

Here we cannot specify the parameters under H1, because, if they are not from B, the bolts could come from several countries, each with its own specifications. Some may have more sophisticated techniques and produce with a mean strength above 155; others, as in the example, with lower strength. The specification of H1 depends on the information available about the problem. If we assume, for example, that country B's industry is the most developed and no other country produces with a higher mean strength, the alternative becomes more explicit:

H1: the bolts are not from origin B (μ less than 155)

This is a one-tailed test, and the rule remains the one from the previous section (reject H0 if x̄ is less than 148.42). The type II error now cannot be calculated, because it depends on the true μ, which we do not know:

Actual origin of the boltMean strength < 148.42Mean strength > 148.42
BType I error
5%
No error
not BNo errorType II error
?%

And what if we do not even know in which direction the other countries' mean might lie, that is, if H1 is only μ different from 155? Then the test is two-tailed: the 5% of α is split into 2.5% in each tail.

P(type I error) = P(Z less than −1.96) + P(Z greater than 1.96) = 2.5% + 2.5% = 5%

−1.96 = (x̄1 − 155)/4, so x̄1 = 147.16

1.96 = (x̄2 − 155)/4, so x̄2 = 162.84

Therefore, for any sample mean below 147.16 or above 162.84, we reject the null hypothesis that the bolts are from origin B.

The sample of 25 bolts had a mean of 164 kg. With α = 5%, what do you conclude in the one-tailed test (H1: μ less than 155) and in the two-tailed test (H1: μ different from 155)?

Loading icon

Answer: Do not reject H0 in the one-tailed test and reject in the two-tailed test — the one-tailed test only rejects if x̄ is less than 148.42, and 164 is on the other side. The two-tailed test rejects above 162.84, and 164 is beyond that limit.

Exercises

1) To decide whether the inhabitants of an island are descendants of civilization A or B, we will proceed as follows:

(i) we select a sample of 100 adult residents of the island and determine their mean height;
(ii) if this mean height is greater than 176, we will say they are descendants of B; otherwise, of A.

The height parameters of the two civilizations are: A: μ = 175 and σ = 10; B: μ = 177 and σ = 10. Type I error: saying the inhabitants are descendants of B when, in reality, they are from A. Type II error: saying they are from A when, in reality, they are from B.

(a) What is the probability of a type I error? And of a type II error?
(b) What should the decision rule be if we want to fix the probability of a type I error at 5%? What is the probability of a type II error in that case?

2) In the situations below, choose as the null hypothesis, H0, the one that, in your view, leads to a more serious type I error. Describe the two errors in each case.

(a) A radar operator's job is to detect enemy aircraft. When something strange appears on the screen, he must decide between the hypotheses: 1. an attack is starting; 2. everything is fine, it is just slight interference.

(b) In a jury trial, an individual is being tried for a crime. The hypotheses before the jury are: 1. the defendant is innocent; 2. the defendant is guilty.

(c) A researcher believes he has discovered a vaccine against the common cold. He will conduct laboratory research to verify the claim and, depending on the result, will or will not launch the vaccine on the market. The hypotheses he can test are: 1. the vaccine is effective; 2. the vaccine is not effective.

3) The variable X, the maintenance cost of a loom, is normally distributed with mean μ and standard deviation of 20 units. The possible values of μ are 200 or 210. To check which of the two is more likely, a sample of 25 looms will be used. Define:

(a) a hypothesis to be tested;
(b) a decision rule, and find the probabilities of type I and II errors.

4) The association of metalworking industry owners is concerned about the time lost to workplace accidents, whose mean has been 60 man-hours per year, with a standard deviation of 20 man-hours. An accident prevention programme was carried out and, afterwards, a sample of nine industries had a mean of 50 man-hours lost. Would you say, at the 5% level, that there is evidence of improvement?

Answer key

1) (a) The standard deviation of the mean is 10/√100 = 1. Type I error = P(x̄ greater than 176 | μ = 175) = P(Z greater than 1) = 15.9%; type II error = P(x̄ less than 176 | μ = 177) = P(Z less than −1) = 15.9%. (b) Rule: say B if x̄ is greater than 175 + 1.645 = 176.64. Type II error = P(Z less than −0.36) ≈ 36%.

2) (a) H0: an attack is starting. Type I error: thinking it is interference when it is an attack; type II error: raising the alarm when it is only interference. (b) H0: the defendant is innocent. Type I error: convicting an innocent person; type II error: acquitting a guilty person. (c) H0: the vaccine is not effective. Type I error: launching a vaccine that does not work; type II error: failing to launch an effective vaccine.

3) (a) H0: μ = 200 versus H1: μ = 210. (b) The standard deviation of the mean is 20/√25 = 4. With the midpoint rule (reject H0 if x̄ is greater than 205): α = P(Z greater than 1.25) = 10.56% and β = P(Z less than −1.25) = 10.56%. If you prefer to fix α = 5%, the rule is to reject H0 if x̄ is greater than 206.58, and β = P(Z less than −0.855) ≈ 19.6%.

4) H0: μ = 60 versus H1: μ less than 60 (one-tailed test). z = (50 − 60)/(20/√9) = −1.5, which does not pass the critical value −1.645 (p-value ≈ 6.7%). It is not possible to reject the null hypothesis: at the 5% level, there is not enough evidence of improvement.

ما رأيك في هذا المقال؟

0%
تقييم المستخدمين (0)

شارك هذا المقال!

المواضيع erroshipoteseteste