1

Suppose I wish to calculate the sample size needed to detect a one percent change in a proportion that is normally at 35%. I don't mean 35% to 36%, I mean 35% to 35.35%. Here is the calculation in R blowing up:

> library(pwr)
> p2 = 0.35
> p1 = p2*1.01
> p1
[1] 0.3535
> h = 2 * asin(sqrt(p1)) - 2 * asin(sqrt(p2))
> alpha = 0.05
> beta = 0.05
> pwr.2p.test(h=h, sig.level=alpha, power = 1-beta)
Error in uniroot(function(n) eval(p.body) - power, c(2 + 1e-10, 1e+05)) : 
  f() values at end points not of opposite sign

Here is a 3% calculation succeeding and saying the sample needs to be of size 53,991:

> library(pwr)
> p2 = 0.35
> p1 = p2*1.03
> p1
[1] 0.3605
> h = 2 * asin(sqrt(p1)) - 2 * asin(sqrt(p2))
> alpha = 0.05
> beta = 0.05
> pwr.2p.test(h=h, sig.level=alpha, power = 1-beta)

     Difference of proportion power calculation for binomial distribution (arcsine transformation) 

              h = 0.02194005
              n = 53990.98
      sig.level = 0.05
          power = 0.95
    alternative = two.sided

NOTE: same sample sizes

I accept all the assumptions above (same sample size, two-sided test, etc.). See here and here for more info on pwr.

dfrankow
  • 2,816
  • 6
  • 30
  • 39
  • possible duplicate of [Simulation of Logistic Regression Power Analysis - Designed Experiments](http://stats.stackexchange.com/questions/35940/simulation-of-logistic-regression-power-analysis-designed-experiments) – gung - Reinstate Monica Mar 26 '14 at 17:20
  • I am curious why you are using an arcsine transformation when you have the capabilities to compute exact answers simply and directly with the `binom` family of functions. – whuber Mar 26 '14 at 17:28
  • Thanks for looking. Just used what was in my refs (http://www.statmethods.net/stats/power.html and http://cran.r-project.org/web/packages/pwr/pwr.pdf. – dfrankow Mar 26 '14 at 17:48
  • @gung: thanks for the ref. However, that page is enormous, and points to other enormous places. A common stats thing: everyone points to everyone else. For this simple, extremely well-defined problem, can we come up with an exact answer, and the method for it? That is: a number and explanation, not a ref. I think it would be very helpful. – dfrankow Mar 26 '14 at 17:49
  • This question is a duplicate, @dfrankow. If you want to understand how power analyses can be conducted in this situation (ie, the method & the explanation), the answer is in the linked thread. It further links to additional resources, but you don't need them to understand the relevant ideas, they're just there if you want more detail. If you just want someone to run the power analysis for you & give you an N, this Q would be off-topic for CV. – gung - Reinstate Monica Mar 26 '14 at 18:34
  • @gung I want to understand the relevant ideas, just in relation to a specific example, and with specific results. The first answer of the thread you link has literally 14 links to external resources. It's got to be simpler to answer this question of narrow scope. It's like answering "what is the confidence interval of a binomial proportion" with "read the following three books". I'd answer instead: "1.96 * sqrt(p*(1-p)/n) for a 95% confidence interval. Here are some refs." – dfrankow Mar 26 '14 at 18:58

0 Answers0