Economic quiz

profileqwertyu43
3rd_class_august_30.pdf

Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Robert de Jong1

1Department of Economics Ohio State University

Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Today’s class 1 Hand out our first takehome 2 Two groups class split for computer class and test of Friday

September 1 and Friday September 8 3 Exercise 4 Short review 5 Calculation of the regression line by hand 6 Calculation of the regression line with the computer 7 Another exercise 8 Three more factoids about the regression line

Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Outline

1 Econ 5410, Wednesday August 30, class 3 Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Computer classes September 1 and September 8: If you specified a preference on the sheet that circulated last week, then please go to the time slot you specified (either 12:45pm-1:25pm, or 1:25pm-2:05pm) Otherwise, please come 1:25pm-2:05pm.

In other words: come 1:25pm-2:05pm, unless you put your name down for the 12:45pm-1:25pm time slot

Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Outline

1 Econ 5410, Wednesday August 30, class 3 Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Exercise

1 Find a counterexample that shows that in general, ( ∑N

i=1 Xi ) 2 6=

∑N i=1 X

2 i .

Example: N = 2, X1 = 1, X2 = 2. Then N∑

i=1

Xi = 2∑

i=1

Xi = X1 + X2 = 3,

so ( ∑N

i=1 Xi ) 2 = 32 = 9, while

N∑ i=1

X 2i = X 2 1 + X

2 2 = 1

2 + 22 = 1 + 4 = 5.

Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Exercise

1 Find a counterexample that shows that in general, ( ∑N

i=1 Xi ) 2 6=

∑N i=1 X

2 i .

Example: N = 2, X1 = 1, X2 = 2. Then N∑

i=1

Xi = 2∑

i=1

Xi = X1 + X2 = 3,

so ( ∑N

i=1 Xi ) 2 = 32 = 9, while

N∑ i=1

X 2i = X 2 1 + X

2 2 = 1

2 + 22 = 1 + 4 = 5.

Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

2 Calculate ∑4

i=1 i .

4∑ i=1

i = 1 + 2 + 3 + 4 = 10.

3 X̄ denotes the average of the Xi . Why is∑N i=1 Xi − NX̄ = 0?

X̄ = N−1 N∑

i=1

Xi,

so N∑

i=1

Xi −NX̄ = N∑

i=1

Xi −N ·N−1 N∑

i=1

Xi = N∑

i=1

Xi − N∑

i=1

Xi = 0.

Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

2 Calculate ∑4

i=1 i . 4∑

i=1

i = 1 + 2 + 3 + 4 = 10.

3 X̄ denotes the average of the Xi . Why is∑N i=1 Xi − NX̄ = 0?

X̄ = N−1 N∑

i=1

Xi,

so N∑

i=1

Xi −NX̄ = N∑

i=1

Xi −N ·N−1 N∑

i=1

Xi = N∑

i=1

Xi − N∑

i=1

Xi = 0.

Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

2 Calculate ∑4

i=1 i . 4∑

i=1

i = 1 + 2 + 3 + 4 = 10.

3 X̄ denotes the average of the Xi . Why is∑N i=1 Xi − NX̄ = 0?

X̄ = N−1 N∑

i=1

Xi,

so N∑

i=1

Xi −NX̄ = N∑

i=1

Xi −N ·N−1 N∑

i=1

Xi = N∑

i=1

Xi − N∑

i=1

Xi = 0.

Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

4 Consider the following data points Xi and Yi :

Xi Yi 7 3 6 1 5 4

For those data points, calculate∑N i=1 Xi ;∑N i=1 Yi ;∑N i=1 Y

2 i ;∑N

i=1 Xi Yi .

Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

4 We have

Xi Yi Y 2i Xi Yi 7 3 9 21 6 1 1 6 5 4 16 20

18 8 26 47

Therefore,∑N i=1 Xi = 18;∑N i=1 Yi = 8;∑N i=1 Y

2 i = 26;∑N

i=1 Xi Yi = 47.

Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Outline

