Sample size

Sample size calculator for comparing two variances

Calculate the sample size needed to test \(H_0: \sigma_1 = \sigma_2\) at a target power using the exact F-test.

This tool calculates the sample size needed to test the equality of two variances (\(H_0: \sigma_1 = \sigma_2\)) at the target power, using the exact \(F\) test.

Parameters

Enter the ratio R = σ₁/σ₂, the significance level and the desired power. The same size is assumed in both groups (n₁ = n₂ = n).

Result pending…

Power curve by sample size

Check the parameters: the chart will appear once they are valid.

Explanation

The Snedecor-Fisher F-test tests the equality of variances of two independent normal populations using the statistic \(F = S_1^2/S_2^2\), which under \(H_0\) follows an \(F(n_1-1, n_2-1)\) distribution.

Under the alternative \(\sigma_1 = R \cdot \sigma_2\) with \(R \neq 1\), we have \(F/R^2 \sim F(n_1-1, n_2-1)\), which, if both populations are normal, allows the exact power to be computed without needing noncentral F distributions. The calculator searches for the smallest \(n\) (per group) so that the exact two-tailed power reaches the target.

Exact power formula

For the two-tailed test \(H_a: \sigma_1 \neq \sigma_2\) with equal-sized groups \(n\):

\( \text{Power} = F_{F(df,df)}\!\left(\frac{F_{\alpha/2,\,df,\,df}}{R^2}\right) + 1 - F_{F(df,df)}\!\left(\frac{F_{1-\alpha/2,\,df,\,df}}{R^2}\right) \)

where \(df = n-1\) and \(F_{p,df,df}\) is the \(p\) quantile of the \(F(df, df)\) distribution. The calculator searches for the smallest \(n\) that satisfies the target power.

  • R > 1: σ₁ > σ₂ (group 1 is more variable).
  • R < 1: in the two-tailed test, equivalent to R'=1/R with the groups swapped. In the one-tailed σ₁ > σ₂ test, R must be greater than 1.

Quick settings

  • R: use R > 1 for the one-tailed σ₁ > σ₂ test; the two-tailed test also accepts R < 1. R=1.5 is a moderate effect; R=2 is already large.
  • α: 0.05 is the standard; 0.01 for critical decisions about variability.
  • Power: 0.80 as a minimum; 0.90 for validation studies.
  • Normality: the F-test of variances is very sensitive to non-normality. If the data are not normal, consider Levene or Brown–Forsythe; Bartlett is also sensitive to non-normality.

Worked example

A study compares the variability of reaction times between a group with and without pharmacological treatment. The researcher considers it relevant to detect differences of 50% or more in the standard deviation (R = 1.5), with \(\alpha = 0.05\) and 80% power.

The calculator returns n = 50 per group (100 in total). If both populations are normal, the F-test with 49 degrees of freedom in each group has at least an 80% probability of rejecting \(H_0\) when the true ratio of standard deviations is ≥ 1.5.

Sensitivity analysis: with R = 2 (fourfold variance) the sample shrinks to n = 19 per group. For R = 1.25, n = 160 per group is needed. The sample size is highly sensitive to R in the region R ∈ (1, 2).

Model assumptions

  • Two random samples, independent of each other.
  • Both populations are normal: the \(F\) test is sensitive to departures from normality.
  • Observations within each group are independent.
  • The sample size is derived from the exact \(F\) distribution for the variance ratio.

How to interpret the result

The value \(n\) is the minimum size of each group in a balanced design to test whether two population variances differ using the Snedecor F-test. The total study size is \(2n\), and the numerator and denominator degrees of freedom are each \(n - 1\). Always round up; one fewer observation can reduce the degrees of freedom right at the critical margin. If you anticipate dropout or rejections, divide each \(n\) by \((1 - \text{dropout rate})\) to get the actual recruitment target per group.

The effect of interest is the variance ratio \(\lambda = \sigma_1^2 / \sigma_2^2\) (or its inverse in the two-tailed test if \(\lambda < 1\)). The design's sensitivity to the specification of \(\lambda\) is high: if the true ratio turns out to be closer to 1 than assumed, the test will have less power than planned. Run a sensitivity analysis by computing \(n\) for different values of \(\lambda\) within a reasonable range. It is important to keep in mind that the F-test is extraordinarily sensitive to non-normality: even moderate deviations from normality can seriously inflate the type I error rate, making the p-value unreliable. If the data are not clearly normal, consider alternative tests such as Levene or Brown–Forsythe (Bartlett is also sensitive to non-normality) and adjust \(n\) accordingly.

Development and additional details

When the calculated \(n\) is very large, it usually indicates that the specified effect size (\(\lambda\) close to 1) is too small to be detected efficiently with a variance-ratio test; consider whether the difference between variances has practical relevance. If the goal is to estimate the variance ratio with a given precision rather than test it, use the sample size calculator for the variance CI. Once the data has been collected, analyze the results with the F-test for two variances.

References

  • Zar, J. H. (2010). Biostatistical Analysis (5th ed.). Pearson.
  • Montgomery, D. C. & Runger, G. C. (2018). Applied Statistics and Probability for Engineers (7th ed.). Wiley.