Linear Regression

Statistics & Probability

This predictive regression analysis tool fits an optimal least-squares trendline to paired numerical datasets to model mathematical relationships between variables. It calculates the best-fit slope, vertical intercept, correlation coefficient r, and coefficient of determination R-squared to support empirical forecasting.

Calculated Result
y = 1.98x + 0.06

r = 0.9988 · R² = 0.9976 · n = 5

Slope m
1.98
Intercept b
0.06
Formula: m = Σ(x−x̄)(y−ȳ) / Σ(x−x̄)²

About this calculator

Modeling relationships between paired numerical variables allows forecasters and data scientists to predict dependent outcomes from known predictor values. Whether evaluating how study hours influence exam grades or how capital investment drives manufacturing production volume, fitting a trendline clarifies underlying linear trajectories. You provide corresponding numerical series for the independent X values and dependent Y values to calculate best-fit parameters.

The generated equation in slope-intercept format provides the gradient slope m, showing the rate of change in Y per unit increase in X, and the intercept b, representing the estimated baseline when X equals zero. Accompanying metrics include Pearson's r and the coefficient of determination R-squared, which reveals the exact proportion of variance accounted for by the model. Be cautious when extrapolating predictions far beyond the range of your observed data points, as unobserved nonlinearities or structural shifts can cause substantial forecasting error.

How It Works & Formula

Formulam = Σ(x−x̄)(y−ȳ) / Σ(x−x̄)² | y = mx + b

The slope m is determined by dividing the sum of cross-products of mean deviations by the sum of squared deviations of X. The vertical intercept b is derived by subtracting slope times mean X from mean Y, forming the complete least-squares trendline equation.