1234567891011121314151617181920212223242526272829303132 |
- library(pwr)
- # First Question: What was the Power of Our Study, With Different Effect Sizes
- p <<- .05
- N <- 30
- w <- seq(from = .07, to = .5, length=50)
- df <- 1
- results <- data.frame()
- ct <- function(w) {
- result <- pwr.chisq.test(w=w, df=df, sig.level=p, N=N)
- return(result$power)
- }
- power <- sapply(w, ct)
- results <- data.frame(p, N, w, df, power)
- library(ggplot2)
- ggplot(results, aes(x=w, y=power)) +
- geom_line() +
- ggtitle(sprintf('Power of Chi-Square Test of Decision Pilot Cliff Avoidance Experiment,\nfor different Effect Sizes (N=%i, p=%.2f)', N, p))
|