Linear Regression Analyzer

The Linear Regression Analyzer turns paired x and y data into the least-squares line of best fit, correlation r and R², with the scatter plot and trend line.

How to Find the Line of Best Fit

Enter matching lists of x and y values. The analyzer fits a straight line by least squares, reports how strong the relationship is, and plots the points with the trend line.

1

Find the means

Start with the average of the x values and the average of the y values. The least-squares line always passes through this center point.

2

Compute the slope and intercept

The slope is m = Σ(x − x̄)(y − ȳ) / Σ(x − x̄)², which is how much y changes on average for each one-unit step in x. The intercept is b = ȳ − m·x̄, giving the line y = mx + b with the smallest possible sum of squared vertical errors.

3

Judge the fit

The correlation r runs from −1 to 1: its sign gives the direction and its size gives the strength of the straight-line relationship. R² = r² is the share of the variation in y that the line explains, so R² = 0.81 means 81%.

Frequently Asked Questions

What does least squares mean?
It means the line is chosen to make the total of the squared vertical distances from each point to the line as small as possible. Squaring keeps positive and negative errors from cancelling out and penalizes big misses more.
What is a good R² value?
It depends on the field. In controlled physics experiments R² above 0.95 is common, while in social or biological data 0.3 to 0.5 can already be a meaningful relationship. A low R² means the straight line explains little of the variation, not that the data is wrong.
What is the difference between r and R²?
r is the correlation coefficient and carries a sign, so it shows direction (positive or negative). R² is r squared, always between 0 and 1, and reads as the fraction of variation explained.
Does a strong correlation prove causation?
No. A strong r only says the points line up. Both variables could be driven by a third factor, or the link could be a coincidence in a small dataset. Use the fit to describe and predict, not to prove cause.