1

I came across this example of calculating a type 2 error.

I understand it up to the following point:

Therefore, so long as the sample mean is between 14.541 and 16.259 in a hypothesis test, the null hypothesis will not be rejected.

I understand this. When I perform a normal test with hypothesis if a sample mean is equal to a hypothetical mean, I set my alpha and this leads to a CI for the mean. One lower and one upper. If the estimated $\bar{x}$ lies within this then I cannot reject.

Now I do not understand how I can calculate a beta error if I know for sure that the true population mean is 15.1? It just says:

Since we assume that the actual population mean is 15.1, we can compute the lower tail probabilities of both end points.

and calculation as follows:

mu = 15.1 # assumed actual mean

<p>p = pt((q - mu)/SE, df=n-1); p<br>
0.097445 0.995168</p>

I tried to draw this:

s

But I do not understand how the beta error results? How can one show these calculations in a graph to understand it ("p = pt((q - mu)/SE, df=n-1);")? I can't get the idea of how to calculate the beta error in this case?

Stat Tistician
  • 2,321
  • 5
  • 34
  • 57

1 Answers1

4

I made the following figure for your example. H1_15.1

The blue curve is the t-distribution under H0 hypothesis: mean = 15.4, from which you have derived the acceptance area $W = \{ 14.541 \leq \bar{x} \leq 16.259\}$. That is, if $\bar{x} \in W$, H0 is not rejected.

The yellow curve is the t-distribution under the alternative H1: mean = 15.1. Type 2 error is defined as the probability of accepting H0 when in fact H1 is true, or $P_{H_1}(\bar{x} \in W)$. We can see that the value corresponds to the orange area in the figure. To calculate this value, you can first acquire under H1 the percentile of the CI upperbound and the percentile of the CI lowerbound, and then take a difference, which is exactly what this piece of code is doing:

> mu = 15.1 # assumed actual mean
> p = pt((q - mu)/SE, df=n-1); p
0.097445 0.995168
> diff(p) # p2-p1
0.89772

Type 2 error can look complicated if you are relatively new to this concept. People look at type 2 error because the acceptance of H0 does not necessarily imply H1 is wrong. Like in this example, if you observe $\bar{x} \in W$ H0 is accepted, but type 2 error tells us that even under H1 you have a 0.89772 chance to see $\bar{x} \in W$. It's more of a "H0 is acceptable, but H1 may not be wrong as well" situation.

Let's compare to the following figure where I changed H1 from 15.1 to 14.0. Now that the two distributions are more apart from each other, the orange area becomes much smaller. If $\bar{x} \in W$ is observed, you can say "I accept H0, and H1 is likely not true".

H1_14.0

Lii
  • 1,096