Module 11 Examples

Simple Linear Regression

x

1

2

4

5

8

Mean = 4 =(1+2+4+5+8)/ 5

 y

20

19

34

30

47

Mean = 30 =(29+19+34+30+47)/ 5

 

Find the Regression line for the points

 

Formula:

 

y = a + bx

 

 

 

 

 

Calculate b

 

(1-4)(20-30) +

(2-4)(19-30) +

(4-4)(34-30) +

(5-4)(30-30) +

(8-4)(47-30)

---------------------------------------------------------------------------------------------------------------

(1-4)2 +

(2-4)2 +

(4-4)2 +

(5-4)2 +

(8-4)2

 

(-3)(-10) +

(-2)(-11) +

(0)( 4) +

(1)(0) +

(4)(17)

----------------------------------------------------------------------------------------------------------

(-3)2 +

(-2)2 +

(0)2 +

(1)2 +

(4)2

 

30+

22 +

0 +

0 +

68

----------------------------------------------------------------------------------------------------------

9 +

4 +

0 +

1 +

16

 

120

------------------------------------

30

 

.b = 4

 

Calculate a

 

30 –4(4)

 

30 –16

.a =14

 

Calculate y

 

y = a + bx

 

y = a + bx

14 + 4x

.y =14 + 4x

 

The regression line is y= 14 + 4x

 

Calculate the regression Coefficient for a and b:

 

(20-30)2 +

(19-30) 2 +

(34-30) 2 +

(30-30) 2 +

(47-30) 2

 

(-10) 2 +

(-11) 2 +

(4) 2 +

(0) 2 +

(17)2

 

100 +

121 +

16 +

0 +

289

 

Total Variation =  = 526

 

                                                   

 

r = .9553

 

The correlation coefficient is close to 1, indicating a strong positive correlation Exactly the same result can be achieved using the formula for R2

 

x

Fitted y value

y = a + bx

y =14 + 4x

 

 

Explained variation

1

14 + 4(1) =18

 

(18-30)2=144

2

14 + 4(2) =22

 

(22-30)2=  64

4

14 + 4(4) =30

 

(30-30)2=    0

5

14 + 4(5) =34

 

(34-30)2=  16

8

14 + 4(8) = 46

 

(46-30)2=256

 

 

 

Explained variation=480

 

R2 = Explained variation / Total variation

R2 = .9125

 

Squaring r = r2

 

 

                                       

 

Precisely equivalent to the result obtained form the formula for R2

 

Check Residual

x

y

Fitted y value

y = a + bx

y =14 + 4x

Residual

Act y – fit. y

1

20

14 + 4(1) = 18

   20     18 =   2

2

19

14 + 4(2) = 22

   19     22 =  -3

4

34

14 + 4(4) = 30

   34     30 =   4

5

30

14 + 4(5) = 34

   30     34 =  -4

8

47

14 + 4(8) = 46

   47     46=   1

 

 

Find the linear regression line and correlation on HB10 Calculator

Find the linear regression line for the following table of numbers.  Also find the correlation.

 

1: Clear Memory

 Row 6, Column 1 Row 3, second one in(CLS)

 

2: Enter Data

 1 Row 3, long key on the left 20 Row 1, Column 6 2 Row 3, long key on the left 19 Row 1, Column 6 4  Row 3, long key on the left
  
34 Row 1, Column 6 5 Row 3, long key on the left 30 Row 1, Column 6 8 Row 3, long key on the left 47Row 1, Column 6

 

3: Calculate the mean of x  and mean of y

 Row 6, Column 1 7

Row 6, Column 1 K (SWAP)  (mean of y)

mean x = 4

 

mean y = 30

4: Compute the slope of the regression line

 0 Row 6, Column 1  5  (=14)

 Row 6, Column 1 K (SWAP) (= 4)

 

y =14 + 4x

5: Compute the y-intercept of the regression line.

 0 Row 6, Column 1  5  (=14)

 

 

 

6: Compute the correlation.

 Row 6, Column 1  4    

Row 6, Column 1  K (SWAP)

 

R2 = .9553

 r = .9553


    You should get a slope of 14, a y-intercept of 4, and a correlation of 0.9553,  The regression line would be: y = 14 +4x