Um blog sobre nada

Um conjunto de inutilidades que podem vir a ser úteis

Intercept, Slope and the Linear Regression Function

Posted by Diego em Novembro 4, 2014


 

The Linear Regression function is a line that minimizes the squared distances (squared error) between the line and each point.
The error is the vertical distance between the point and the line.
To define the function, we need to find out the Intersect and the slope (β0 and β1).

 

Given a random dataset:

 

X

Y

1

5

2

6

3

7

4

8

5

9

6

10

7

11

8

12

9

13

10

14

11

15

12

20

13

25

14

33

15

34

16

35

17

36

18

37

19

38

20

39

With the following  information:

 

 

X

Y

   

Std Dev

5.91608

12.67519

   
     

Correl

0.964021

Mean

10.5

20.35

   

 

·         We are using the sample standard deviation

·         The correlation was calculated in excel using the CORREL function

 

 

Who can be plotted like this:

clip_image002

 

 

The slope is defined by:

β1 = CORREL * (sdY / sdX)
       = 0.964021 * (
12.67519 / 5.91608)
       = 2.065414

(how to calculate correlation is explained here)

β0 =  meanY – (β1* meanX)
     = 20.35 – (
2.065414 * 10.5)
     = 20.35 – (21.686847)
     = -1.336847

 

Then the formula is:

Y= β1X + β0
y = 2.0654x – 1.3368

clip_image003

 

Interesting to note that the function will cross the (meanX, meanY) point, in this case (10.5, 20.35)

clip_image005

 

 

Another way to find the slope is applying the formula bellow (and this is from khan academy – https://www.khanacademy.org/math/probability/regression/regression-correlation/v/proof-part-4-minimizing-squared-error-to-regression-line) :

clip_image006

 

Which in this example would be:

= ((10.5 * 20.35) – (282.35)) / (110.25 – 143.5)
= -68.675 / -33.25
= 2.065414

Another interesting formula is:

image

Which means, the predicted Yi – the average of Ys  is equal to the slope * (Xi – mean of X)

Deixe uma Resposta

Preencha os seus detalhes abaixo ou clique num ícone para iniciar sessão:

Logótipo da WordPress.com

Está a comentar usando a sua conta WordPress.com Terminar Sessão / Alterar )

Imagem do Twitter

Está a comentar usando a sua conta Twitter Terminar Sessão / Alterar )

Facebook photo

Está a comentar usando a sua conta Facebook Terminar Sessão / Alterar )

Google+ photo

Está a comentar usando a sua conta Google+ Terminar Sessão / Alterar )

Connecting to %s

 
%d bloggers like this: