Correlation and Regression
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.
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.
For a planned alternative slope B₁, This calculator uses the conditional fixed-X approach. The noncentrality parameter is
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.
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.
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.
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.
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.
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.
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).