Power for a one-sample chi-square test using R

For a type I error, alpha, proportions contained in the vector, prop, and total sample size of ntot we obtain power, pow, and effect size, omega.

[COPY AND PASTE INPUTS BELOW INTO R AND ADJUST AS REQUIRED]

alpha <- 0.05
prop <- c(0.1,0.4,0.5)
ntot <- 23

[COPY AND PASTE THE BELOW INTO R]

chisq <- sum((prop - (1/length(prop)))^2)/(1/length(prop))
omega <- sqrt(chisq)
pow <- 1-pchisq(abs(qchisq(1-alpha,length(prop)-1)),length(prop)-1,ntot*chisq)
cat("Power of one-sample chi-square =")
print(pow)  
cat("Effect size, w, =")
print(omega)