Linear Regression & Trend Forecast

Linear regression quantifies how one variable moves with another. Fit the least-squares line, test whether the relationship is statistically significant, and forecast new values with confidence and prediction intervals.

How it works

Fit an ordinary least squares line to paired data, test the significance of the relationship, and forecast new values with confidence and prediction intervals.

Slope b₁ = Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)²;   Intercept b₀ = ȳ − b₁x̄
R² = 1 − SSE ÷ SST;   s = √(SSE ÷ (n − 2))
t = b₁ ÷ SE(b₁),  SE(b₁) = s ÷ √Σ(x − x̄)²
Prediction interval = ŷ ± t·s·√(1 + 1/n + (x₀ − x̄)² ÷ Σ(x − x̄)²)

Common uses

  • Cost behavior analysis and cost-driver identification
  • Trend forecasting of revenue, volume or expenses
  • Statistics coursework and research

Worked example

The calculator above opens with this example. Change any input to see the results update instantly, or select Reset to return to these figures.

X values (leave blank for 1, 2, 3 …)12 15 18 20 22 25 27 30 32 35 38 40
Y values210 228 251 262 270 296 301 322 330 352 367 380
X values to forecast (optional)42 45 50
Confidence level95%
Example inputs
Regression equationŷ = 139.9506 + 6.0178·x
R²0.9978
Correlation (r)0.9989
Slope p-value< 0.0001
Standard error of estimate2.69
F statistic4,525.80
Results

Each one-unit increase in X is associated with a 6.0178 change in Y. Prediction intervals cover a single new observation; confidence intervals cover the average Y at that X.

Interpreting the results

  • A small p-value (below 0.05 at 95% confidence) indicates the slope is statistically different from zero.
  • R² measures fit, not causation; check residuals for curves or outliers before trusting forecasts.
  • Forecasting far outside the range of observed X values (extrapolation) widens real uncertainty beyond the computed interval.

Frequently asked questions

What does R-squared tell me?

R-squared is the share of the variation in Y explained by X. A value of 0.85 means the line explains 85% of the variation. A high R-squared shows a good fit but does not prove that X causes Y.

What is the difference between a confidence interval and a prediction interval?

A confidence interval estimates the range for the average Y at a given X. A prediction interval covers a single new observation, so it is always wider because it includes the scatter of individual points around the line.

When is the slope statistically significant?

The slope is significant when its p-value is below the chosen significance level, typically 0.05 for 95% confidence. That indicates the relationship is unlikely to be the result of random variation alone.

Browse all 13 Statistics & Forecasting calculators