Solved – How to conduct sample size calculation for >2 groups in R

rsample-size

I am attempting to determine the sample size needed in a clinical study of 2 treatment groups to one control group (3 groups total). However, I am not sure how to calculate this properly. Traditionally, the bsamsize function in the Hmisc package is what I have been using to calculate sample size if the desired power, proportions of each group being compared (p0 under null and p1 under alternative), and the fraction of observations in the first group. You can find this function's documentation here: https://www.rdocumentation.org/packages/Hmisc/versions/4.1-0/topics/bpower

So I am wondering, how would one go about calculating the sample size needed for, say, 2 treatment groups and 1 control group, if one wanted equal numbers of subjects in each group? In this case, I don't think there is a way to do this using the bsamsize function, since this assumes only one hypothesis being tested. How would I want to go about specifying multiple hypotheses (e.g., Control mean is different from Treatment 1 but not Treatment 2, Control mean is different from both Treatment 1 and Treatment 2, etc.)?

So far, I have tried the following code using generic values:

p1 = 0.1
p2 = 0.15
frac = 1/3
bsamsize(p1, p2, fraction=frac, alpha=.05, power=.8)

To get the output:

n1        n2 
525.3318 1050.6636 

I believe that the fraction needs to be 1/3 if I have 3 groups total. But, when using this function, we can only specify p1 and p2, and not a third proportion, say p3, to get 3 equal sample sizes for 3 total groups.

I am hoping that someone knows of a package that can handle a research question such as this. I also would be interested to know how to generalize this problem, say to compare 3, 4, 5, …, x treatments to a control at once.

Thank you for any/all help!

Best Answer

If you do a three group comparison: Trt1 vs Ctl and Trt2 vs control, then a sample size calculation can be done in the following way:

Obtain sample sizes for Trt1 and Ctl in a two group comparison.

Obtain sample sizes for Trt2 and Ctl in a second two group comparison.

Assign Trt1 and Trt2 according to their respective sample size calculations. Assign control according to the maximum of either sample size calculation. It will simply be a slightly more precise/powerful comparison in the smaller, larger effect treatment group. If the effects of Trt1 and Trt2 are equal, their sample sizes are equal, and you simply assign another 50% of the participants to the other treatment.

Related Question