Determine the ideal sample size
When running an experiment and statistical analyses of any sort, sample size is an important consideration. A sample size that is too small will not reveal an effect, regardless of if there is an effect present to be found. Prior to collecting data, a power analysis can be run to determine the minimum sample size that must be collected to effectively detect an effect, dependent on the analysis that will be performed on the collected data.
Perform a one sample t-test, one group, on experimental data and need to determine the sample size required for a one sample t-test to achieve a large effect size and power with an alpha of 0.05.
This exercise is part of the course
A/B Testing in R
Exercise instructions
- Load the
pwr
package needed to run a power analysis for the one sample t-test. - Use
pwr.t.test()
to determine the sample size needed for a two-tailed, one sample t-test with an effect size of0.8
, power of0.9
, and significance of0.05
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Load the `pwr` package
___
# Determine the sample size needed for a one sample t-test
___(d = ___, power = ___, sig.level = ___, type = ___, alternative = ___)