In [6]:
powerf <- function(x, thet0, n, alph) {
  pchisq(thet0/x * qchisq(alph/2, 2*n), 2*n) +
  pchisq(thet0/x * qchisq(1-alph/2, 2*n), 2*n, lower.tail=FALSE)
}

par(mfrow=c(1,2))
x <- seq(0, 4, by=0.001)
y <- sapply(x, powerf, thet0=1, n=10, alph=0.05)  
plot(x, y, type="l", lty=1, lwd=2, xlab=expression(theta),
  ylab="Power", ylim=c(0,1))
abline(h=c(0,1), lty=2)  
abline(v=1, lty=2)
abline(h=0.05, lty=2)

x <- seq(0.6, 1.4, by=0.001)
y <- sapply(x, powerf, thet0=1, n=10, alph=0.05)  
plot(x, y, type="l", lty=1, lwd=2, xlab=expression(theta),
  ylab="Power", ylim=c(0,0.1))
abline(h=c(0,1), lty=2)  
abline(v=1, lty=2)
abline(h=0.05, lty=2)
par(mfrow=c(1,1))



In [ ]: