 # Linear Regression Formula

Linear regression is the most basic and commonly used predictive analysis. One variable is considered to be an explanatory variable, and the other is considered to be a dependent variable. For example, a modeler might want to relate the weights of individuals to their heights using a linear regression model.

There are several linear regression analyses available to the researcher.

Simple linear regression

• One dependent variable (interval or ratio)
• One independent variable (interval or ratio or dichotomous)

Multiple linear regression

• One dependent variable (interval or ratio)
• Two or more independent variables (interval or ratio or dichotomous)

Logistic regression

• One dependent variable (binary)
• Two or more independent variable(s) (interval or ratio or dichotomous)

Ordinal regression

• One dependent variable (ordinal)
• One or more independent variable(s) (nominal or dichotomous)

Multinomial regression

• One dependent variable (nominal)
• One or more independent variable(s) (interval or ratio or dichotomous)

Discriminant analysis

• One dependent variable (nominal)
• One or more independent variable(s) (interval or ratio)

Formula for linear regression equation is given by:

$\large y=a+bx$

a and b are given by the following formulas:

$$\begin{array}{l}\large a \left(intercept\right)=\frac{\sum y \sum x^{2} – \sum x \sum xy} {(\sum x^{2}) – (\sum x)^{2}}\end{array}$$

$$\begin{array}{l}\large b\left(slope\right)=\frac{n\sum xy-\left(\sum x\right)\left(\sum y\right)}{n\sum x^{2}-\left(\sum x\right)^{2}}\end{array}$$

Where,
x and y are two variables on the regression line.
b = Slope of the line.
a = y-intercept of the line.
x = Values of the first data set.
y = Values of the second data set.

### Solved Examples

Question: Find linear regression equation for the following two sets of data:

 x 2 4 6 8 y 3 7 5 10

Solution:

Construct the following table:

 x y x2 xy 2 3 4 6 4 7 16 28 6 5 36 30 8 10 64 80 $$\begin{array}{l}\sum x\end{array}$$ = 20 $$\begin{array}{l}\sum y\end{array}$$ = 25 $$\begin{array}{l}\sum x^{2}\end{array}$$ = 120 $$\begin{array}{l}\sum xy\end{array}$$ = 144

$$\begin{array}{l}b\end{array}$$
=
$$\begin{array}{l}\frac{n\sum xy-(\sum x)(\sum y)}{n\sum x^{2}-(\sum x)^{2}}\end{array}$$

$$\begin{array}{l}b\end{array}$$
=
$$\begin{array}{l}\frac{4 \times 144 – 20 \times 25}{4 \times 120 – 400}\end{array}$$

b = 0.95

$$\begin{array}{l}a=\frac{\sum y \sum x^{2} – \sum x \sum xy} {n(\sum x^{2}) – (\sum x)^{2}}\end{array}$$

$$\begin{array}{l}a=\frac{25\times 120 – 20\times 144} {4(120) – 400}\end{array}$$

a = 1.5

Linear regression is given by:

y = a + bx

y = 1.5 + 0.95 x