10
$\begingroup$

I know that a Type II error is where H1 is true, but H0 is not rejected.

Question

How do I calculate the probability of a Type II error involving a normal distribution, where the standard deviation is known?

$\endgroup$
  • 1
    $\begingroup$ See Wikipedia article 'Statistical power' $\endgroup$ – onestop Feb 19 '11 at 21:01
  • 1
    $\begingroup$ I would rephrase this question as "how do I find the power of a general test, such as $H_{0}:\mu=\mu_{0}$ versus $H_{1}:\mu > \mu_{0}$?" This is often the more frequently performed test. I don't know how one would calculate the power of such a test. $\endgroup$ – probabilityislogic Feb 20 '11 at 0:24
26
$\begingroup$

In addition to specifying $\alpha$ (probability of a type I error), you need a fully specified hypothesis pair, i.e., $\mu_{0}$, $\mu_{1}$ and $\sigma$ need to be known. $\beta$ (probability of type II error) is $1 - \textrm{power}$. I assume a one-sided $H_{1}: \mu_{1} > \mu_{0}$. In R:

> sigma <- 15    # theoretical standard deviation
> mu0   <- 100   # expected value under H0
> mu1   <- 130   # expected value under H1
> alpha <- 0.05  # probability of type I error

# critical value for a level alpha test
> crit <- qnorm(1-alpha, mu0, sigma)

# power: probability for values > critical value under H1
> (pow <- pnorm(crit, mu1, sigma, lower.tail=FALSE))
[1] 0.63876

# probability for type II error: 1 - power
> (beta <- 1-pow)
[1] 0.36124

Edit: visualization

enter image description here

xLims <- c(50, 180)
left  <- seq(xLims[1],   crit, length.out=100)
right <- seq(crit, xLims[2],   length.out=100)
yH0r  <- dnorm(right, mu0, sigma)
yH1l  <- dnorm(left,  mu1, sigma)
yH1r  <- dnorm(right, mu1, sigma)

curve(dnorm(x, mu0, sigma), xlim=xLims, lwd=2, col="red", xlab="x", ylab="density",
      main="Normal distribution under H0 and H1", ylim=c(0, 0.03), xaxs="i")
curve(dnorm(x, mu1, sigma), lwd=2, col="blue", add=TRUE)
polygon(c(right, rev(right)), c(yH0r, numeric(length(right))), border=NA,
        col=rgb(1, 0.3, 0.3, 0.6))
polygon(c(left,  rev(left)),  c(yH1l, numeric(length(left))),  border=NA,
        col=rgb(0.3, 0.3, 1, 0.6))
polygon(c(right, rev(right)), c(yH1r, numeric(length(right))), border=NA,
        density=5, lty=2, lwd=2, angle=45, col="darkgray")
abline(v=crit, lty=1, lwd=3, col="red")
text(crit+1,  0.03,  adj=0, label="critical value")
text(mu0-10,  0.025, adj=1, label="distribution under H0")
text(mu1+10,  0.025, adj=0, label="distribution under H1")
text(crit+8,  0.01,  adj=0, label="power", cex=1.3)
text(crit-12, 0.004,  expression(beta),  cex=1.3)
text(crit+5,  0.0015, expression(alpha), cex=1.3)
$\endgroup$
  • 1
    $\begingroup$ Is there a typo in this answer? I think what is called $\texttt{pow}$ is actually $\beta$ and vice versa. Either way, this is an excellent graph and example R code! $\endgroup$ – jdods Nov 19 '18 at 2:30
  • 1
    $\begingroup$ @jdods Indeed, there was a lower.tail=FALSE missing. Thank you very much! $\endgroup$ – caracal Nov 19 '18 at 8:56
  • $\begingroup$ @caracal could you explain, in ~layman terms, why we can calculate a p-value (risk of type 1 error) without consideration for beta, but we need to specify alpha to be able to measure the risk of type 2 error? I feel like I'm missing something. Thanks for your excellent answer. $\endgroup$ – Cystack Jan 11 at 0:55
  • 1
    $\begingroup$ @Cystack The precise meaning of a p-value, type 1 error, type 2 error are beyond what can be conveyed in a comment. I'd start looking at answers to questions like stats.stackexchange.com/q/46856/1909 or stats.stackexchange.com/q/129628/1909, also see the "Linked" and "Related" boxes in the top right corner for more relevant content. $\endgroup$ – caracal Jan 11 at 9:25
2
$\begingroup$

To supplement caracal's answer, if you are looking for a user-friendly GUI option for calculating Type II error rates or power for many common designs including the ones implied by your question, you may wish to check out the free software, G Power 3.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.