# Type II Error in Two-Tailed Test of Population Mean with Unknown Variance in R

• Last Updated : 22 Jun, 2022

In this article, we will cover type II Errors in the Two-Tailed Test of Population Mean with Unknown Variance.

Conventionally, In a two-tail test is used in null-hypothesis testing. The null hypothesis (μo) is equal to the hypothesized mean value (μ). We fail to reject the null hypothesis if the test statistic lies within the range of critical values at the chosen significance level. Type II error is an error that occurs if the hypothesis test based on a random sample fails to reject the null hypothesis even when the true population means μo is not equal to the hypothesized mean value μ.

Here the assumption is the population variance σ2  is unknown. Let s2 be the sample variance. For larger n (usually >30), the population of the following statistics of all possible samples of size n is approximately a Student t distribution with n-1 degree of freedom (DOF).

The range of sample means for a student t distribution is calculated as follows. Let us try to understand the type II error by considering a case study

Suppose the mean weight of boxers in Asia last year was 75.4 kg. In a sample of 35 boxers same time this year in the same region, the mean boxer’s weight is 74.6 kg. Assume the sample standard deviation is 2.5 kg.  Is there enough evidence to reject the null hypothesis that the mean boxer’s weight does not differ from last year at 0.05 significance

Let us start by computing the standard error estimate

## R

 # sample size n = 35    # sample standard deviation s = 2.5               SE = s/sqrt(n); SE

Output:

0.422577127364258

We next compute the lower and upper bounds of sample means for which the null hypothesis μo = 74.6 would not be rejected. In the output 73.74 is the lower bound whereas, 75.45 is upper bound.

## R

 # significance level alpha = .05       # hypothetical mean mu0 = 15.4           I = c(alpha/2, 1-alpha/2) q = mu0 + qt(I, df=n-1) * SE;q

Output:

73.7412199531507      75.4587800468493

The upper and lower bounds suggest as long as the sample mean is between 73.741 and 75.458 in a hypothesis test, the null hypothesis will not be rejected. Since we assume that the actual population mean is 75.4kg, we can compute the lower tail probabilities of both endpoints.

## R

 # assumed actual mean mu = 75.4             p = pt((q - mu)/SE, df=n-1);p

Output:

0.000200411362802067     0.554903698326656

Finally, the probability % of type II error is the probability between the two endpoints found by finding the difference between the two endpoints.

## R

 diff(p)

Output:

0.554703286963854

Here we can understand that, If the boxers sample size is 35, the sample standard deviation of the boxer’s weight is 2.5 kg and the actual mean population weight is 75.4  kg, then the probability of type II error for testing the null hypothesis μ = 75.4 at .05 significance level is 55.47%, and the power of the hypothesis test is 44.53%.

My Personal Notes arrow_drop_up