How to Use the Linear Regression Calculator
This calculator helps you perform a simple linear regression with one numerical response variable and one numerical predictor.
To use the calculator:
- Enter the response variable in the Y column.
- Enter the predictor variable in the X column.
- Edit the variable names if necessary.
- Select the number of decimal places you want to display.
- Click Calculate.
The calculator returns the regression equation, Model Summary, ANOVA table, regression coefficients, p-values, 95% confidence intervals, and an optional prediction.
Tip. When entering the data, you can enter the values manually, paste two columns directly from Excel or Google Sheets, or upload a CSV, Excel, or TXT file. The calculator also allows you to upload a file with more than two variables and allows you to select the columns you want to use as Y and X. Additionally, this calculator automatically excludes rows containing missing values from the analysis.
If your main goal is simply to calculate the slope, intercept, line equation, and graph the fitted line, use the line of best fit calculator to get instant results, with a clear, step-by-step solution explaining how the line of best fit (regression equation) was computed. However, if the response variable is categorical and binary, you should use the binary logistic regression calculator.
What Is Simple Linear Regression?
Simple linear regression is a statistical method used to model the linear relationship between one numerical predictor variable and one numerical response variable.
For example, a researcher may want to determine whether the number of hours an employee spends in training can be used to predict their performance score.
In this case:
- Training Hours is the predictor variable, X.
- Performance Score is the response variable, Y.
Simple linear regression estimates a straight-line relationship between the two variables and allows us to determine whether X significantly predicts Y. The method is called simple linear regression because the model contains only one predictor.
Need to perform a linear regression with two or more predictors? Use the multiple linear regression calculator instead.
Simple Linear Regression Equation
The estimated simple linear regression equation is: ŷ = b₀ + b₁x
Where:
- ŷ is the predicted value of Y.
- b₀ is the intercept.
- b₁ is the regression coefficient or slope.
- x is the value of the predictor variable.
For example, suppose the regression equation is: ŷ = 28.5 + 2.7x. In this case, the slope is b₁ = 2.7. This means that every one-unit increase in X is associated with an estimated increase of 2.7 units in Y. The intercept is b₀ = 28.5, which indicates that the predicted value of Y when X = 0 is 28.5.
Note. In linear regression, the practical interpretation of the y-intercept depends entirely on whether an independent variable value of X = 0 makes logical sense and falls within the scope of your actual data.
Understanding the Simple Linear Regression Outputs
After you click Calculate, the calculator first displays the regression equation and a summary of the main results. It then organizes the detailed regression output into three tables:
- Model Summary
- ANOVA
- Coefficients
Each table provides different information about the regression model. The sections below explain the statistics reported in each table and how to interpret them.
1) Model Summary
The Model Summary provides an overview of how well the regression model fits the data. It reports:
- R: Measures the relationship between the observed Y values and the values predicted by the regression model. In linear regression, R is reported as the positive square root of R². Therefore, use the sign of the slope or standardized coefficient (β) to determine whether the relationship between X and Y is positive or negative.
- R²: Shows the proportion of variation in Y accounted for by the linear regression model. For example, R² = 0.64 means that the model accounts for approximately 64% of the variation in Y.
- Adjusted R²: Adjusts R² for the sample size and number of predictors. In a linear regression with one predictor, adjusted R² is usually close to R².
- SE: Gives the standard error of the estimate. It measures the typical size of the residuals, or the differences between the observed and predicted Y values. Smaller values indicate that the observations tend to fall closer to the fitted regression line.
- N: Shows the number of complete observations included in the analysis.
You can learn more about R² and how to calculate it using the R Square calculator.
2) ANOVA
The ANOVA table tests whether the regression model significantly predicts Y. It separates the variation in Y into the variation accounted for by the model and the variation that remains unexplained.
The table reports:
- Regression SS: The amount of variation in Y accounted for by X.
- Residual SS: The amount of variation in Y that the regression model does not account for.
- Total SS: The total variation in Y. It equals Regression SS + Residual SS.
- df: The degrees of freedom associated with each source of variation.
- MS: The mean square, calculated by dividing each sum of squares by its corresponding degrees of freedom.
- F: The F statistic used to test the overall regression model.
- p: The p-value associated with the F statistic.
For a linear regression with one predictor, the hypotheses for the overall model are:
- H₀: β₁ = 0 ( X does not linearly predict Y in the population).
- H₁: β₁ ≠ 0 ( X linearly predict Y in the population).
Therefore, if p < .05, you would normally reject the null hypothesis and conclude that the regression model is statistically significant. In other words, there is sufficient evidence that X significantly predicts Y.
For example, F(1, 18) = 12.46, p = .002 shows that the regression model is statistically significant.
3) Coefficients
The Coefficients table shows the estimated intercept and the regression coefficient for X. More importantly, it allows you to determine the direction, size, and statistical significance of the relationship between X and Y.
The table reports:
- B: The unstandardized regression coefficient. For X, B represents the expected change in Y for a one-unit increase in X. On the other hand, the intercept B gives the predicted value of Y when X = 0.
- SE: The standard error of B. It indicates the uncertainty associated with the estimated coefficient.
- β: The standardized regression coefficient. It expresses the relationship in standard deviation units. In a linear regression with one predictor (simple linear regression), β equals Pearson’s correlation coefficient, r.
- t: The t statistic used to test whether the regression coefficient differs significantly from zero.
- p: The p-value for the coefficient test. If p < .05, the predictor is considered statistically significant at the 5% significance level.
- 95% CI for B: Gives the 95% confidence interval for the unstandardized coefficient. If the interval for the predictor does not contain zero, the coefficient will normally be statistically significant at α = .05.
For example, suppose Training Hours has B = 2.81, SE = 0.29, t = 9.79, p < .001. This means that each additional hour of training is associated with an estimated increase of 2.81 units in Y. Since p < .001, Training Hours is also a statistically significant predictor of Y.
Tip. The regression equation uses the B coefficients, not the standardized β coefficients. Therefore, for a model with one predictor, the general form of the regression equation is: Predicted Y = Intercept B + Predictor B(X)
Example: Linear Regression
A company wants to determine whether weekly advertising expenditure can be used to predict weekly sales.
The following data were collected for eight weeks.
| Advertising Expenditure (X) | Weekly Sales (Y) |
|---|---|
| 5 | 42 |
| 7 | 46 |
| 8 | 54 |
| 10 | 53 |
| 12 | 65 |
| 13 | 61 |
| 15 | 74 |
| 18 | 77 |
Perform a linear regression to determine whether advertising expenditure significantly predicts weekly sales.
Solution
To perform the analysis using the calculator:
- Enter the Weekly Sales values in the Y column.
- Enter the Advertising Expenditure values in the X column.
- Rename Y to Weekly Sales.
- Rename X to Advertising Expenditure.
- Click Calculate.
The calculator gives the regression equation as: Predicted Weekly Sales = 28.0833 + 2.8106(Advertising Expenditure). It also displays the following tables.
Model Summary Table
| Model | R | R² | Adjusted R² | SE | N |
|---|---|---|---|---|---|
| 1 | 0.9701 | 0.9411 | 0.9313 | 3.2981 | 8 |
From the table, the model gives R² = 0.9411. Therefore, approximately 94.11% of the variation in Weekly Sales is accounted for by its linear relationship with Advertising Expenditure. After adjusting for the sample size, Adjusted R² = 0.9313. The standard error of the estimate is 3.2981.
ANOVA Table
| Source | SS | df | MS | F | p |
|---|---|---|---|---|---|
| Regression | 1042.7348 | 1 | 1042.7348 | 95.8614 | < .001 |
| Residual | 65.2652 | 6 | 10.8775 | ||
| Total | 1108.0000 | 7 |
The ANOVA table shows that the regression model is statistically significant, F(1, 6) = 95.8614, p < .001. Therefore, there is sufficient evidence that Advertising Expenditure significantly predicts Weekly Sales.
Coefficients Table
| Term | B | SE | β | t | p | 95% CI for B |
|---|---|---|---|---|---|---|
| Intercept | 28.0833 | 3.3661 | — | 8.3429 | < .001 | [19.8467, 36.3199] |
| Advertising Expenditure | 2.8106 | 0.2871 | 0.9701 | 9.7909 | < .001 | [2.1082, 3.5130] |
The regression coefficient for Advertising Expenditure is B = 2.8106. Therefore, for every one-unit increase in Advertising Expenditure, Weekly Sales are predicted to increase by approximately 2.81 units. Advertising Expenditure is also a statistically significant predictor of Weekly Sales, t(6) = 9.7909, p < .001.
Moreover, the 95% confidence interval for the coefficient is [2.1082, 3.5130]. Since this interval does not contain zero, it supports the conclusion that Advertising Expenditure has a significant positive relationship with Weekly Sales. Therefore, Advertising Expenditure is a statistically significant positive predictor of Weekly Sales.
How to Report Linear Regression Results in APA Style
When reporting a linear regression in APA style, include the overall model test, R², and the regression coefficient for the predictor. You can also report the standard error, standardized coefficient, and 95% confidence interval where appropriate.
Using the example above, you could report the results as follows:
A linear regression was conducted to determine whether Advertising Expenditure predicted Weekly Sales. The regression model was statistically significant, F(1, 6) = 95.86, p < .001, R² = .941. Advertising Expenditure was a significant positive predictor of Weekly Sales, B = 2.81, SE = 0.29, β = .970, t(6) = 9.79, p < .001, 95% CI [2.11, 3.51].
Making a Prediction From the Regression Model
Once the regression equation has been calculated, you can use it to predict Y for a given value of X.
Using the previous example regression equation: Predicted Weekly Sales = 28.0833 + 2.8106(Advertising Expenditure), we can predict the weekly sales of an advertising expenditure of 11 units as follows:
Since X = 11 units, we substitute the value in the fitted regression equation and solve for the predicted weekly sales.
Hence, Predicted Weekly Sales = 28.0833 + 2.8106(11)
= 59.0000
You can make this calculation directly using the Predict Y option in the calculator.
Remember predictions are generally more reliable when the X value is within or close to the range of the data used to fit the regression model. Using the regression equation far outside the observed range is called extrapolation and should be interpreted cautiously.
Simple Linear Regression vs Line of Best Fit
A least-squares regression line and a line of best fit use the same underlying fitted straight line. However, the two calculators on StatCalc serve different purposes. The table below provides a summary of the differences in the two calculators.
| Line of Best Fit Calculator | Linear Regression Calculator |
|---|---|
| Focuses on finding the fitted line | Focuses on statistical analysis |
| Shows slope and intercept calculations | Reports coefficient tests |
| Includes a scatter plot | Reports ANOVA |
| Shows calculations step by step | Reports standard errors |
| Useful for learning the least-squares method | Useful for analyzing research data |
| Returns r and R² | Returns R² and adjusted R² |
| Focuses on the equation | Includes p-values and confidence intervals |
Use the line of best fit calculator when you want to see how the fitted line is calculated from the data. However, if you need to determine whether the relationship is statistically significant and interpret the full regression output, use the linear regression calculator instead.
Simple vs Multiple Linear Regression
The main difference between simple and multiple linear regression is the number of predictors. The table below provides a quick summary ofthe differences.
| Simple Linear Regression | Multiple Linear Regression |
|---|---|
| One response variable | One response variable |
| One predictor | Two or more predictors |
| ŷ = b₀ + b₁x | ŷ = b₀ + b₁x₁ + b₂x₂ + … |
| No multicollinearity between predictors | Multicollinearity may need to be assessed |
| One slope coefficient | Several regression coefficients |
If you want to predict Y using two or more predictors, use the multiple linear regression calculator.
Assumptions of Simple Linear Regression
Before interpreting the p-values and confidence intervals, check whether the main assumptions of simple linear regression are reasonably satisfied.
- Linearity. The relationship between X and Y should be approximately linear. A scatter plot is useful for identifying strong curves or other nonlinear patterns.
- Independence. The observations should be independent of one another. For example, one participant’s value should not improperly determine another participant’s value.
- Homoscedasticity. The spread of the residuals should remain reasonably constant across the fitted values. A strong funnel-shaped residual pattern may indicate unequal variance.
- Normality of Residuals. The residuals should be approximately normally distributed when using the usual t and F tests, particularly in small samples. The X and Y variables themselves do not have to be normally distributed.
- No Highly Influential Outliers. Unusual observations can have a large effect on the slope, intercept, and statistical tests. As such, you should always consider the data and study context before drawing conclusions from the fitted model.
Linear Regression vs Correlation
Linear regression and correlation both examine linear relationships, but they answer different questions. The table below shows the key differences between a simple linear regression and Pearson correlation.
| Linear Regression | Correlation |
|---|---|
| Predicts Y from X | Measures association between X and Y |
| Distinguishes between predictor and response | Treats the two variables symmetrically |
| Produces a regression equation | Produces Pearson’s r |
| Estimates slope and intercept | Does not estimate a prediction equation |
| Can test whether X significantly predicts Y | Tests whether the linear association differs from zero |
If you only need to measure the strength and direction of the linear relationship between two numerical variables, use the correlation coefficient calculator.
Frequently Asked Questions
A linear regression calculator is an online tool that performs a simple linear regression using one numerical predictor and one numerical response variable. This calculator returns the regression equation, R², adjusted R², ANOVA, regression coefficients, standard errors, p-values, and confidence intervals. It also allows you to do predictions.
It is a statistical model that models the linear relationship between one predictor variable, X, and one response variable, Y. It estimates an intercept and slope that can be used to predict Y from X.
B is the unstandardized coefficient and is expressed in the original units of X and Y. However, β is the standardized coefficient and expresses the relationship in standard deviation units. In simple linear regression, β equals Pearson’s r.
In simple linear regression with one predictor, the overall F-test and the t-test for the slope test the same null hypothesis. Therefore, F = t² and both tests produce the same p-value.
Yes. You can upload CSV, Excel, or TXT data. If the file contains more than two columns, choose which variable should be used as Y and which should be used as X.
No. A statistically significant regression shows evidence of a relationship between X and Y. It does not by itself prove that changes in X cause changes in Y. Causal conclusions depend on the study design and other evidence.
