# Computing Type II Error for a One-Sided Normal Test.

For a random sample $X_1,X_2,\ldots , X_{49}$ taken from a population having standard deviation 4, sample mean is found to be 20.3. Test the claim that the mean of the population is not less than 21 at 1% level of significance.Find the probability of Type II error if the population mean is 19.1

So to test for $H_0: \mu\geq 21$ versus alternate hypothesis $H_1: \mu < 21$ we calculate the test statistic $Z=\frac{20.3-21}{\frac{4}{\sqrt{49}}}=-1.225$ and since $-z_{0.01}=-2.326<-1.225$, we cannot reject the null hypothesis at 1% level of significance.

I am confused how to do the second part. I know that the Type 2 error will be $P(Accept \ H_0|\mu=19.1)$. How do I do this?

Intuitively, for the test you have $H_0: \mu \ge 21$ and $H_a: \mu < 21.$ From data you have $\bar X = 20.3,$ which is smaller then $\mu_0 = 21.$ However, the critical value for a test at level 1% is $c = 19.67.$ Because $\bar X > c,$ you find that $\bar X$ is not significantly smaller than $\mu_0.$

Computation using R: Under $H_0$ we have $\bar X \sim \mathsf{Norm}(21, 4/7);\,P(\bar X \le 19.671) = .01.$

qnorm(.01, 21, 4/7)     # 'qnorm' is normal quantile function (inverse CDF)
## 19.67066             # 1% critical value
pnorm(19.671, 21, 4/7)  # 'pnorm' is normal CDF
## 0.01001595           # verified


Now you wonder, whether a specific alternative value $\mu_a = 19.1 < 21$ might have yielded a value of $\bar X$ small enough to lead to rejection.

The Answer from @spaceisdarkgreen (+1) has done the power computation by standardizing, so that probabilities can be read from printed normal tables.

If we leave the problem on the original measurement scale, the following figure illustrates the situation. The blue curve (at right) is the hypothetical normal distribution of $\bar X \sim \mathsf{Norm}(\mu_0 = 21, \sigma = 2/7).$ The 1% significance level is the area under this curve to the left of the vertical line.

The orange curve is the alternative normal distribution of $\bar X \sim \mathsf{Norm}(\mu_a =19.1, \sigma = 2/7).$ The area to the left of the vertical line under this curve represents the power against alternative $H_a: \mu = \mu_a,$ which is $0.840.$ [The power is $1 - P(\text{Type II Error}).$] Computation: Under $H_a: \mu_a = 19.1,$ we have $\bar X \sim \mathsf{Norm}(19.1, 4/7).$

pnorm(19.671, 19.1, 4/7)
## 0.8411632               # power against alternative 19.1
1 - pnorm(19.671, 19.1, 4/7)
## 0.1588368               # Type II error probability


Note: Some statistical calculators can be used to find the same normal probabilities I have found using R statistical software.

Addendum: Some textbooks reduce the computations shown by @spaceisdarkgreen to the following formula for Type II error of a one-sided test at level $\alpha$ against an alternative $\mu_a:$

$$\beta(\mu_a) = P\left(Z \le z_\alpha - \frac{|\mu_0-\mu_a|}{\sigma/\sqrt{n}} \right).$$ In your case this is $P(Z \le 2.326 - 3.325 = -0.999) = \Phi(-0.999) = 0.1589.$

Ref.: The displayed formula is copied from Sect 5.4 of Ott & Longnecker: Intro. to Statistical Methods and Data Analysis.

For the $1\%$ significance level, you have calculated you should reject if $$\frac{\sqrt{49}(21-\bar X)}{4} > 2.326,$$ so you need to calculate the probability that $$\frac{\sqrt{49}(21-\bar X)}{4} < 2.326$$ when $X_i\sim N(19.1,16).$

Under this assumption, you know that $$\frac{\sqrt{49}(19.1-\bar X)}{4} \sim N(0,1)$$ so you just need to rearrange: $$P\left(\frac{\sqrt{49}(21-\bar X)}{4} < 2.326\right)=P\left(\frac{\sqrt{49}(19.1-\bar X)}{4}+\frac{\sqrt{49}(1.9)}{4} < 2.326\right)\\=P\left(\frac{\sqrt{49}(19.1-\bar X)}{4}<-0.999\right) =\Phi(-0.999) = 15.9\%$$

Another way of saying this is that at effect size $\mu = 19.1$ and sample size $n=49,$ the test has $1-15.9\% = 84.1\%$ power.