Linear Regression Calculator
Fit a linear trend line (line of best fit) through bivariate paired data (X, Y) using the ordinary least squares (OLS) method. Computes the slope (m), intercept (b), Pearson correlation (r), and coefficient of determination (R²).
Predictor values X separated by commas or spaces
Response values Y matching each corresponding X in sequence
Best fit line characterizing relationship
How to Use This Calculator
- Enter independent X values separated by commas.
- Enter matching dependent Y values in the same sequential order.
- Inspect the line of best fit equation (y = mx + b) and R² goodness-of-fit.
Formula & Calculation Methodology
Ordinary least squares minimizes the sum of squared vertical residuals (distances from observed points to the regression line). R² represents the square of Pearson’s r.
Worked Example
Fitting pairs (1,2), (2,4), (3,5), (4,4), (5,5)
Perfect correlation (1, 10), (2, 20), (3, 30)
Frequently Asked Questions
What does R² (R-squared) indicate?↓
R² ranges between 0.0 and 1.0. An R² of 0.85 means 85% of the variance in the dependent variable Y is explained by the linear relationship with X.
Does linear regression prove causation?↓
No. Correlation does not imply causation. Two variables may be strongly correlated due to a third confounding variable or coincidence.
What occurs if X and Y lists have different lengths?↓
The calculator truncates to the shorter length so that each point has a complete (X, Y) pair.
What is a limitation of simple linear regression?↓
It only detects straight-line relationships. If data follows a curve (such as an exponential or U-shaped parabola), linear regression will underestimate fit.
Related Calculators
Source Citation & Disclaimer
Informational tool only; not licensed tax, legal, or financial advice.