Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/Rscript
- library(statmod)
- library(ggplot2)
- library(reshape2)
- num_samples <- 10
- pow <- matrix(nrow=(num_samples+1), ncol=(num_samples+1))
- for(j in 1:(num_samples+1)){
- for(i in 1:(num_samples+1)) {
- p1 <- (i-1)/num_samples
- p2 <- (j-1)/num_samples
- pow[i, j] <- power.fisher.test(p1, p2, num_samples, num_samples)
- }
- }
- rownames(pow) <- c(0:num_samples)/num_samples
- colnames(pow) <- c(0:num_samples)/num_samples
- melted_pow <- melt(pow)
- png('fischer.power.samples.png')
- ggplot(data=melted_pow, aes(x=Var1, y=Var2, fill=value)) + geom_tile() + labs(y="Fraction of Responders", x="Fraction of Non-Responders") + guides(fill=guide_legend("power"))
- dev.off()
Add Comment
Please, Sign In to add comment