# Sample size requirements for t tests

Example 1: What is the minimum sample size needed to obtain power of at least 80% for a two sample, two-tailed t test with null hypothesis μ1 = μto detect an effect of size d = .4 assuming that both samples have the same size?

We begin by repeating Example 3 of Statistical Power of the t tests, assuming that the two sample sizes are equal (see Figure 4 of Statistical Power of the t tests).

Figure 1 – Initialize search for sample size

We now employ Excel’s Goal Seek capability by selecting Data > Data Tools|What-if Analysis > Goak Seek… When a dialog box as in Figure 2 appears, fill in the fields as indicated.

Figure 2 – Goal Seek dialog box

The results are shown in Figure 3.

Figure 3 – Sample size needed to achieve 80% power

Rounding up to the nearest integer, we see that a sample size of 99 is required to detect an effect of .4 with power of about 80%. In fact we see that a sample size of 99 still leaves us just short of 80% power. We need a sample of size 100 to achieve 80% power; note that T2_POWER(.4,100) = .803648.

This same result can be achieved using the second of the following supplemental functions.

Real Statistics Functions: The following functions are provided in the Real Statistics Resource Pack:

T1_SIZE(d, 1−β, tails, α, iter, prec) = the minimum sample size required to obtain power of at least 1β (default .80) in a one sample t test when d = Cohen’s effect size, tails = # of tails: 1 or 2 (default) and α = alpha (default = .05).

T2_SIZE(d, 1β, tails, α, nratio, iter, prec) = the minimum sample size required to obtain power of at least 1β (default .80) in a two sample t test when d = Cohen’s effect size, tails = # of tails: 1 or 2 (default), α = alpha (default = .05) and nratio = the size of the second sample divided by the size of the first sample (default = 1).

Here iter = the maximum number of terms from the infinite sum (default 1000) and prec = the maximum amount of error acceptable in the estimate of the infinite sum unless the iteration limit is reached first (default = 0.000000000001).

In the two sample case, only the size of the first sample is returned. If the two samples don’t have the same size, you can specify the size of the second sample in terms of the size of first sample using the nratio argument. E.g. if the size of the second sample is half of the first, then set nratio = .5.

If you set nratio to be a negative number then the absolute value of this number will be used as the sample size of the second sample. E.g. if nratio = -50, then the T2_SIZE function will find the size of the first sample assuming that the second sample has 50 elements.

For Example 1, T2_SIZE(.4) = T2_SIZE(.4, .8, 2, .05, 1, 1000, 0.000000000001) = 100. T2_SIZE(.4, .9) = 133, which is consistent with the fact that a larger sample is required to obtain higher statistical power. Also T2_SIZE(.4, .8, 1) = 78, which is consistent with the fact that a one-tailed test requires a smaller sample. We also see that T2_SIZE(.4, .8, 2, .025) = 121, which is consistent with the fact that a lower value of α requires a larger sample to achieve the same power. T2_SIZE(.3) = 176, which is consistent with the fact that a larger sample is required to detect a smaller effect size.

Finally, T1_SIZE(.4) = 52, which is consistent with the fact that a paired sample test requires a smaller sample to achieve the same power.

### 2 Responses to Sample size requirements for t tests

1. Art sergi says:

Mr. Zaiontz,
My company is using the Excel t-test unequal variance for a population of 3 and I am doubting that this is large enough to produce valid results.