# This R code computes sample sizes needed # to obtain equivalence tests for comparing # two success rate with specified power values. # This code is posted in the file power2e.sas # Specify the probability of success # for the first population (p1) p1 <- .70 # Specify upper bound on relative # risk rrb <- 1.2 # Enter power values power <- c(.8, .9) # Enter relative risk for some # alternatives rra <- c(1.05, 1.10) # Enter the type I error level alpha <- .05 np <- length(rra) # Cycle across alternatives for(i2 in 1:np) { pa <- qnorm(1-alpha)*sqrt(1+1/rra[i2]) pb <- qnorm(power)*sqrt(1+1/rrb) size <- ((pb+pa)/log(rrb/rra[i2]))^2 size <- ceiling(size) cat("\n \n Sample sizes for equivalence test", "\n \n p1=",p1,"RR=",rrb, "True RR", rra[i2], "alpha=", alpha,"power=", power, "\n \n Sample sizes: " , size, "\n") }