- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

To find the sample size for t test, we can use pwr.t.test function of pwr package, wherever we can pass the arguments for alternative hypothesis such as one-sided or two-sided, significance level, power of the test and difference for two samples.

Check out the below examples to understand how it works.

Consider the following code to find sample size for t test −

library("pwr") pwr.t.test(power=0.80,d=1,sig.level=0.05,alternative="two.sided")

If you execute the above given code, it generates the following Output for the two-sample t test power calculation −

n = 16.71472 d = 1 sig.level = 0.05 power = 0.8 alternative = two.sided

**Note** − n is number in *each* group.

Consider the following code to find sample size for t test −

library("pwr") pwr.t.test(power=0.90,d=1,sig.level=0.05,alternative="two.sided")

If you execute the above given code, it generates the following Output for the two-sample t test power calculation −

n = 22.02109 d = 1 sig.level = 0.05 power = 0.9 alternative = two.sided

**Note** − n is number in *each* group.

Consider the following code to find sample size for t test −

library("pwr") pwr.t.test(power=0.90,d=1.24,sig.level=0.05,alternative="two.sided")

If you execute the above given code, it generates the following Output for the two-sample t test power calculation −

n = 14.69768 d = 1.24 sig.level = 0.05 power = 0.9 alternative = two.sided

**Note** − n is number in *each* group.

Consider the following code to find sample size for t test −

library("pwr") pwr.t.test(power=0.90,d=1.24,sig.level=0.01,alternative="two.sided")

n = 21.08 d = 1.24 sig.level = 0.01 power = 0.9 alternative = two.sided

**Note** − n is number in *each* group.

Consider the following code to find sample size for t test −

library("pwr") pwr.t.test(power=0.80,d=1.24,sig.level=0.10,alternative="two.sided")

n = 8.80455 d = 1.24 sig.level = 0.1 power = 0.8 alternative = two.sided

**Note** − n is number in *each* group.

Consider the following code to find sample size for t test −

library("pwr") pwr.t.test(power=0.85,d=1.24,sig.level=0.10,alternative="two.sided")

n = 10.10416 d = 1.24 sig.level = 0.1 power = 0.85 alternative = two.sided

**Note** − n is number in *each* group.

Consider the following code to find sample size for t test −

library("pwr") pwr.t.test(power=0.90,d=2,sig.level=0.10,alternative="two.sided")

n = 5.130901 d = 2 sig.level = 0.1 power = 0.9 alternative = two.sided

**Note** − n is number in *each* group.

Consider the following code to find sample size for t test −

library("pwr") pwr.t.test(power=0.95,d=2,sig.level=0.10,alternative="two.sided")

n = 6.231837 d = 2 sig.level = 0.1 power = 0.95 alternative = two.sided

**Note** − n is number in *each* group.

Consider the following code to find sample size for t test −

library("pwr") pwr.t.test(power=0.95,d=2,sig.level=0.05,alternative="two.sided")

n = 7.608958 d = 2 sig.level = 0.05 power = 0.95 alternative = two.sided

**Note** − n is number in *each* group.

Consider the following code to find sample size for t test −

library("pwr") pwr.t.test(power=0.80,d=0.78,sig.level=0.05,alternative="two.sided")

n = 26.79675 d = 0.78 sig.level = 0.05 power = 0.8 alternative = two.sided

**Note** − n is number in *each* group.

Consider the following code to find sample size for t test −

library("pwr") pwr.t.test(power=0.80,d=1.5,sig.level=0.05,alternative="two.sided")

n = 8.060321 d = 1.5 sig.level = 0.05 power = 0.8 alternative = two.sided

**Note** − n is number in *each* group.

- Related Questions & Answers
- How to find the sample size for two sample proportion tests with given power in R?
- How to find the power of t test in R?
- How to apply two sample t test using a categorical column in R data frame?
- How to apply one sample t-test on all columns of an R data frame?
- How to perform paired t test for multiple columns in R?
- How to find critical value for one-sided and two-sided t test in R?
- How to perform one sample Kolmogorov-Smirnov test in R?
- How to extract the p-value from t test in R?
- sample test example question
- How to find the object size in R?
- How to Create a Test Plan? (Sample Template, Examples)
- How to return a logical value for a t test based on 0.05 level of significance in R?
- How to perform paired t test in R with a factor column in the data frame?
- How to find the size of the plotting window in R?
- How to create the random sample by defining the probabilities for each unit in R?

Advertisements