Linear Regression Calculator
Calculate the linear regression equation, slope, intercept, and R-squared for two sets of numbers. This helps estimate the best-fit line for paired X and Y values.
Enter the X values separated by commas.
Enter the Y values separated by commas in the same order.
How This Calculator Works
This calculator uses simple linear regression to find the best-fit line for paired X and Y values. It calculates the slope and intercept of the regression line, then uses those values to build the equation of the line.
It also calculates R-squared, which shows how much of the variation in Y is explained by the regression line. Values closer to 1 indicate a stronger fit.
Formula
Regression Line = y = mx + b
Slope (m) = Sum[(x - mean of x)(y - mean of y)] / Sum[(x - mean of x)^2]
Intercept (b) = Mean of y - m * Mean of x
Example
If X values are 1, 2, 3, 4, 5 and Y values are 2, 4, 5, 4, 6, this calculator finds the slope and intercept of the best-fit line and returns the regression equation that best describes the relationship.
Frequently Asked Questions
What is linear regression?
Linear regression is a statistical method used to model the relationship between two variables with a straight line.
What does the slope mean?
The slope shows how much Y is expected to change for each one-unit increase in X.
What does the intercept mean?
The intercept is the expected value of Y when X equals 0.
What is R-squared?
R-squared measures how well the regression line explains the variation in the Y values. A value closer to 1 means a better fit.
When can linear regression not be calculated?
Linear regression cannot be calculated if all X values are the same, because there is no variation in X to estimate a line.