I am trying to test whether the sex ratio of some sampled individuals significantly differs from the expected sex ratio of 1. I have n= 64, of which female=34 and male=30.
I ran a binomial test:
succ <- c(34,30)
binom.test(succ,0.5)
data: succ
number of successes = 34, number of trials = 64, p-value = 0.708
alternative hypothesis: true probability of success is not equal to 0.5
95 percent confidence interval:
0.4023098 0.6572035
sample estimates:
probability of success
0.53125
I would like to calculate the statistical power of this test, and I know that power = 1-β, where β is the type II error.
I am getting confused when reading this explanation. I don't understand how to adapt this formula (for different choices of n) to my case:
enn = 1:2000
critical = qbinom(.025, enn, .5)
beta = pbinom(enn-critical,enn,.55) - pbinom(critical-1,enn,.55)
What I did was
1-(pbinom(34,64,0.5)- pbinom(30, 64, .5))
[1] 0.7410237
but I am not sure if it is correct to use 0.5 as probability. Moreover, I tried a different method, and I get a completely different result
pwr.p.test(ES.h(.53125,.5),n=64, power=NULL, alternative = "two.sided")
proportion power calculation for binomial distribution (arcsine transformation)
h = 0.06254076
n = 64
sig.level = 0.05
power = 0.07913605
alternative = two.sided
Is one of these two tests correct and why?
Thanks for your help!
