Econ 526 In Class Exercise Week 3

advertisement
Econ 526
In Class Exercise Week 3
Regression Example: What is the effect of height on weight?
Calculating the Regression Line:
X=height
Y=weight
60
62
64
66
68
70
72
74
76
84
95
140
155
119
175
145
197
150
X
Y
(X  X)
n
1.
b
 (x
i
2.
 x )( yi  y )

i 1
n
 (x
i 1
a  y  bx
(Y  Y )
i
 x)2
Cov ( x , y )
Var ( x )
( X  X )(Y  Y )
( X  X )2
(Y  Y ) 2
 ( X  X )(Y  Y )
Cov(x,y)
å (X - X)
2
Var(x)
 (Y  Y )
Var(y)
2
Econ 526
In Class Exercise Week 3
Calculating the Regression Error Terms:
Predicted value: y i  200  5xi
n
Regression Sum of Squares: RSS = å ( ŷi - y)2
i=1
n
Sum of Squared Errors: ESS = å (yi - ŷi )2
i=1
n
Total Sum of Squares: TSS = å (yi - y )2
i=1
X=height
Y=weight
60
62
64
66
68
70
72
74
76
84
95
140
155
119
175
145
197
150
X
Y
Predicted
y
Regression SS
( y i  y )
( y i  y ) 2
 ( y
i
 y)2
Error SS
( yi  y i )
( yi  y i ) 2
(y
i
 y i ) 2
Econ 526
In Class Exercise Week 3
Purpose of Regression:
We’re interested in fitting the best line because we can then describe the
relationship between height and weight as a linear function with a slope and
intercept. The goal of linear regression is to find the slope and intercept that best
fits the data. The regression line is y = a + bx + e
(1)
a=intercept; b=slope; e = error term
(2)
y = dependent variable; x = independent
variable.
the fitted line: y  a  bx
(3)
n
2.
b
 (x
i
 x )( yi  y )

i 1
n
 (x
i
 x)2
Cov ( x , y )
Var ( x )
i 1
3.
Intercept: a  y  bx
n
1.
Slope: b 
 (x
i
 x )( yi  y )

i 1
n
 (x
i
 x)2
Cov ( x , y ) 1200

5
Var ( x )
240
i 1
2.
Intercept: a  y  bx  140  5(68)  200
3.
Regression line: y = -200 + 5x + e
4.
Predicted value: y i  200  5xi

slope interpretation: an increase in one inch of height
will increase weight by 5 pounds.

intercept interpretation: if height = 0; weight = -200.

Note: the regression line always passes thru the point
(x, y)
B.
X(i)=
Height
60
62
64
66
68
70
72
74
76
68
X
Y(i)=
Weight
84
95
140
155
119
175
145
197
150
140
Y
( xi  x )
( yi  y )
( xi  x )( yi ( xyi ) x ) 2
( yi  y ) 2
-8
-6
-4
-2
0
2
4
6
8
-56
-45
0
15
-21
35
5
57
10
448
270
0
-30
0
70
20
342
80
1200
Cov(xy)
3136
2025
0
225
441
1225
25
3249
100
10426
Var(y)
64
36
16
4
0
4
16
36
64
240
Var(x)
Calculating the Regression Error Terms:
Predicted value: y i  200  5xi
n
Regression Sum of Squares: RSS = å ( ŷi - y)2
i=1
n
Sum of Squared Errors: ESS = å (yi - ŷi )2
i=1
n
Total Sum of Squares: TSS = å (yi - y )2
i=1
X=height
Y=weight
60
62
64
66
68
70
72
74
76
68
X
84
95
140
155
119
175
145
197
150
140
Y
Predicted
y
100
110
120
130
140
150
160
170
180
Regression SS
( y i  y )
( y i  y ) 2
-40
-30
-20
-10
0
10
20
30
40
1600
900
400
100
0
100
400
900
1600
6000
 ( yi  y ) 2
Error SS
( yi  y i )
( yi  y i ) 2
-16
-15
20
25
-21
25
-15
27
-30
256
225
400
625
441
625
225
729
900
4426
 ( yi  yi ) 2
Download