Change language

Statistics

Simple and multiple linear regression calculator

Least-squares line or plane with coefficients, intervals, prediction, assumption checks and fit and residual plots, all in your browser.

Published by SolucionesAhora.com How we verify

Calculator inputs

  1. Enter your figures, or press “See example” to watch it work.
  2. If your case is unusual, open “Advanced options”.
  3. Read the result and, below it, what it means and how it was worked out.

One row per observation. The first column is the variable to explain (Y) and the next ones the explanatory variables (X): one is simple regression, several is multiple (up to 10). If the first line has names, they are used. Separate with spaces, commas or tabs and use a decimal point. You can also import an Excel or CSV file.

Y in the first column, then X

Enter one value for each explanatory variable, in the same order as the columns (for example “7” in simple regression or “6 12” with two variables). You get the predicted value with the confidence interval of the mean and the prediction interval.

Optional, one value per X variable

See the result

Results

Model equationventas = 0.1467 + 2.0343·publicidad
R² (coefficient of determination)0.9984
Adjusted R²0.9981
Model F2,568.973
Model p valuep < 0.001
Standard error of the estimate0.1679
Observations6
Predicted Y14.3867
95% CI of the mean: lower13.9527
95% CI of the mean: upper14.8206
Prediction interval: lower13.7498
Prediction interval: upper15.0236
Durbin-Watson3.328
Breusch-Pagan (constant variance)p = 0.393
Jarque-Bera (residual normality)p = 0.913
Maximum VIF (collinearity)1
Maximum Cook’s distance0.501
Model coefficients
VariableCoefficient bStd. errortp95% CI low95% CI highStd. betaVIF
Intercept0.14670.15630.9380.4012-0.28730.5806——
publicidad2.03430.040150.68501.92292.14570.999—
See the working step by step
  1. Observations = 6; explanatory variables = 1
  2. R² = 0.9984; adjusted R² = 0.9981; standard error of the estimate = 0.1679
  3. F(1, 4) = 2,568.973, p < 0.001
  4. Durbin-Watson = 3.328; Breusch-Pagan: p = 0.393; Jarque-Bera: p = 0.913
  5. Maximum VIF = 1; maximum Cook = 0.501 (row 5)

In short

What it calculates
Least-squares line or plane with coefficients, intervals, prediction, assumption checks and fit and residual plots, all in your browser.
Formula used
Model: Y = b0 + b1·X1 + b2·X2 + … + e
Example
Example 1. House price from size and rooms: two variables.

Linear regression calculator

Linear regression finds the line (or the plane, with several variables) that best summarises how one variable changes with others, and lets you predict new values. But a high R² is not enough: you also need to check the model meets its assumptions.

Paste your data with Y in the first column and the X variables after it. The calculator fits the model, gives the coefficient table with confidence intervals, adjusted R², the prediction with its interval and checks the assumptions with tests and two plots. Everything runs in your browser.

How it works

Least squares picks the coefficients that minimise the sum of squared residuals, that is, the distances between what was observed and what the model predicts. With one X variable the result is a line; with several, a plane in more dimensions.

Then the model is tested as a whole (the F), each coefficient on its own (the t), and the assumptions are checked: independence of residuals (Durbin-Watson), constant variance (Breusch-Pagan), normal residuals (Jarque-Bera), no collinearity among the X (VIF) and no overly influential observations (Cook’s distance).

Formula

