Bug 17345 - power.prop.test() function displays proportions over 1
Summary: power.prop.test() function displays proportions over 1
Status: CLOSED FIXED
Alias: None
Product: R
Classification: Unclassified
Component: Analyses (show other bugs)
Version: R 3.4.1
Hardware: Other Other
: P5 enhancement
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2017-09-27 14:45 UTC by gael.millot
Modified: 2017-12-09 17:15 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description gael.millot 2017-09-27 14:45:04 UTC
Hi.

Since the modification of the power.prop.test() function in R 3.1.3
("power.t.test() and power.prop.test() now make use of the extendInt option of uniroot() and hence work in more extreme cases. (PR#15792)")
the function can display proportion over 1 without warning message.
Example:

power.prop.test(n=30, p1=0.90, p2=NULL, sig.level=0.05, power=0.8, alternative="two.sided", strict=TRUE)

     Two-sample comparison of proportions power calculation 

              n = 30
             p1 = 0.9
             p2 = 1.030182
      sig.level = 0.05
          power = 0.8
    alternative = two.sided

NOTE: n is number in *each* group

This was not the case before the modification.

Moreover, in ?power.prop.test(), the following sentence is not clear:

"If one of them is computed p1 < p2 will hold, although this is not enforced when both are specified".

Many thanks for your help.
Comment 1 Martin Maechler 2017-11-11 14:39:46 UTC
(In reply to gael.millot from comment #0)
> Hi.
> 
> Since the modification of the power.prop.test() function in R 3.1.3
> ("power.t.test() and power.prop.test() now make use of the extendInt option
> of uniroot() and hence work in more extreme cases. (PR#15792)")
> the function can display proportion over 1 without warning message.
> Example:
> 
> power.prop.test(n=30, p1=0.90, p2=NULL, sig.level=0.05, power=0.8,
> alternative="two.sided", strict=TRUE)
> 
>      Two-sample comparison of proportions power calculation 
> 
>               n = 30
>              p1 = 0.9
>              p2 = 1.030182
>       sig.level = 0.05
>           power = 0.8
>     alternative = two.sided
> 
> NOTE: n is number in *each* group
> 
> This was not the case before the modification.

where it gave an error.  There's no valid  p2 > p1  ensuring such power.
You can see a boundary here:

 > power.prop.test(p1 = 0.90, p2 = 1.0, power=0.8)

     Two-sample comparison of proportions power calculation 

              n = 73.37427
             p1 = 0.9
             p2 = 1
      sig.level = 0.05
          power = 0.8
    alternative = two.sided

So, indeed, only when n >= 74  do you get a valid p2 <= 1.
Should we return an error in these cases instead?
Or just a warning?
I agree that one or the other should happen, but I don't really know.  I think I have never used the function (nor any power calculations in "real life" I think),
so maybe others should voice an opinion.

> 

> 
> Moreover, in ?power.prop.test(), the following sentence is not clear:
> 
> "If one of them is computed p1 < p2 will hold, although this is not enforced
> when both are specified".

Well, I did not write it, but I do understand it.  Is the following a bit clearer?
 
   If one of p1 and p2 is computed, then p1 < p2 is assumed and will hold 
   (but you can specify p2 <= p1).


> 
> Many thanks for your help.
Comment 2 Martin Maechler 2017-12-08 22:18:14 UTC
I've decided to only signal a warning for now   (and only in R-devel)...

Current plan is to port to R-patched ... 

and possibly --- typically after a year so, make the warning into an error.
Comment 3 gael.millot 2017-12-09 17:15:32 UTC
Yes, the sentence is clearer to me. Thanks for everything !