1 Econ 5410, Wednesday August 30, class 3 Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Suppose that we try the line y = β0 + β1x point # vertical distance squared vertical

to line distance 1 |Y1 − (β0 + β1X1)| |Y1 −β0 −β1X1|2 2 |Y2 − (β0 + β1X2)| |Y2 −β0 −β1X2|2 3 |Y3 − (β0 + β1X3)| |Y3 −β0 −β1X3|2

total: |Y1 −β0 −β1X1|2 +|Y2 −β0 −β1X2|2 +|Y3 −β0 −β1X3|2

In general:

|Y1 −β0 −β1X1|2 + |Y2 −β0 −β1X2|2

+ . . . + |YN −β0 −β1XN|2

where N denotes sample size Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Using mathematics, we can find the values of β0 and β1 that minimize

|Y1 −β0 −β1X1|2 + |Y2 −β0 −β1X2|2

+ . . . + |YN −β0 −β1XN|2.

Question: why not minimize the sum of absolute values, or fourth powers?

Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Minimizing N∑

i=1

(Yi − (β0 + β1Xi ))2

over all possible values of β0 and β1 gives

β̂1 = N ·

∑N i=1 Xi Yi −

∑N i=1 Xi ·

∑N i=1 Yi

N · ∑N

i=1 X 2 i − (

∑N i=1 Xi )

2

and β̂0 = Ȳ − β̂1X̄

Note Ȳ = N−1 ∑N

i=1 Yi , the average of the Yi

The mathematical calculation requires being able to find the minimum of a function of two variables using differentiation

Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Outline

1 Econ 5410, Wednesday August 30, class 3 Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Last class’ in-class example

Xi Yi Xi Yi X 2i 1 2 2 1 4 2 8 16 1 3 3 1 6 7 13 18

β̂1 = N ·

∑N i=1 Xi Yi −

∑N i=1 Xi ·

∑N i=1 Yi

N · ∑N

i=1 X 2 i − (

∑N i=1 Xi )

2

= 3 · 13 − 7 · 6 3 · 18 − 62

= 39 − 42 54 − 36

= −3 18

= − 1 6 ≈−0.167

Also

β̂0 = Ȳ − β̂1X̄ = 7/3 − (− 1 6

)(6/3) = 8/3 ≈ 2.67

Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Q: does the regression line y = (8/3) − (1/6)x pass through the middle of the points (1,2) and (1,3)?

A: Yes, if x = 1, the corresponding y value for the regression line is

(8/3) − (1/6) · 1 = (16/6) − (1/6)

= 15/6 = 2.5

Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Outline

1 Econ 5410, Wednesday August 30, class 3 Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Computer software: Gretl will calculate the regression line for us

Other packages that can do this: Excel, or other spreadsheet program SAS, SPSS Stata, Eviews, etc.

Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Goal of this class: be able to interpret output for regressions; examples:

1 A “wage equation": explaining individuals’ wages from characteristics; http://www.econ.ohio-state.edu/ dejong/files/wage2.gdt

2 Teenage pregnancy rates in Ohio counties; http://www. econ.ohio-state.edu/dejong/teenpreg.gdt

3 George W. Bush approval rating vs. oil price http://www.econ.ohio-state.edu/dejong/ bushapproval2.gdt

Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Outline

1 Econ 5410, Wednesday August 30, class 3 Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

In-class exercise

Xi Yi Xi Yi X 2i 1 3 3 1 3 4 12 9 2 5 10 4 6 12 25 14

Question 1

β̂1 = N ·

∑N i=1 Xi Yi −

∑N i=1 Xi ·

∑N i=1 Yi

N · ∑N

i=1 X 2 i − (

∑N i=1 Xi )

2

= 3 · 25 − 6 · 12

3 · 14 − 62 =

75 − 72 42 − 36

= 3 6

= 0.5

β̂0 = Ȳ − 1.4X̄ = 4 − 0.5 · 2 = 3 Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Question 2

Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Questions 3 and 4: calculate

