Linear Regression Calculator
Paste your X and Y values below to compute the least-squares regression line, slope, intercept, correlation coefficient, and R-squared.
What is linear regression?
Linear regression is a statistical method used to model the relationship between two numeric variables. You provide a set of paired points (x, y), and regression finds the line of best fit that minimizes total squared error. In plain language: it finds the straight line that best summarizes how Y changes as X changes.
The classic simple regression equation is: y = a + bx
- b = slope (how much Y changes for each 1-unit increase in X)
- a = intercept (predicted Y when X = 0)
Why use a linear regression calculator?
You can compute slope and intercept by hand, but once datasets get larger, manual calculation becomes slow and error-prone. A regression calculator gives instant, repeatable results and helps you focus on interpretation instead of arithmetic.
- Fast analysis of trends in business, science, and finance
- Clear model summary with equation, correlation, and R-squared
- Easy what-if prediction for new X values
How to use this calculator
1) Enter your data
Add one list of X values and one list of Y values. Keep them aligned by position. That means the first X matches the first Y, second X matches second Y, and so on.
2) Click “Calculate Regression”
The tool applies the least squares formula and reports:
- Regression line: y = a + bx
- Slope and intercept
- Correlation coefficient (r)
- Coefficient of determination (R²)
- Optional predicted Y value for your custom X
3) Interpret the output
A positive slope indicates an upward trend; a negative slope indicates a downward trend. R-squared tells you how much of Y’s variation is explained by X in your linear model.
Understanding the results
Slope (b)
If slope is 1.8, then Y increases by about 1.8 units for every 1-unit increase in X.
Intercept (a)
The intercept is the model’s Y value at X = 0. It may or may not be practically meaningful depending on your context.
Correlation coefficient (r)
The value of r ranges from -1 to +1:
- Near +1: strong positive linear relationship
- Near -1: strong negative linear relationship
- Near 0: weak linear relationship
R-squared (R²)
R² ranges from 0 to 1 and measures goodness of fit. For example, R² = 0.84 means 84% of variation in Y is explained by X with this straight-line model.
Practical example
Suppose you track weekly study hours (X) and exam scores (Y). If your regression line is: y = 52 + 4.5x, then each extra hour of weekly study is associated with a 4.5-point increase in predicted score. If a student studies 6 hours, predicted score is: 52 + (4.5 × 6) = 79.
Common mistakes to avoid
- Using different list lengths for X and Y
- Mixing categories/text with numeric inputs
- Assuming correlation proves causation
- Using linear regression for clearly nonlinear patterns
- Predicting far beyond your observed X range (extrapolation risk)
When linear regression is a good fit
Use this approach when:
- You have paired numerical data
- A scatterplot looks roughly linear
- You want an interpretable model with slope and intercept
- You need a quick baseline before trying advanced machine learning models
Final thoughts
A linear regression calculator is one of the most useful tools in introductory statistics and data analysis. It helps you summarize trends, quantify relationships, and make fast predictions. Use it as a decision-support tool, then combine the math with domain knowledge for better conclusions.