Linear Regression Calculator

Linear Regression Calculator
Statistics » Linear Correlation » Binomial Distribution » Sampling » Statistics and Probability

Understanding Linear Regression

Linear regression is a statistical method used to model the relationship between a dependent variable (often denoted $y$) and one or more independent variables (often denoted $x$). Simple linear regression involves a single independent variable.

The goal is to find a linear equation that best describes or "fits" the observed data. This line can then be used for prediction and understanding the relationship between the variables.

The Method of Least Squares

The most common method for finding the "line of best fit" is the method of least squares. This method determines the line that minimizes the sum of the squared vertical distances (errors or residuals) between the observed values and the values predicted by the linear model.

  • Regression of Y on X ($y = a + bx$): Minimizes vertical errors, $\sum (y_i - \hat{y}_i)^2$. This is used to predict $y$ from $x$.
  • Regression of X on Y ($x = a' + b'y$): Minimizes horizontal errors, $\sum (x_i - \hat{x}_i)^2$. This is used to predict $x$ from $y$.

These two lines are generally different unless the data points fall perfectly on a single line.

Regression Line Formulas

1. Regression Line of Y on X: $y = a + bx$

Slope ($b$): $$ b = \frac{n(\sum xy) - (\sum x)(\sum y)}{n(\sum x^2) - (\sum x)^2} $$

Intercept ($a$): $$ a = \bar{y} - b\bar{x} $$


2. Regression Line of X on Y: $x = a' + b'y$

Slope ($b'$): $$ b' = \frac{n(\sum xy) - (\sum x)(\sum y)}{n(\sum y^2) - (\sum y)^2} $$

Intercept ($a'$): $$ a' = \bar{x} - b'\bar{y} $$

Enter Your Data