On Feb 5, 2014, at 10:05 AM, Simone <misen...@hotmail.com> wrote: > Hi all, > > I have performed a binomial test to verify if the number of males in a study > is significantly different from a null hypothesis (say, H0:p of being a male= > 0.5). > For instancee: > binom.test(10, 30, p=0.5, alternative="two.sided", conf.level=0.95) > > Exact binomial test > > data: 10 and 30 > number of successes = 10, number of trials = > 30, p-value = 0.09874 > alternative hypothesis: true probability of success is not equal to 0.5 > 95 percent confidence interval: > 0.1728742 0.5281200 > sample estimates: > probability of success > 0.3333333 > > This way I get the estimated proportion of males (in this case p of success) > that is equal to 0.33 and an associated p-value (this is not significant at > alpha=0.05 with respect to the H0:P=0.5). > > Now, I want to know, given a power of, say, 0.8, alpha=0.05 and the above > sample size (30), what is the minimum proportion of males as low or as high > (two sided) like to be significantly detected with respect to a H0 (not > necessarily H0:P=0.5 - I am interested also in other null hypotheses). In > other words, I would have been able to detect a significant deviation from > the H0 for a given power, alpha and sample size if the proportion of males > would have been more than Xhigh or less than Xlow. > > I have had a look at the "pwr" package but it seems to me it doesn't allow to > calculate this. > I would appreciate very much any suggestion.
Take a look at ?power.prop.test, where you can specify that one of the proportions is NULL, yielding the value you seek: > power.prop.test(n = 30, p1 = 0.5, p2 = NULL, power = 0.8, sig.level = 0.05) Two-sample comparison of proportions power calculation n = 30 p1 = 0.5 p2 = 0.834231 sig.level = 0.05 power = 0.8 alternative = two.sided NOTE: n is number in *each* group The value for 'p2' is your high value for the detectible difference from a proportion of 0.5, given the other parameters. 1 - p2 would be your low value. Regards, Marc Schwartz ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.