Power & Sample Size Calculations
One key part of designing an experiment is knowing the required sample size you'll need to be able to test your hypothesis.
The pwr
package provides a handy function, pwr.t.test()
, which will calculate that for you. However, you do need to know your desired significance level (often 0.05), if the test is one- or two-sided, if the data is from one sample, two samples, or paired, the effect size, and the power. Some of this information will be given to you or can be reasoned from the design.
A power or sample size calculation is usually different each time you conduct one, and the details of the calculation strongly depend on what kind of experiment you're designing and what your end goals are.
This exercise is part of the course
Experimental Design in R
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Load the pwr package
___
# Calculate power
pwr.t.test(n = ___,
d = ___,
sig.level = ___,
type = "two.sample",
alternative = "two.sided",
power = NULL)