#### R script to demonstrate power and the ROC cureves library(TeachingDemos) # power calculation for the simple versus simple Normal test theta0 = 25 sigma0 = 3 theta1 = 30 diff = theta1-theta0 n = 300 # calculate the power power.examp(n = 30, stdev = 3, diff = diff, alpha = 0.05, xmin = -3, xmax = 3) # run the power demo run.power.examp(hscale=1.5, vscale=1.5, wait=FALSE) # ROC curve demo roc.demo(x = rnorm(n, theta0, sigma0), y = rnorm(n, theta1, sigma0)) # change n to 100, and theta1 to 27 theta1 = 30 n = 100 roc.demo(x = rnorm(n, theta0, sigma0), y = rnorm(n, theta1, sigma0)) ########################################################################## # distribution demos vis.normal() vis.t() vis.gamma() vis.binom() # there is also an MLE demo if(interactive()){ mle.demo() m <- runif(1, 50,100) s <- runif(1, 1, 10) x <- rnorm(15, m, s) mm <- mean(x) ss <- sqrt(var(x)) ss2 <- sqrt(var(x)*11/12) mle.demo(x) # now find the mle from the graph and compare it to mm, ss, ss2, m, and s }