Simple Linear Regression & R² Line of Best Fit

Simple Linear Regression & R² Line of Best Fit

Fit a bivariate linear model, compute slope, intercept, Pearson correlation coefficient, and R² variance explained.

Regression Line Model Client-Side Execution
Line Equation (y = mx + b)
y = 1.4500x + 0.9500

R² (Coefficient of Determination): 99.64%

Correlation (r)0.9982
Predicted Y at X=69.6500

At a Glance

Category
Statistics
Best For
Students and analysts modeling a straight-line relationship and making predictions
Privacy
100% in your browser: nothing you enter is uploaded
Time Required
Under a minute
Cost
Free
Updated
November 2026

Quick Overview

What This Tool Does

Finds the straight line that minimizes the squared vertical distances to your points and uses it to predict y.

Who Should Use It

Students, scientists, analysts and forecasters.

When to Use It

When you want a trend line and a prediction from observed data.

Why It Is Useful

It quantifies a trend and shows how well a straight line fits.

Key Features & Capabilities

Regression line

Slope and intercept from least squares.

Goodness of fit

r and R² show how well the line fits.

Prediction

Estimate y at any x.

How to Use This Tool

1

Enter your points

Put one x, y pair on each line. Tip: At least two distinct x values are needed.

2

Read the equation

The slope and intercept define y = mx + b. Tip: The slope is the change in y per unit of x.

3

Check the fit

R² near 1 means the line fits well. Tip: Plot the points to check for curvature.

4

Predict

Enter an x value to see the predicted y. Tip: Avoid predicting far outside your data range.

Worked Real-World Example

Five data points

Data: (1, 2.5), (2, 3.8), (3, 5.1), (4, 6.9), (5, 8.2). Predict y at x = 6.

Sample Inputs
Coordinate points1, 2.5; 2, 3.8; 3, 5.1; 4, 6.9; 5, 8.2
Predict at x6
Regression liney = 1.45x + 0.95; r = 0.9982; R² = 0.9964; ŷ(6) = 9.65
Calculation Breakdown
Sums: Σx, Σy, Σxy, Σx² = 15; 26.5; 94.0; 55
Slope: (5 × 94.0 − 15 × 26.5) ÷ (5 × 55 − 15²) = 1.45
Intercept: (26.5 − 1.45 × 15) ÷ 5 = 0.95
Prediction at x = 6: 1.45 × 6 + 0.95 = 9.65
Each extra unit of x adds about 1.45 to y, and the line explains 99.6% of the variation. The prediction at x = 6 is just outside the data (extrapolation), so treat it with caution.

How It Works (Math & Calculation Logic)

With n points: slope = (nΣxy − ΣxΣy) ÷ (nΣx² − (Σx)²), intercept = (Σy − slope × Σx) ÷ n, r = (nΣxy − ΣxΣy) ÷ √((nΣx² − (Σx)²)(nΣy² − (Σy)²)), R² = r². Predicted y = slope × x + intercept.

Formula / Algorithmŷ = mx + b m = (nΣxy − ΣxΣy) ÷ (nΣx² − (Σx)²)
Variable & Logic Definitions
mSlope - Change in y per unit x
bIntercept - Value of y at x = 0
nPoints - Number of data points (count)

How to Interpret Your Results

Typical Benchmarks

R² ranges from 0 to 1. Higher means a closer fit.

Evaluating Your Output

A high R² does not prove causation or that a line is the right model.

Recommended Next Action

Plot residuals and keep predictions within the range of observed x.

Frequently Asked Questions

What is a line of best fit?
The line that minimizes the sum of squared vertical distances from the points.
What does R² mean?
The share of variation in y explained by x.
How many points do I need?
At least two, but more give a more reliable line.
Can I predict outside my data?
You can, but extrapolation is less reliable.
What is the difference between r and R²?
R² is r squared; r also gives direction.

Complementary QuickForma Utilities

Mathematics & Statistics

Descriptive Statistics Calculator

Calculate mean, median, mode, range, variance, standard deviation, quartiles, IQR, and MAD from data.

Open Tool
Mathematics & Statistics

Hypothesis Test Calculator

Calculate test statistic Z = (xbar - mu) / (s / sqrt(n)), two-tailed p-value, and significance decision.

Open Tool
Mathematics & Statistics

Sample & Population Standard Deviation Solver

Solves sample (s) and population (σ) standard deviation with variance steps.

Open Tool
Mathematics & Statistics

Margin of Error & Survey Sample Size Solver

Calculates minimum required survey sample size based on confidence level (95%, 99%) and margin of error.

Open Tool
Mathematics & Statistics

Altman Z-Score Business Bankruptcy Predictor

Uses 5 financial ratios to predict public and private business insolvency risk.

Open Tool
Mathematics & Statistics

Raw Quiz / Exam Test Score Percentage Solver

Converts raw exam points (e.g. 47 out of 58) into percentage, letter grade, and grade points.

Open Tool
Mathematics & Statistics

Definite & Indefinite Integration Solver

Calculates polynomial, exponential, and trigonometric definite/indefinite integrals with step-by-step logic.

Open Tool
Mathematics & Statistics

Matrix Addition, Multiplication & Determinant Solver

Performs $2\times 2$ and $3\times 3$ matrix operations, determinant calculation, and matrix inversion.

Open Tool
Mathematics & Statistics

Line Slope, Y-Intercept & Equation Solver

Solves line slope m = (y₂-y₁)/(x₂-x₁), point-slope form, and slope-intercept equation y=mx+b.

Open Tool
Mathematics & Statistics

Pearson r & Spearman Rank Correlation

Computes Pearson product-moment correlation coefficient r and Spearman rank correlation.

Open Tool