Linear Regression Calculator

StatisticsLast updated: August 17, 2026

Simple linear regression is the modeling technique that predicts a dependent (response) variable from a single independent (predictor) variable. The analysis finds the line that best represents the relationship between X and Y by the method of least squares and produces an equation of the form ŷ = b₀ + b₁·x. Questions such as "how well does study time predict an exam score?" or "how much does demand change when the price goes up by one unit?" are typical applications.

This calculator returns the regression coefficients, the correlation, R² and adjusted R², the standard error of the estimate, and the significance test for the slope (t and p); it draws the observed values and the regression line on the same chart. Enter a value in the optional prediction field and you also get the expected y for that x straight from the equation.

Separate the values with commas, spaces, or line breaks. Both decimal points and decimal commas are accepted.
Each value must belong to the observation (the same participant) in the matching position of the X field.
Optional: enter an x value and the expected y is computed from the equation.

Formula

b₁ = Σ(xᵢ − x̄)(yᵢ − ȳ) / Σ(xᵢ − x̄)²
b₀ = ȳ − b₁·x̄
ŷ = b₀ + b₁·x
t = b₁ / SE(b₁)  ,  df = n − 2

The coefficients come from the method of least squares: the chosen line is the one that minimizes the sum of squared residuals (observed − predicted). In simple regression R² equals the square of the Pearson correlation, and the t test of the slope returns the same p-value as the significance test of the correlation.

How to Calculate

  1. Paste the X (independent) and Y (dependent) values into the two fields in the same order; each row must belong to the same observation.
  2. If you wish, enter an x value in the prediction field — the expected y is computed automatically from the equation.
  3. Read the equation, R² and adjusted R², and the t and p values for the slope in the results section.
  4. Compare the observed Y values with the regression line on the chart; if the relationship does not look linear, do not use a linear model.
  5. Report the slope, R², and the significance together, and keep your predictions within the range of x covered by your data.

Worked Examples

Study hours and quiz score (small sample)

For five students the equation is ŷ = 2.20 + 0.60·x: one extra hour of study raises the score by 0.60 on average, and with R² = 0.600 the model explains 60% of the variance. With n = 5, however, the sample is far too small for the slope to reach significance (t(3) = 2.12; p = 0.124). The prediction for x = 4 is ŷ = 4.60.

Regression equation: ŷ = 2.20 + 0.60·x · Slope (b₁): 0.6000 · Intercept (b₀): 2.2000

Weekly study hours and exam score (12 students)

For a data set of 12 students the equation is ŷ = 50.03 + 2.10·x: each additional hour of study raises the score by 2.10 points on average. R² = 0.406 (40.6%) and the slope is significant (t(10) = 2.61; p = 0.026). A student who studies 7 hours a week has an expected score of ŷ = 64.71.

Regression equation: ŷ = 50.03 + 2.10·x · Slope (b₁): 2.0963 · Intercept (b₀): 50.0327

Price and demand (negative slope)

Between price (X) and units sold (Y) the equation is ŷ = 123.92 − 2.83·x: a one-unit rise in price is associated with an average drop of 2.83 units in demand. The model fits almost perfectly (R² = 0.996; p < 0.001), and the correlation is r = -0.998.

Regression equation: ŷ = 123.92 − 2.83·x · Slope (b₁): -2.8333 · Intercept (b₀): 123.9167

Frequently Asked Questions

How high should R² be?
There is no universal threshold; what counts as an acceptable R² depends on the field. Under Cohen's widely used classification, 0.02 is a small effect, 0.13 a medium one, and 0.26 or above a large one. Experimental work in the physical sciences may expect R² above 0.80, while in the social sciences values of 0.20–0.30 can still be meaningful and valuable.
What does a negative slope (b₁) mean?
A negative slope means that Y tends to decrease as X increases. If b₁ = −2.5, for instance, a one-unit increase in X is associated with an average decrease of 2.5 units in Y. The sign of the slope only tells you the direction of the relationship; the strength of the model is judged separately by R², and whether the slope differs from zero by the p-value.
Why is predicting outside the data range (extrapolation) risky?
The regression equation has only been tested over the observed range of X. Outside that range there is no guarantee that the relationship keeps the same linear form; it may curve or even reverse. Predicting a score for 40 hours from a model built on 1–10 hours of study can produce entirely unrealistic results.
What does regression add once you have the correlation?
A correlation summarizes the direction and strength of the relationship in a single coefficient; a regression turns that relationship into an equation you can predict with. The equation lets you compute the expected y for a specific x, and the slope answers the concrete question "how much does Y change when X goes up by one unit?" R² and the standard error of the estimate also tell you how good the model is.
How much data does a regression analysis need?
This calculator will work with as few as 3 data pairs, but results from samples that small are extremely unstable. The literature generally recommends at least 25–30 observations for simple linear regression. As the sample grows, the coefficient estimates stabilize, the confidence intervals narrow, and the p-values become trustworthy.
Does regression prove causation?
No. A significant slope only shows that Y can be predicted more accurately when X is known; it does not prove that X produces Y. Y may be affecting X, or both may be driven by a third variable. In your write-up, prefer wording such as "predicts" or "is associated with", and avoid saying "causes".