Statistical Calculators › Correlation and Regression › Simple Linear Regression Sample Size (Slope Test)
← All Calculators

Correlation and Regression

Simple Linear Regression Sample Size (Slope Test)

Calculates the minimum sample size needed to test whether the slope in a simple linear regression differs from zero, using the conditional fixed-X noncentral-t approach documented in the statistical literature. Runs entirely in your browser.

Study Design

Specify the slope you want to detect, the variability of X and the residual variability of Y.
Model: Y = β₀ + β₁X + ε, with normally distributed residuals. The null hypothesis is β₁ = 0. The calculation treats the planned distribution of X as fixed and uses its standard deviation σX.

Required Sample Size

The smallest integer N whose calculated power reaches the requested target.
Enter the study assumptions and click Calculate Sample Size.

Methodology

Simple linear regression models the relationship between a continuous response Y and an independent variable X as Y = β₀ + β₁X + ε. The slope is estimated by least squares, and a t statistic with N − 2 degrees of freedom is used to test the null hypothesis that the slope is zero.

Test statistic and noncentrality

For a planned alternative slope B₁, This calculator uses the conditional fixed-X approach. The noncentrality parameter is

λ = √N × (B₁ − B₀) × σX / σe    with    B₀ = 0

Here σX is the standard deviation of the planned X values and σe is the residual standard deviation. Larger slope effects, greater variability in X, and smaller residual variability increase the noncentrality and therefore increase power.

Power calculation

For a two-sided test, the critical value is t1−α/2,N−2, and power is the probability that a noncentral-t random variable with N − 2 degrees of freedom and noncentrality λ falls outside the two critical boundaries. For a one-sided test, the corresponding one-tail critical value is used.

Two-sided power = P(T > tcrit) + P(T < −tcrit) under the noncentral-t distribution.

The calculator searches over integer sample sizes and returns the first N for which the calculated power is at least the requested target. Thus, the displayed N is not a continuous approximation that is merely rounded at the end.

Fixed-X versus random-X interpretation

This implementation follows the conditional approach used by this method: the calculation is conditional on the planned X values, summarized by σX. This is different from an unconditional correlation-based calculation in which X itself is modeled as a random variable.

Worked validation example

this method provides a published validation example from Neter, Wasserman, and Kutner (1983): N = 10, B₁ = 0.25, α = 0.05, σX = √(3400/10) = 18.439, and σe = √10 = 3.16228 for a two-sided test. This yields power = 0.9797.

Validation inputs: Power target = 0.9797 · α = 0.05 · Two-sided · B₁ = 0.25 · σX = 18.439 · σe = 3.16228

Expected result: N = 10
Independent implementation check: calculated power at N = 10 ≈ 0.9797; N = 9 gives ≈ 0.9610, so N = 10 is the first integer meeting the 0.9797 target.

Important planning note

The choice of σX is consequential. Note that the specific X values are often unknown during planning, so σX should be estimated carefully from prior data, the study design, or the planned range and allocation of X values. If the actual X variability is smaller than assumed, achieved power can be lower than planned.

References

Dupont, W. D. & Plummer, W. D. Jr. (1998). “Power and Sample Size Calculations for Studies Involving Linear Regression.” Controlled Clinical Trials, 19, 589–601.

For context on the distinction between conditional and unconditional approaches, see: Sample Size Calculations in Simple Linear Regression: A New Approach, Entropy, 25(4), 611 (2023).