Sample Size for Medical Research with R

A Quick Guide Cookbook

Author

Kittipos Sirivongrungson

Published

October 19, 2024

Preface

Goal

An in-development cookbook & code collection for sample size calculation in medical research using R

Who is book for

This book this for someone who has

  • Some basic R knowledge.

  • Some experience conducting statistical test (e.g., t-test).

But you haven’t done any sample size calculation before (at least in R) and you want a quick tutorial to do that in R with some examples.

Resources

Many of the resources and code are from these sources:

Functions

Here is the summary of functions that help you calculate sample size or power based on statistical test

# Groups Package Function
Continuous ~ Categorical / parametric
One-sample t test 1

pwr

pwr.t.test(type = 'one.sample')

Two-sample t test 2

pwr

pwr.t.test(type = 'two.sample')

Paired t test 2

pwr

pwr.t.test(type = 'paired')

One-way ANOVA ≥3

pwr

pwr.anova.test()

Continuous ~ Categorical / nonparametric
One-sample Wilcoxon test 1

pwr

NA
Mann-Whitney U test 2

pwr

NA
Paired Wilcoxon test 2

pwr

NA
Kruskal-Wallis test ≥3

pwr

NA

TODO: make table above from here

R Packages and functions for sample size calculation, from (Park et al. 2023)

R Package Used