logo

How to Draw a Power Function Graph in R 📂R

How to Draw a Power Function Graph in R

Overview

This section introduces a simple way to draw the graph of a univariate function. As an appropriate example in statistics, let’s draw a power function.

Definition

Let’s define the rejection region $C_{\alpha}$ at the significance level $\alpha$ for the null hypothesis $H_{0} : \theta \in \Theta_{0}$ and the alternative hypothesis $H_{1} : \theta \in \Theta_{1}$. The function $\gamma_{C_{\alpha}}(\theta) : = P_{\theta} [ \mathbf{x} \in C_{\alpha} ]$ for the true value $\theta$ is called the Power Function.

Description

Another expression is $\gamma_{C_{\alpha}}(\theta) : = 1 - P_{\theta}[\text{Type 2 Error}]$. Just like with the significance probability, understanding the power function merely by its definition is really not easy, so let’s start from looking at an example illustrated with a graph.

8.png

In the graph above, the two-tailed test shows the power function when the null hypothesis is $H_{0} : \mu = 0$, and the right-tailed test shows it when the null hypothesis is $H_{0} : \mu < 0$.

If you look closely at the graph, you can see that the function value $\gamma_{C_{\alpha}} (\theta_{0})$ at $x = \theta_{0}$ is the significance probability. Once you understand the relationship between the power function and the significance probability, there is nothing more you need to know about the power function. It’s okay to be confused whether it’s a left or right tail, but if you can’t even get a feel for the two-tailed test, there’s a high chance you don’t understand the significance probability at all.

Code

Below is an example code.

win.graph(7,3)
par(mfrow=c(1,2))
 
p2<-function(mu)
{
  return(1+pnorm(mu-1.96)-pnorm(mu+1.96))
}
 
plot(p2,-4,4,main="양쪽꼬리검정")
 
p1<-function(mu)
{
  return(pnorm(mu-1.96))
}
 
plot(p1,-4,4,main="오른쪽꼬리검정")