- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to find the sample size for two sample proportion tests with given power in R?
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.
- Related Articles
- How to find the sample size for t test in R?
- How to create sample space of throwing two dices in R?
- How to repeat a random sample in R?
- How to deal with error “Error in shapiro.test(…) : sample size must be between 3 and 5000” in R?
- How to perform one-way anova with unequal sample sizes in R?
- How to create the random sample by defining the probabilities for each unit in R?
- How to create a random sample with values 0 and 1 in R?
- How to create a random sample of months in R?
- How to perform one sample Kolmogorov-Smirnov test in R?
- How to apply two sample t test using a categorical column in R data frame?
- How to create a random sample of week days in R?
- How to take a random sample from a matrix in R?
- How to create sample of rows using ID column in R?
- How to create a sample or samples using probability distribution in R?
- Sample questions for ITIL Foundation Course
