Wednesday, May 2, 2012

Calculating Type II (β) Error

In hypothesis test, β is the probability of failing to reject the null hypothesis when it is actually false. Let's first consider the two-sided case to see how it is calculated. Begin with the following given conditions:
  • Let x̄(n) = 174.5, s(n) = 6.9, n = 50, α = 0.05
  • H0: μ = 175, H1: μ ≠ 175
  • Compare against alternative hypothesis μ = 173
At α = 0.05, we are concerned with z = 1.96 and z = -1.96. Turn these z values into critical values for x̄:
  • Recall that for samples (for both two- or one-sided cases), z = (x̄-μ) / (s(n) / sqrt(n))
  • 1.96 = (x̄ - 175) / (6.9 / sqrt(50)) --> x̄ = 176.913
  • -1.96 = (x̄ - 175) / (6.9 / sqrt(50)) --> x̄ = 173.087
Under standard conditions, the null hypothesis would be accepted if x̄ is between those values. But what if the mean is really 173? That is the alternative hypothesis we are considering. To do that, use a normal distribution with 173 as the mean. We then need to find the z-values for 173.087 and 176.913. To do that:
  • (173.087 - 173) / (6.9 / sqrt(50)) = 0.0892
  • (176.913 - 173) / (6.9 / sqrt(50)) = 4.0100
From here, β is just the area under the normal distribution curve between the two critical values. Using MATLAB, normcdf(4.0100)-normcdf(0.0892) = β = 0.4644. The power of the test, or probability of correctly rejecting the null hypothesis when it is false, is 1-β = 0.5356.

What about an one-sided case? It is similarly computed. Consider the following given conditions:
  • Let p̂ = 0.535, n = 1000, α = 0.05
  • H0: p = 0.50, H1: p > 0.50
  • Compare against the alternative hypothesis p = 0.52
Remember that for the one-sided case, α = 0.05 gives the critical value of z = 1.645. Again turn the value into a value for p̂, similar to the way we solved for x̄ in the example above :
  • Recall that for proportions (for both two- or one-sided cases), z = (p̂-p) / sqrt(p*(1-p)/n)
  • 1.645 = (p̂-0.5) / (sqrt(0.5^2/1000)
  • p̂ = 0.52601
Under standard conditions, the null hypothesis would be accepted if p̂ is 0.52601 or less. Now use a normal distribution with 0.52 as the mean. We want the area to the left of 0.52601, because this is the area that will not be rejected. Now, carefully note that if our H1 were p < 0.50, we would be concerned with the area to the right, instead of left, of 0.52601. Back in the scenario here, we now need to turn 0.52601 to a z-score.
  • Do not forget that p = 0.52 now, instead of 0.50
  • (0.52601 - 0.52) / sqrt(0.52*0.48 / 1000)
  • = 0.3804
To obtain the area to the left of that z-score, simply run normcdf(0.3804) = 0.6482 = β. The power, or the probability of correctly rejecting the null hypothesis when it is false, would again be 1- β = 0.3518.