residuals ei = Yi − β̂0 − β̂1Xi = Yi − 3 − 0.5Xi

and

predictions Ŷi = β̂0 + β̂1Xi = 3 + 0.5Xi

Xi Yi Yi − 3 − 0.5Xi 3 + 0.5Xi 1 3 3 − 3 − 0.5 · 1 = −0.5 3 + 0.5 · 1 = 3.5 3 4 4 − 3 − 0.5 · 3 = −0.5 3 + 0.5 · 3 = 4.5 2 5 5 − 3 − 0.5 · 2 = 1 3 + 0.5 · 2 = 4 6 12 0 12

Question 5 and 6: residuals add up to 0; predictions sum to the same value as Yi ; why ?Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Residual: ei = Yi − β̂0 − β̂1Xi

Average of residuals:

N−1 N∑

i=1

ei = N −1

N∑ i=1

(Yi − β̂0 − β̂1Xi )

= (N−1 N∑

i=1

Yi ) − β̂0 − β̂1(N−1 N∑

i=1

Xi ) = Ȳ − β̂0 − β̂1X̄

but β̂0 = Ȳ − β̂1X̄,

so

N−1 N∑

i=1

ei = Ȳ − β̂0 − β̂1X̄ = 0 Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Average of predictions = average of Yi

average of predictions Ŷi

= N−1 N∑

i=1

Ŷi = N −1

N∑ i=1

(β̂0 + β̂1Xi )

= β̂0 + β̂1X̄

= (Ȳ − β̂1X̄ ) + β̂1X̄

= Ȳ .

Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Outline

1 Econ 5410, Wednesday August 30, class 3 Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Why does the regression line pass through the point (X̄, Ȳ ) ?

Earlier: regression line was y = 3 + 0.5x , X̄ = 2, Ȳ = 4

This regression line passed through (2,4) because

3 + 0.5X̄ = 3 + 0.5 · 2

= 3 + 1 = 4 = Ȳ

Reason: we draw the line

y = β̂0 + β̂1x = (Ȳ − β̂1X̄ ) + β̂1x,

and for x = X̄ , we get

y = (Ȳ − β̂1X̄ ) + β̂1X̄ = Ȳ .

Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Last week’s in-class example; Xi and Yi reversed: Yi Xi Xi Yi X 2i 1 2 2 4 4 2 8 4 1 3 3 9 6 7 13 17

β̂1 = N ·

∑N i=1 Xi Yi −

∑N i=1 Xi ·

∑N i=1 Yi

N · ∑N

i=1 X 2 i − (

∑N i=1 Xi )

2

= 3 · 13 − 7 · 6 3 · 17 − 72

= 39 − 42 51 − 49

= −3 2

= −1.5

Also

β̂0 = Ȳ − β̂1X̄ = 2 − (−3/2)(7/3) = 2 + (7/2) = 5.5 Regression line: y = 5.5 − 1.5x

Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Other example

Yi Xi Xi Yi X 2i 3 2 6 4 4 2 8 4 5 2 10 4 12 6 24 12

So,

β̂1 = N ·

∑N i=1 Xi Yi −

∑N i=1 Xi ·

∑N i=1 Yi

N · ∑N

i=1 X 2 i − (

∑N i=1 Xi )

2

= 3 · 24 − 6 · 12

3 · 12 − 62 =

72 − 72 36 − 36

= 0 0

=???

Robert de Jong Econ 5410, Wednesday August 30, class 3

Econ 5410, Wednesday August 30, class 3

Two groups class split for computer class and test of Friday September 1 and Friday September 8 Exercise Review Calculating the regression line by hand Calculating the regression line by computer Another exercise Three more factoids

Robert de Jong Econ 5410, Wednesday August 30, class 3

  • Econ 5410, Wednesday August 30, class 3
    • Two groups class split for computer class and test of Friday September 1 and Friday September 8
    • Exercise
    • Review
    • Calculating the regression line by hand
    • Calculating the regression line by computer
    • Another exercise
    • Three more factoids