Linear Regression Calculator
Example 1
Solution
Answer
Source: StatQuest: Linear Regression
Example 2
Solution
Answer
Source: StatQuest: R-squared
Example 3
Solution
Answer
Example 4
Solution
Answer
References
- [1]Wiley, Applied Regression Analysis, 3rd ed., 1998.
- [2]NIST, NIST/SEMATECH e-Handbook of Statistical Methods. https://www.itl.nist.gov/div898/handbook
- [3]PennState Eberly College of Science, STAT 501: Regression Methods. https://online.stat.psu.edu/stat501
- [4]IUPAC, Harmonized Guidelines for Single-Laboratory Validation of Methods of Analysis, 2002.
Glossary
- Linear regression – A statistical method that models the relationship between an independent variable X and a dependent variable Y by fitting a straight line through observed data points using the least squares criterion.
- Dependent variable – The outcome variable whose variation is being explained or predicted, denoted as Y in the regression equation y = mx + b. It is also called the response variable.
- Independent variable – The predictor variable used to explain or predict changes in the dependent variable, denoted as X in the regression equation y = mx + b. It is also called the explanatory variable.
- Slope – The coefficient m in the regression equation y = mx + b, representing the change in Y for each one-unit increase in X. A positive slope indicates a direct relationship; a negative slope indicates an inverse relationship.
- Intercept – The constant b in the regression equation y = mx + b, representing the predicted value of Y when X equals zero. It is also called the y-intercept.
- Correlation coefficient (r) – A measure of the strength and direction of a linear relationship between two variables, ranging from −1 to +1. Values near ±1 indicate a strong linear relationship; values near 0 indicate a weak or no linear relationship.
- Coefficient of determination (R²) – The proportion of variance in the dependent variable that is predictable from the independent variable, ranging from 0 to 1. An R² of 0.85 means 85% of the variability in Y is explained by X.
- Residual – The vertical distance between an observed data point and the value predicted by the regression line at the same X coordinate. A positive residual means the point lies above the line; a negative residual means it lies below.
- Least squares method – The optimization technique used to fit a regression line by minimizing the sum of squared vertical distances (residuals) between observed data points and the line. This produces the best-fitting linear model for the data.
- Line of best fit – The straight line that best represents the relationship between two variables in a scatter plot, determined by the least squares method. It is also called the regression line and is expressed as y = mx + b.
How to Use?
- 1
Locate your data
Collect paired X and Y observations. Each X value must have a corresponding Y value.
- 2
Enter data pairs
Set the number of data points, then enter each paired X and Y value in the table rows — for example: (1, 2.1), (2, 3.9), (3, 6.2), (4, 7.8), (5, 10.1).
- 3
Predict a value (optional)
Enter an X value in the Predict Y field to compute the predicted Y from the regression line. Leave it blank to skip.
- 4
Review the results
The calculator displays the regression equation, slope, intercept, Pearson r, R², and the number of points. If you entered a prediction X, the predicted Y appears as a primary result.
- 5
Inspect the graph
A scatter plot shows your raw data points with the fitted regression line overlaid. Use it to visually assess model fit.