1 econ 240a power 7. 2 this week, so far §normal distribution §lab three: sampling distributions...

69
1 Econ 240A Power 7

Post on 19-Dec-2015

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

1

Econ 240A

Power 7

Page 2: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

2

This Week, So Far

Normal DistributionLab Three: Sampling DistributionsInterval Estimation and Hypothesis Testing

Page 3: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

3

Outline

Distribution of the sample varianceThe California Budget: Exploratory Data

AnalysisTrend ModelsLinear Regression ModelsOrdinary Least Squares

Page 4: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

4

PopulationRandom variable xDistribution f(f ?

Sample

Sample Statistic:

),(~ 2Nx

Sample Statistic

)1/()( 2

1

2

nxxsn

ii

Pop.

Page 5: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

5

The Sample Variance, s2

22

1

22

/*)1(

)1/(])([

sn

nxixsn

i

Is distributed 2 with n-1 degrees of

freedom (text, 12.2 “inference about a population variance)(text, pp. 266-270, Chi-Squared distribution)

n

i

n

ii zxxsn

1 1

22222 /)(/)1(

Page 6: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

6

TextChi-SquaredDistribution

Page 7: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

7

TextChi-SquaredTable 5Appendixp. B-10

Page 8: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

8

Example: Lab Three50 replications of a sample of size 50

generated by a Uniform random number generator, range zero to one, seed =20. expected value of the mean: 0.5 expected value of the variance: 1/12

Page 9: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

9

Histogram of 50 sample means

05

1015

20

0.05

0.15

0.25

0.35

0.45

0.55

0.65

0.75

0.85

0.95

Mor

e

Sample Mean

Fre

qu

en

cy

Histogram of 50 Sample Means, Uniform, U(0.5, 1/12)

Average of the 50 sample means: 0.4963

Page 10: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

10

Histogram of 50 Sample Variances

0

5

10

15

20

0.01

0.03

0.05

0.07

0.09

0.11

0.13

0.15

0.17

0.19

0.21

0.23

0.25

Sample variance

Fre

qu

en

cy

Histogram of 50 sample variances, Uniform, U(0.5, 0.0833)

Average sample variance: 0.0832

Page 11: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

11

Confidence Interval for the first sample variance of 0.07667A 95 % confidence interval

95.0]0562.01161.0[

95.0]01.19/161.8[

95.0]42.71/07667.0*4936.32[

95.0]42.71/*)1(36.32[

95.0]42.7136.32[

2

2

2

22

2

p

p

p

snp

p

Where taking the reciprocal reverses the signs of the inequality

Page 12: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

12

Page 13: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

13

The UC Budget

Page 14: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

14

The UC Budget

The part of the UC Budget funded by the state from the general fund

Page 15: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

15

Page 16: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

16

Page 17: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

17

Total General Fund ExpendituresAppendix, p.11Schedule 6

Page 18: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

18

UC General Fund Expenditures, Appendix p. 33

2003-04, General fund actual, $2,901,257,000

2004-05, estimated $2,175,205,000

2005-06, estimated $2,806,267,000

Page 19: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

19

UC General Fund Expenditures, Appendix p. 46

Page 20: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

20

Page 21: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

21

Page 22: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

22

Page 23: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

23

Page 24: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

24

Page 25: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

25

Page 26: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

26

Page 27: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

27

UC Budget in Nominal Millions: 1968-69 through 2007-08

0

500

1000

1500

2000

2500

3000

3500

4000

68-6

9

70-7

1

72-7

3

74-7

5

76-7

7

78-7

9

80-8

1

82-8

3

84-8

5

86-8

7

88-8

9

90-9

1

92-9

3

94-9

5

96-9

7

98-9

9

00-0

1

02-0

3

04-0

5

06-0

7

Fiscal Year

Mill

ion

s $

Page 28: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

28

How to Forecast the UC Budget?

Linear Trendline?

Page 29: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

29

Trend Models

Page 30: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

30

UC Budget in Nominal Millions: 1968-69 through 2007-08

y = 80.323x + 36.343

R2 = 0.9431

0

500

1000

1500

2000

2500

3000

3500

4000

68-6

9

70-7

1

72-7

3

74-7

5

76-7

7

78-7

9

80-8

1

82-8

3

84-8

5

86-8

7

88-8

9

90-9

1

92-9

3

94-9

5

96-9

7

98-9

9

00-0

1

02-0

3

04-0

5

06-0

7

Fiscal Year

Mill

ion

s $

Page 31: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

31

UC Budget In Millions of Nominal Dollars, 1968-69 to 2006-07

y = 80.143x + 38.773

R2 = 0.9385

0

500

1000

1500

2000

2500

3000

3500

4000

68-6

9

70-7

1

72-7

3

74-7

5

76-7

7

78-7

9

80-8

1

82-8

3

84-8

5

86-8

7

88-8

9

90-9

1

92-9

3

94-9

5

96-9

7

98-9

9

00-0

1

02-0

3

04-0

5

06-0

7

Fiscal Year

Mill

ion

s $

Page 32: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

32

UC Budget in Nominal Millions: 1968-69 through 2007-08

y = 80.323x + 36.343

R2 = 0.9431

0

500

1000

1500

2000

2500

3000

3500

4000

68-6

9

70-7

1

72-7

3

74-7

5

76-7

7

78-7

9

80-8

1

82-8

3

84-8

5

86-8

7

88-8

9

90-9

1

92-9

3

94-9

5

96-9

7

98-9

9

00-0

1

02-0

3

04-0

5

06-0

7

Fiscal Year

Mill

ion

s $

Slope: increase of 80.323 Million $ per yearGovernor’s Proposed Increase 186.712 Million $

Page 33: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

33

Linear Regression Trend Models

A good fit over the years of the data sample may not give a good forecast

Page 34: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

34

How to Forecast the UC Budget?

Linear trendline?Exponential trendline ?

Page 35: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

35

Page 36: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

36

Trend Models

Page 37: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

37

An Application

Page 38: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

38

Page 39: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

39

Time Series Trend Analysis

Two Steps Select a trend model Fit the trend model

• Graphically

• algebraically

Page 40: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

40

Trend Models

Linear Trend: y(t) = a + b*t +e(t) dy(t)/dt = b

Exponential trend: z(t) = exp(c + d*t + u(t)) ln z(t) = c + d*t + u(t) (1/z)*dz/dt = d

Page 41: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

41

Linear Trend Model Fitted to UC Budget UCBUDB(t) = 0.0363 + 0.0803*t, R2 = 0.943

UC Budget in Nominal Billions $: 1968-69 through 2007-08

y = 0.0803x + 0.0363

R2 = 0.9431

0

0.5

1

1.5

2

2.5

3

3.5

4

68-6

9

70-7

1

72-7

3

74-7

5

76-7

7

78-7

9

80-8

1

82-8

3

84-8

5

86-8

7

88-8

9

90-9

1

92-9

3

94-9

5

96-9

7

98-9

9

00-0

1

02-0

3

04-0

5

06-0

7

Fiscal Year

Bill

ion

s $

Page 42: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

42

Time Series ModelsLinear

UCBUD(t) = a + b*t + e(t) where the estimate of a is the intercept: $0.0363

Billion in 68-69 where the estimate of b is the slope: $0.0803

billion/yr where the estimate of e(t) is the the difference

between the UC Budget at time t and the fitted line for that year

Exponential

Page 43: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

43

UC Budget in Billions $:1968-69 through 2007-08

y = 0.3838e0.0611x

R2 = 0.9047

0

0.5

1

1.5

2

2.5

3

3.5

4

4.5

5

68-6

9

70-7

1

72-7

3

74-7

5

76-7

7

78-7

9

80-8

1

82-8

3

84-8

5

86-8

7

88-8

9

90-9

1

92-9

3

94-9

5

96-9

7

98-9

9

00-0

1

02-0

3

04-0

5

06-0

7

Fiscal Year

Bill

ion

s $

Exponential Trend Model Fitted to UC Budget

Page 44: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

44

-1.5

-1.0

-0.5

0.0

0.5

1.0

1.5

0 10 20 30 40

TIME

LN

UC

BU

DB

Page 45: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

45

lnUCBudB(t) = a-hat + b-hat*timelnUCBudB(t) = -0.896566 + 0.0611 *timeExp(-0.896566) = 0.408 B (1968-69) intercept

Page 46: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

46

-0.4

-0.2

0.0

0.2

0.4

-2

-1

0

1

2

70 75 80 85 90 95 00 05

Residual Actual Fitted

Page 47: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

47

Time Series Models

Exponential UCBUD(t) = UCBUD(68-69)*eb*teu(t)

UCBUD(t) = UCBUD(68-69)*eb*t + u(t)

where the estimate of UCBUD(68-69) is the estimated budget for 1968-69

where the estimate of b is the exponential rate of growth

Page 48: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

48

Linear Regression Time Series Models

Linear: UCBUD(t) = a + b*t + e(t)How do we get a linear form for the

exponential model?

Page 49: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

49

Time Series Models

Linear transformation of the exponential take natural logarithms of both sides ln[UCBUD(t)] = ln[UCBUD(68-69)*eb*t + u(t)] where the logarithm of a product is the sum of

logarithms: ln[UCBUD(t)] = ln[UCBUD(68-69)]+ln[eb*t + u(t)] and the logarithm is the inverse function of the

exponential: ln[UCBUD(t)] = ln[UCBUD(68-69)] + b*t + u(t) so ln[UCBUD(68-69)] is the intercept “a”

Page 50: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

50

Naïve Forecasts

Averageforecast next year to be the same as this

year

Page 51: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

51

A Naive Budget Forecast

0

500

1000

1500

2000

2500

3000

3500

4000

68-6

9

71-7

2

74-7

5

77-7

8

80-8

1

83-8

4

86-8

7

89-9

0

92-9

3

95-9

6

98-9

9

01-0

2

Fiscal Year

$ M

illi

on

s

UC Budget

Average

Page 52: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

52

UC Budget Forecasts for 2006-07

Method Increase Forecast

Linear Trend $80.5 M $2,886,707,000

Exponential Trend 6.4% $2,985,047,000*

Same as 2005-06 0 $2,806,207,000

Average 0 $1,603,671,000

* 1.068x$2,806,207,000; exponential trendline forecast ~$4.5 B

Actual:$2,806,207,000 in Governor’s Budget Summary for 05-06

Page 53: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

53

Time Series Forecasts

The best forecast may not be a regression forecast

Time Series Concept: time series(t) = trend + cycle + seasonal + noise(random or error)

fitting just the trend ignores the cycleUCBUD(t) = a + b*t + e(t)

Page 54: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

54

Application of Bivariate Plot

O-Ring FailurePlot zeros (no failure) and the ones (failure)

versus launch temperature for the 24 launches prior to Challenger

Page 55: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

55

O-Ring Failure (yes=1, No=0) Versus Launch Temperature

y = -0.0367x + 2.8583

R2 = 0.3254

-0.2

0

0.2

0.4

0.6

0.8

1

30 40 50 60 70 80 90

Launch Temperatue

Pro

ba

bili

ty

Page 56: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

56

O-Ring Failure (yes=1, No=0) Versus Launch Temperature

y = -0.0367x + 2.8583

R2 = 0.3254

-0.2

0

0.2

0.4

0.6

0.8

1

30 40 50 60 70 80 90

Launch Temperatue

Pro

ba

bili

ty

Linear Approximation to Backward Sigmoid

Page 57: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

57

Ordinary Least Squares

Page 58: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

58

Criterion for Fitting a LineMinimize the sum of the absolute value of

the errors?Minimize the sum of the square of the

errors easier to use

error is the difference between the observed value and the fitted value example UCBUD(observed) - UCBUD(fitted)

)(ˆ)(ˆ tytye

Page 59: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

59

The fitted value:

The fitted value is defined in terms of two parameters, a and b (with hats), that are determined from the data observations, such as to minimize the sum of squared errors

tbaty *ˆˆ)(ˆ

Page 60: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

60

Minimize the Sum of Squared Errors

062005

691968

2

2062005

691968

062005

691968

2

]*ˆˆ)([

])(ˆ)([ˆ

tbaty

tytye

Page 61: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

61

How to Find a-hat and b-hat?

Methodology grid search differential calculus likelihood function

Page 62: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

62

Grid Search, a-hat=0, b-hat=80

FiscalYear

Timeindex

UCBUD y-hat Error-hat

68-69 0 291.3 0 291.3

69-70 1 329.3 80 249.3

70-71 2 335.9 160 175.9

… … … … …

Page 63: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

63

Grid Search

a-hat

-

+

+-0

b-hat

Find the point where the sum of squared errors is minimum

Page 64: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

64

Differential CalculusTake the derivative of the sum of squared errors with

respect to a-hat and with respect to b-hat and set to zero.

Divide by -2*n

or

0]1[]*ˆˆ)([2ˆ/]*ˆˆ)([0605

6968

0605

6968

2

tbatyatbaty

0605

6968

0605

6968

/ˆˆ/)( ntbanty

tbay *ˆˆ

Page 65: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

65

Least Squares Fitted Parameters

So, the regression line goes through the sample means.

Take the other derivative:

divide by -2

0605

6968

0605

8968

2 0]][*ˆˆ)([2ˆ/]*ˆˆ)([ ttbatybtbaty

0605

6968

0605

6968

20605

6968

ˆˆ*)( tbtatty

Page 66: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

66

Ordinary Least Squares(OLS)

Two linear equations in two unknowns, solve for b-hat and a-hat.

Page 67: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

67

Page 68: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

68

O-Ring Failure Versus launch temperature

Page 69: 1 Econ 240A Power 7. 2 This Week, So Far §Normal Distribution §Lab Three: Sampling Distributions §Interval Estimation and Hypothesis Testing

69