presentation for sample size calculator app

SarahLynn
1/29/2021

Motivation

why use a sample size calculator?

  • When you are designing an experiment, you need to know ahead of time how many observations to collect
    • If not planned correctly, when you try to analyze your test results you may find you dont have enough data to detect a difference that is truely there. On the flip side, you do not want to collect more data than you have to.
  • The calculator presented here allows for selection of your specific experiment type (ie one sample continuous outcome like if you are looking to see if mean height for a population is greater than X, or a two sample discrete outcome like if you are looking to compare conversion rates between a test and control group.)

Underlying code for app

The sample size calculator app uses formulas like the following to calculate power. Here we are using defualt parameters, but note that the app will allow you to change them.

#for one sample continuous outcome
power.t.test(delta=.1,sd=1,power=.9,
             type=c("one.sample"),
             alternative=c("two.sided"))$n
[1] 1052.665
#for two sample discrete outcome
pwr.2p.test(h=.05,sig.level=.05,power=.9,
            alternative=c("two.sided"))$n
[1] 8405.936

Visuals in app

The app will also display a graph that shows how the sample size needed will change as you adjust the difference to detect or other input parameters. Example below with default values.

plot of chunk unnamed-chunk-3

Conclusion

A well conducted experiment requires a pre-thought out sample size calculation and plan for collecting the appropriate data. A calculator like the one in this app will reduce the friction in gathering this information and hopefully make this step easier.

The sample size calculator app can be found here: https://swilde92.shinyapps.io/sample_size_calculator_r/