How to find the sample size for two sample proportion tests with given power in R?

R ProgrammingServer Side ProgrammingProgramming

To find the sample size for two sample proportion tests with given power, we can use the function power.prop.test where we need to at least pass the two proportions and power.

By default the significance level will be taken as 0.05 and if we want to change it then sig.level argument will be used.

Given below are some examples with the display of significance levels.

Example 1

Use the code given below to find the sample size for two sample proportion tests −

power.prop.test(p1=8/20,p2=6/20,power=0.90,sig.level=0.05)

Output

If you execute the above given snippet, it generates the following Output for the two-sample comparison of proportions power calculation −

   n = 476.0072
   p1 = 0.4
   p2 = 0.3
sig.level = 0.05
   power = 0.9
alternative = two.sided

Note − n is number in *each* group.

Example 2

Use the code given below to find the sample size for two sample proportion tests −

power.prop.test(p1=18/20,p2=16/20,power=0.90,sig.level=0.05)

Output

If you execute the above given snippet, it generates the following Output for the two-sample comparison of proportions power calculation −

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

Note − n is number in *each* group.

Example 3

Use the code given below to find the sample size for two sample proportion tests −

power.prop.test(p1=18/100,p2=16/100,power=0.90,sig.level=0.05)

Output

If you execute the above given snippet, it generates the following Output for the two-sample comparison of proportions power calculation −

   n = 7410.91
   p1 = 0.18
   p2 = 0.16
sig.level = 0.05
   power = 0.9
alternative = two.sided

Note − n is number in *each* group.

Example 4

Use the code given below to find the sample size for two sample proportion tests −

power.prop.test(p1=18/1000,p2=16/1000,power=0.90,sig.level=0.05)

Output

If you execute the above given snippet, it generates the following Output for the two-sample comparison of proportions power calculation −

      n = 87792.7
   p1 = 0.018
   p2 = 0.016
sig.level = 0.05
   power = 0.9
alternative = two.sided

Note − n is number in *each* group.

Example 5

Use the code given below to find the sample size for two sample proportion tests −

power.prop.test(p1=49/100,p2=51/100,power=0.90,sig.level=0.05)

Output

If you execute the above given snippet, it generates the following Output for the two-sample comparison of proportions power calculation −

      n = 13132.2
   p1 = 0.49
   p2 = 0.51
sig.level = 0.05
   power = 0.9
alternative = two.sided

Note − n is number in *each* group.

Example 6

Use the code given below to find the sample size for two sample proportion tests −

power.prop.test(p1=49/100,p2=51/100,power=0.90,sig.level=0.10)

Output

If you execute the above given snippet, it generates the following Output for the two-sample comparison of proportions power calculation −

      n = 10702.93
   p1 = 0.49
   p2 = 0.51
sig.level = 0.1
   power = 0.9
alternative = two.sided

Note − n is number in *each* group.

Example 7

Use the code given below to find the sample size for two sample proportion tests −

power.prop.test(p1=49/100,p2=51/100,power=0.95,sig.level=0.10)

Output

If you execute the above given snippet, it generates the following Output for the two-sample comparison of proportions power calculation −

      n = 13525.01
   p1 = 0.49
   p2 = 0.51
sig.level = 0.1
   power = 0.95
alternative = two.sided

Note − n is number in *each* group.

Example 8

Use the code given below to find the sample size for two sample proportion tests −

power.prop.test(p1=49/100,p2=51/100,power=0.80,sig.level=0.10)

Output

If you execute the above given snippet, it generates the following Output for the two-sample comparison of proportions power calculation −

      n = 7727.15
   p1 = 0.49
   p2 = 0.51
sig.level = 0.1
   power = 0.8
alternative = two.sided

Note − n is number in *each* group.

Example 9

Use the code given below to find the sample size for two sample proportion tests −

power.prop.test(p1=5/200,p2=5/100,power=0.80,sig.level=0.10)

Output

If you execute the above given snippet, it generates the following Output for the two-sample comparison of proportions power calculation −

      n = 713.0383
   p1 = 0.025
   p2 = 0.05
sig.level = 0.1
   power = 0.8
alternative = two.sided

Note − n is number in *each* group.

Example 10

Use the code given below to find the sample size for two sample proportion tests −

power.prop.test(p1=5/200,p2=5/100,power=0.80,sig.level=0.05)

Output

If you execute the above given snippet, it generates the following Output for the two-sample comparison of proportions power calculation −

      n = 905.3658
   p1 = 0.025
   p2 = 0.05
sig.level = 0.05
   power = 0.8
alternative = two.sided

Note − n is number in *each* group.

Example 11

Use the code given below to find the sample size for two sample proportion tests −

power.prop.test(p1=5/200,p2=5/100,power=0.80,sig.level=0.05,alternative="one.sided")

Output

If you execute the above given snippet, it generates the following Output for the two-sample comparison of proportions power calculation −

      n = 713.0383
   p1 = 0.025
   p2 = 0.05
sig.level = 0.05
   power = 0.8
alternative = one.sided

Note − n is number in *each* group.

raja
Updated on 03-Nov-2021 07:01:21

Advertisements