Sample size

Sample size calculator for a one-variance test

Calculate the sample size needed to test \(H_0: \sigma = \sigma_0\) with a target power using the exact chi-square distribution.

This tool calculates the sample size needed to test whether the variance (or standard deviation) differs from a reference value (\(H_0: \sigma = \sigma_0\)) at a target power, using the exact chi-square distribution.

Calculator

Enter the ratio R = σ₁/σ₀, the significance level, the desired power and the type of alternative to get the minimum sample size.

Result pending…

Explanation

The chi-square variance test checks \(H_0: \sigma^2 = \sigma_0^2\) using the statistic \(T = (n-1)S^2/\sigma_0^2\), which under \(H_0\) follows a \(\chi^2_{n-1}\) distribution.

Under the alternative \(\sigma_1 = R\cdot\sigma_0\), the statistic \(T\) follows an \(R^2 \cdot \chi^2_{n-1}\) distribution, equivalently \(T/R^2 \sim \chi^2_{n-1}\). Exact power is evaluated using the central chi-square CDF, without normal approximations.

Exact power formula

For the two-sided alternative (\(H_a: \sigma \neq \sigma_0\)):

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

For the upper one-sided alternative (\(H_a: \sigma \geq \sigma_0\)):

\( \text{Power} = 1 - F_{\chi^2_{n-1}}\!\left(\frac{\chi^2_{1-\alpha,\,n-1}}{R^2}\right) \)

For the lower one-sided alternative (\(H_a: \sigma \leq \sigma_0\)):

\( \text{Power} = F_{\chi^2_{n-1}}\!\left(\frac{\chi^2_{\alpha,\,n-1}}{R^2}\right) \)

The calculator finds the smallest \(n\) such that the exact power reaches the target value.

Quick setup

  • R: specify the ratio σ₁/σ₀ you want to detect. R=1.5 (a 50% increase) is a moderate effect size. R=2 (quadruple variance) is detected with smaller samples.
  • α: 0.05 is the standard; 0.01 for decisions with critical consequences.
  • Power: 0.80 is the usual minimum; 0.90 if false negatives are costly.
  • Alternative: two-sided if you have no prior direction; upper one-sided to detect increases in variability (quality control).
  • Normality: this test is very sensitive to deviations from normality; check the assumption before applying it.

Worked example

A semiconductor manufacturer wants to detect an increase of at least 50% in the standard deviation of chip diameter (R = σ₁/σ₀ = 1.5). The nominal process has \(\sigma_0 = 2\) μm. A two-sided test is wanted with \(\alpha = 0.05\) and 80% power.

The calculator finds the smallest \(n\) such that the exact power is ≥ 0.80 with R = 1.5, and returns approximately n = 54 observations. With that sample, if the true variance is \((1.5 \times 2)^2 = 9\) μm² (instead of the nominal 4 μm²), the test will detect the change 80% of the time.

Sensitivity analysis: with R = 2 (quadruple variance), the sample shrinks to n ≈ 18. To detect R = 1.25 (a 25% increase) with the same power requires n ≈ 184. Variance tests need considerably larger samples than mean tests for the same relative effect size.

Model assumptions

  • Simple random sampling with independent observations.
  • The variable follows a normal distribution: the \(\chi^2\) test on the variance is very sensitive to deviations from normality.
  • \(\sigma_0\) is the reference value of the standard deviation under \(H_0\).
  • The calculation uses the exact chi-square distribution with \(n-1\) degrees of freedom.

How to interpret the result

The value \(n\) obtained is the minimum number of observations needed for the hypothesis test on the variance to reach the specified power. With that sample size, if the true deviation of the variance from \(\sigma_0^2\) is at least the one indicated by the ratio \(R = \sigma_1/\sigma_0\), the test will detect it with the desired probability. Always round up. If you expect losses of observations, divide \(n\) by \((1 - \text{dropout rate})\) to get the recruitment size needed.

The power of the variance test depends on the relative deviation \(R\) in a nonlinear way: detecting small variations (for example \(R = 1.2\)) requires very large samples, while large variations (\(R = 2\) or more) are detected with few observations. Run a sensitivity analysis varying \(R\) by ±0.1 or ±0.2 to assess the robustness of the sample size to uncertainty about the true magnitude of the effect.

A critical assumption is normality of the data: the chi-square statistic for the variance is notably more sensitive to deviations from normality than the \(t\) statistic for the mean. If the data are skewed or heavy-tailed, the nominal \(\alpha\) level may not hold. Before using this result, check normality with the sample size calculator for Shapiro-Wilk or draw a Q-Q plot. Once the data are collected, run the test with the hypothesis test calculator for variances.

References

  • Zar, J. H. (2010). Biostatistical Analysis (5th ed.). Pearson.
  • Montgomery, D. C. (2019). Introduction to Statistical Quality Control (8th ed.). Wiley.