Linear regression calculator

Fit a least-squares line to paired data and get the equation, significance of the slope, R², an ANOVA table, prediction intervals and a residual plot.

ŷ = 49.721 + 2.242x
TermEstimateSEtp
Intercept49.72111.696829.303< .001
Slope2.24210.169713.214< .001
R²
0.9562
Adjusted R²
0.9507
r
0.9778
Residual SE
2.3389
F(1, 8)
174.601
Slope 95% CI
1.851, 2.633
At x = 12: ŷ = 76.62695% CI for the mean: 74.556 to 78.69795% prediction interval: 70.849 to 82.404
Residuals vs X. Look for curves or a funnel shape.

b = 2.24, t(8) = 13.21, p < .001; R² = 0.96, F(1, 8) = 174.6

Write up this regression

An APA-style results paragraph built only from the coefficients and fit statistics above.

Uses an AI model via Vercel AI Gateway. It only sees what you send here; check anything you publish.

The formulas

b₁ = Σ(x − x̄)(y − ȳ) / Σ(x − x̄)² b₀ = ȳ − b₁x̄SE(b₁) = s / √Σ(x − x̄)², s = √(SSE / (n − 2))R² = 1 − SSE / SST

The slope's t statistic, b₁/SE(b₁), has n − 2 degrees of freedom. In simple regression F = t², and the p-value equals that of the Pearson correlation between X and Y (see the correlation calculator).

Confidence vs prediction intervals

The confidence interval says where the average Y lies for a given X. The prediction interval says where a single new observation will probably fall; it adds the residual variance, so it is always wider. Both are narrowest at x̄ and widen as you move away from it. Avoid predicting far outside the range of X you observed.

Sample size for regression

Testing a single slope is equivalent to testing a correlation, so the power analysis calculator (correlation mode) gives the n: about 85 participants to detect r = .30 (R² ≈ .09) with 80% power.

Frequently asked questions

How do I calculate a linear regression line?

The least-squares slope is b₁ = Σ(x − x̄)(y − ȳ) / Σ(x − x̄)² and the intercept is b₀ = ȳ − b₁x̄. Paste your X and Y values above and the calculator computes both, with standard errors and p-values.

What does R² tell me?

The proportion of variance in Y explained by the straight line. R² = 0.60 means the line accounts for 60% of the variation in Y; the rest is residual. Adjusted R² penalises for the number of predictors.

How do I interpret the slope?

The expected change in Y for a one-unit increase in X. Its p-value tests whether the true slope is zero; for simple regression it is identical to the p-value of the Pearson correlation.

What assumptions does linear regression make?

A linear relationship, independent observations, roughly constant spread of residuals across X (homoscedasticity), and approximately normal residuals for valid small-sample inference. The residual plot above helps check the first and third.

Can I predict Y for a new X?

Yes, type an X value into the prediction box. The calculator gives the predicted mean and a 95% prediction interval for an individual case, which is wider than the confidence interval for the mean.