Model: Y = b0 + b1·X1 + b2·X2 + … + e
Coefficients: b = (X'X)⁻¹ X'Y (with centred data for stability)
R² = 1 − SSR ÷ SST; adjusted R² = 1 − (1 − R²)(n − 1) ÷ (n − p − 1)
F = (SSReg ÷ p) ÷ (SSR ÷ (n − p − 1)); t_j = b_j ÷ SE(b_j)
Prediction interval: ŷ ± t × √(MSE (1 + 1/n + (x0 − x̄)'S⁻¹(x0 − x̄)))
VIF_j = 1 ÷ (1 − R²_j) with R²_j from regressing X_j on the other X
Durbin-Watson = Σ(e_t − e_(t−1))² ÷ Σ e_t²
Jarque-Bera = n ÷ 6 × (skewness² + (kurtosis − 3)² ÷ 4)
Breusch-Pagan: n × R² of regressing e² on the X
Cook_i = e_i² ÷ ((p + 1) MSE) × h_i ÷ (1 − h_i)²

Worked example

Example 1. House price from size and rooms: two variables.
Eight homes. price = 30.58 + 2.046 × size + 8.154 × rooms (thousands), R² = 0.998. Size is significant (p < .001); rooms is not (p = .069) once size is included, because the two move together.
For a 95 m² home with 3 rooms the model predicts 249.4 thousand. The mean would be between 242.9 and 256.0 (95% CI), and an individual home between 239.7 and 259.1 (prediction interval).

Example 2. One influential point.
Ten points, nine of which lie on a clear upward line and one far away (X = 20, Y = 5). The fitted slope is only 0.198 with R² = 0.039, and Cook’s distance reaches 15.4 for row 10: a single observation is driving the whole result.

Explanation

Simple and multiple regression

In simple regression one X explains Y; in multiple regression, several do. Each X’s coefficient is read “holding the others constant”: that is why it can change a lot (even flip sign) when variables are added or removed.

How to read the results

  • R² is the proportion of the variation in Y the model explains. Adjusted R² penalises each added variable and is the one to compare between models.
  • The F tests whether the model as a whole explains more than the mean. Each coefficient’s p value tests whether that variable adds anything once the others are in.
  • A coefficient’s confidence interval gives the plausible range of its effect. If it includes zero, no effect cannot be ruled out.
  • Standardised coefficients (beta) let you compare the relative weight of variables measured in different units.

The assumptions and how to check them

  • Linearity: look at the residual plot; there should be no curve.
  • Independent errors: Durbin-Watson near 2 (only with time-ordered data).
  • Constant variance (homoscedasticity): non-significant Breusch-Pagan and a residual cloud with no funnel shape.
  • Normal residuals: non-significant Jarque-Bera. It matters less with many observations.
  • No strong collinearity: VIF below 5 (or 10, depending on the rule).
  • No overly influential observations: small Cook’s distance.

Confidence or prediction interval

The confidence interval of the mean says where the average Y lies for given X values. The prediction interval says where an individual case may fall, and it is always wider. Mixing them up is a common mistake.

Common mistakes

  • Stopping at R² without checking assumptions or the residual plot.
  • Extrapolating outside the data range.
  • Reading correlation as causation.
  • Adding variables until R² goes up: it always rises, even if they add nothing; use the adjusted one.
  • Ignoring a high VIF: coefficients and their signs stop being reliable.

Limits of this calculator

  • It is ordinary least-squares linear regression. It does not do logistic or non-linear regression, interactions, categorical variables (you must code them) or robust errors.
  • Jarque-Bera is a quick normality check; with very small samples it has little power.
  • Durbin-Watson only makes sense if rows follow an order (time, for example).
  • Up to 2,000 rows and 10 explanatory variables.

Notice

This is an estimate. For publication, confirm the model with a statistics package and justify the assumptions you checked.

Frequently asked questions

What is linear regression?

A method that fits a line (or a plane) to data to describe how one variable changes with others and to predict new values.

How do I run a multiple regression?

Enter a column of Y and then one column for each explanatory variable. You can put the names on the first line.

What is the difference between R² and adjusted R²?

R² always rises when you add variables. The adjusted version penalises that, so it is the one for comparing models with different numbers of variables.

What counts as a good R²?

It depends on the field. In physics 0.99 is normal; in social science 0.3 can be a meaningful finding.

What is the VIF?

A collinearity measure: how much a coefficient’s variance grows because that variable resembles the others. Above 5 or 10, review the model.

What is the difference between a confidence and a prediction interval?

The confidence interval bounds the mean of Y for given X; the prediction interval bounds an individual case and is wider.

Can I extrapolate beyond my data range?

Only with great caution. The observed relationship may not hold outside the range you measured.

Is my data sent to a server?

No. The calculation runs in your browser.

Sources and references

The formula behind this calculator is not ours. These are the sources it comes from, in APA 7 format, in case you want to go to the original or cite them in your own work.

  1. Montgomery, D. C., Peck, E. A., & Vining, G. G. (2021). Introduction to linear regression analysis (6.ª ed.). Wiley. The least-squares formulas, prediction intervals and Cook’s distance.
  2. Breusch, T. S., & Pagan, A. R. (1979). A simple test for heteroscedasticity and random coefficient variation. Econometrica, 47(5), 1287–1294. https://doi.org/10.2307/1911963 https://doi.org/10.2307/1911963 The heteroscedasticity test included here.
  3. Durbin, J., & Watson, G. S. (1950). Testing for serial correlation in least squares regression: I. Biometrika, 37(3–4), 409–428. https://doi.org/10.2307/2332391 https://doi.org/10.2307/2332391 The residual autocorrelation statistic.

Need to calculate something else?

These tools are often used alongside this calculator.

Pearson correlation

Pearson’s r between two variables, with p value, confidence interval, regression line and scatter plot.

Spearman correlation

Rank correlation between two variables, which detects monotonic relationships even if they are not straight…

Cohen’s d

Effect size between two groups or before and after, with confidence intervals, plain-language equivalents…

Sample size

How many responses you need to estimate a percentage or a mean, with finite population, design effect and…

t-test

Compare two means (independent or paired) or one mean with a value, with p value, confidence interval and…