Chapter 26 Power and Sample Size Issues Comparing Two Means
26.1 Paired Sample t Tests and Power/Sample Size
For a paired-samples t test, R can estimate any one of the following elements, given the other four, using the power.t.test
command, for either a one-tailed or two-tailed paired t test…
- n = the sample size (# of pairs) being compared
- \(\delta\) = delta = the true difference in means between the two groups
- s = sd = the true standard deviation of the paired differences
- \(\alpha\) = sig.level = the significance level for the comparison (maximum acceptable risk of Type I error)
- 1 - \(\beta\) = power = the power of the paired t test to detect the effect of size \(\delta\)
26.2 A Toy Example
As a toy example, suppose you are planning a paired samples experiment involving n = 30 subjects who will each provide a “Before” and an “After” result, which is measured in days.
Suppose you want to do a two-sided (two-tailed) test at 95% confidence (so \(\alpha\) = 0.05), and that you expect that the true difference between the “Before” and “After” groups will have to be at least \(\delta\) = 5 days to be of any real interest. Suppose also that you are willing to assume that the true standard deviation of those paired differences will be 10 days.
That is, of course, a lot to suppose.
Now, we want to know what power the proposed experiment will have to detect this difference with these specifications, and how tweaking these specifications will affect the power of the study.
So, we have - n = 30 paired differences will be collected - \(\delta\) = 5 days is the minimum clinically meaningful difference - s = 10 days is the assumed population standard deviation of the paired differences - \(\alpha\) is 0.05, and we’ll do a two-sided test
26.3 Using the power.t.test
function
power.t.test(n = 30, delta = 5, sd = 10, sig.level = 0.05,
type="paired", alternative="two.sided")
Paired t test power calculation
n = 30
delta = 5
sd = 10
sig.level = 0.05
power = 0.754
alternative = two.sided
NOTE: n is number of *pairs*, sd is std.dev. of *differences* within pairs
So, under this study design, we would expect to detect an effect of size \(\delta\) = 5 days with 75% power, i.e. with a probability of incorrect retention of H0 of 0.25. Most of the time, we’d like to improve this power, and to do so, we’d need to adjust our assumptions.
26.4 Changing Assumptions in a Power Calculation
We made assumptions about the sample size n, the minimum clinically meaningful difference in means \(\delta\), the population standard deviation s, and the significance level \(\alpha\), not to mention decisions about the test, like that we’d do a paired t test, rather than another sort of test for paired samples, or use an independent samples approach, and that we’d do a two-tailed, or two-sided test. Often, these assumptions are tweaked a bit to make the power look more like what a reviewer/funder is hoping to see.
26.4.1 Increasing the Sample Size, absent other changes, will Increase the Power
Suppose, we committed to using more resources and gathering “Before” and “After” data from 40 subjects instead of the 30 we assumed initially – what effect would this have on our power?
power.t.test(n = 40, delta = 5, sd = 10, sig.level = 0.05,
type="paired", alternative="two.sided")
Paired t test power calculation
n = 40
delta = 5
sd = 10
sig.level = 0.05
power = 0.869
alternative = two.sided
NOTE: n is number of *pairs*, sd is std.dev. of *differences* within pairs
With more samples, we should have a more powerful test, able to detect the difference with greater probability. In fact, a sample of 40 paired differences yields 87% power. As it turns out, we would need at least 44 paired differences with this scenario to get to 90% power, as shown in the calculation below, which puts the power in, but leaves out the sample size.
power.t.test(power=0.9, delta = 5, sd = 10, sig.level = 0.05,
type="paired", alternative="two.sided")
Paired t test power calculation
n = 44
delta = 5
sd = 10
sig.level = 0.05
power = 0.9
alternative = two.sided
NOTE: n is number of *pairs*, sd is std.dev. of *differences* within pairs
We see that we would need at least 44 paired differences to achieve 90% power. Note: we always round the sample size up in doing a power calculation – if this calculation had actually suggested n = 43.1 paired differences were needed, we would still have rounded up to 44.
26.4.2 Increasing the Effect Size, absent other changes, will increase the Power
A larger effect should be easier to detect. If we go back to our original calculation, which had 75% power to detect an effect (i.e. a true population mean difference) of size \(\delta\) = 5, and now change the desired effect size to \(\delta\) = 6, we should obtain a more powerful design.
power.t.test(n = 30, delta = 6, sd = 10, sig.level = 0.05,
type="paired", alternative="two.sided")
Paired t test power calculation
n = 30
delta = 6
sd = 10
sig.level = 0.05
power = 0.888
alternative = two.sided
NOTE: n is number of *pairs*, sd is std.dev. of *differences* within pairs
We see that this change in effect size from 5 to 6, leaving everything else the same, increases our power from 75% to nearly 89%. To reach 90% power, we’d need to increase the effect size we were trying to detect to at least 6.13 days.
- Again, note that I am rounding up here.
- Using \(\delta\) = 6.12 would not quite make it to 90.00% power.
- Using \(\delta\)=6.13 guarantees that the power will be 90% or more, and not just round up to 90%..
26.4.3 Decreasing the Standard Deviation, absent other changes, will increase the Power
The choice of standard deviation is usually motivated by a pilot study, or else pulled out of thin air. It’s relatively easy to convince yourself that the true standard deviation might be a little smaller than you’d guessed initially. Let’s see what happens to the power if we reduce the sample standard deviation from 10 days to 9 days. This should make the effect of 5 days easier to detect as being different from the null hypothesized value of 0, because it will have smaller variation associated with it.
power.t.test(n = 30, delta = 5, sd = 9, sig.level = 0.05,
type="paired", alternative="two.sided")
Paired t test power calculation
n = 30
delta = 5
sd = 9
sig.level = 0.05
power = 0.837
alternative = two.sided
NOTE: n is number of *pairs*, sd is std.dev. of *differences* within pairs
This change in standard deviation from 10 to 9, leaving everything else the same, increases our power from 75% to nearly 84%. To reach 90% power, we’d need to decrease the standard deviation of the population paired differences to no more than 8.16 days.
Note I am rounding down here, because using \(s\) = 8.17 days would not quite make it to 90.00% power. Note also that in order to get R to treat the sd as unknown, I must specify it as NULL in the formula…
power.t.test(n = 30, delta = 5, sd = NULL, power = 0.9,
sig.level = 0.05, type="paired", alternative="two.sided")
Paired t test power calculation
n = 30
delta = 5
sd = 8.16
sig.level = 0.05
power = 0.9
alternative = two.sided
NOTE: n is number of *pairs*, sd is std.dev. of *differences* within pairs
26.4.4 Tolerating a Larger \(\alpha\) (Significance Level), without other changes, increases Power
We can trade off some of our Type II error (lack of power) for Type I error. If we are willing to trade off some Type I error (as described by the \(\alpha\)), we can improve the power. For instance, suppose we decided to run the original test with 90% confidence.
power.t.test(n = 30, delta = 5, sd = 10, sig.level = 0.1,
type="paired", alternative="two.sided")
Paired t test power calculation
n = 30
delta = 5
sd = 10
sig.level = 0.1
power = 0.848
alternative = two.sided
NOTE: n is number of *pairs*, sd is std.dev. of *differences* within pairs
The calculation suggests that our power would thus increase from 75% to nearly 85%.
26.5 Two Independent Samples: Power for t Tests
For an independent-samples t test, with a balanced design (so that \(n_1\) = \(n_2\)), R can estimate any one of the following elements, given the other four, using the power.t.test
command, for either a one-tailed or two-tailed t test…
- n = the sample size in each of the two groups being compared
- \(\delta\) = delta = the true difference in means between the two groups
- s = sd = the true standard deviation of the individual values in each group (assumed to be constant – since we assume equal population variances)
- \(\alpha\) = sig.level = the significance level for the comparison (maximum acceptable risk of Type I error)
- 1 - \(\beta\) = power = the power of the t test to detect the effect of size \(\delta\)
This method only produces power calculations for balanced designs – where the sample size is equal in the two groups. If you want a two-sample power calculation for an unbalanced design, you will need to use a different library and function in R, as we’ll see.
26.6 A New Example
Suppose we plan a study of the time to relapse for patients in a drug trial, where subjects will be assigned randomly to a (new) treatment or to a placebo. Suppose we anticipate that the placebo group will have a mean of about 9 months, and want to detect an improvement (increase) in time to relapse of 50%, so that the treatment group would have a mean of at least 13.5 months. We’ll use \(\alpha\) = .10 and \(\beta\) = .10, as well. Assume we’d do a two-sided test, with an equal number of observations in each group, and we’ll assume the observed standard deviation of 9 months in a pilot study will hold here, as well.
We want the sample size required by the test under a two sample setting where:
- \(\alpha\) = .10,
- with 90% power (so that \(\beta\) = .10),
- and where we will have equal numbers of samples in the placebo group (group 1) and the treatment group (group 2).
- We’ll plug in the observed standard deviation of 9 months.
- We’ll look at detecting a change from 9 [the average in the placebo group] to 13.5 (a difference of 50%, giving delta = 4.5)
- using a two-sided pooled t-test.
The appropriate R command is:
power.t.test(delta = 4.5, sd = 9,
sig.level = 0.10, power = 0.9,
type="two.sample",
alternative="two.sided")
Two-sample t test power calculation
n = 69.2
delta = 4.5
sd = 9
sig.level = 0.1
power = 0.9
alternative = two.sided
NOTE: n is number in *each* group
This suggests that we will need a sample of at least 70 subjects in the treated group and an additional 70 subjects in the placebo group, for a total of 140 subjects.
26.6.1 Another Scenario
What if resources are sparse, and we’ll be forced to do the study with no more than 120 subjects, overall? If we require 90% confidence in a two-sided test, what power will we have?
power.t.test(n = 60, delta = 4.5, sd = 9,
sig.level = 0.10,
type="two.sample",
alternative="two.sided")
Two-sample t test power calculation
n = 60
delta = 4.5
sd = 9
sig.level = 0.1
power = 0.859
alternative = two.sided
NOTE: n is number in *each* group
It looks like the power under those circumstances would be just under 86%. Note that the n = 60 refers to half of the total sample size, since we’ll need 60 drug and 60 placebo subjects in this balanced design.
26.7 Power for Independent Sample T tests with Unbalanced Designs
Using the pwr
library, R can do sample size calculations that describe the power of a two-sample t test that does not require a balanced design using the pwr.t2n.test
command.
Suppose we wanted to do the same study as we described above, using 100 “treated” patients but as few “placebo” patients as possible. What sample size would be required to maintain 90% power? There is one change here – the effect size d in the pwr.t2n.test
command is specified using the difference in means \(\delta\) that we used previously, divided by the standard deviation s that we used previously. So, in our old setup, we assumed delta = 4.5, sd = 9, so now we’ll assume d = 4.5/9 instead.
pwr::pwr.t2n.test(n1 = 100, d = 4.5/9,
sig.level = 0.1, power = 0.9,
alternative="two.sided")
t test power calculation
n1 = 100
n2 = 52.8
d = 0.5
sig.level = 0.1
power = 0.9
alternative = two.sided
We would need at least 53 subjects in the “placebo” group.
26.7.1 The most efficient design for an independent samples comparison will be balanced.
- Note that if we use \(n_1\) = 100 subjects in the treated group, we need at least \(n_2\) = 53 in the placebo group to achieve 90% power, and a total of 153 subjects.
- Compare this to the balanced design, where we needed 70 subjects in each group to achieve the same power, thus, a total of 140 subjects.
We saw earlier that a test with 60 subjects in each group would yield just under 86% power. Suppose we instead built a test with 80 subjects in the treated group, and 40 in the placebo group, then what would our power be?
pwr::pwr.t2n.test(n1 = 80, n2 = 40, d = 4.5/9,
sig.level = 0.10,
alternative="two.sided")
t test power calculation
n1 = 80
n2 = 40
d = 0.5
sig.level = 0.1
power = 0.822
alternative = two.sided
As we’d expect, the power is stronger for a balanced design than for an unbalanced design with the same overall sample size.
Note that I used a two-sided test to establish my power calculation – in general, this is the most conservative and defensible approach for any such calculation, unless there is a strong and specific reason to use a one-sided approach in building a power calculation, don’t.