1 econ 240a power 7. 2 this week, so far §normal distribution §lab three: sampling distributions...
Post on 19-Dec-2015
213 views
TRANSCRIPT
1
Econ 240A
Power 7
2
This Week, So Far
Normal DistributionLab Three: Sampling DistributionsInterval Estimation and Hypothesis Testing
3
Outline
Distribution of the sample varianceThe California Budget: Exploratory Data
AnalysisTrend ModelsLinear Regression ModelsOrdinary Least Squares
4
PopulationRandom variable xDistribution f(f ?
Sample
Sample Statistic:
),(~ 2Nx
Sample Statistic
)1/()( 2
1
2
nxxsn
ii
Pop.
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(
6
TextChi-SquaredDistribution
7
TextChi-SquaredTable 5Appendixp. B-10
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
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
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
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
12
13
The UC Budget
14
The UC Budget
The part of the UC Budget funded by the state from the general fund
15
16
17
Total General Fund ExpendituresAppendix, p.11Schedule 6
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
19
UC General Fund Expenditures, Appendix p. 46
20
21
22
23
24
25
26
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 $
28
How to Forecast the UC Budget?
Linear Trendline?
29
Trend Models
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 $
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 $
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 $
33
Linear Regression Trend Models
A good fit over the years of the data sample may not give a good forecast
34
How to Forecast the UC Budget?
Linear trendline?Exponential trendline ?
35
36
Trend Models
37
An Application
38
39
Time Series Trend Analysis
Two Steps Select a trend model Fit the trend model
• Graphically
• algebraically
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
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 $
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
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
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
45
lnUCBudB(t) = a-hat + b-hat*timelnUCBudB(t) = -0.896566 + 0.0611 *timeExp(-0.896566) = 0.408 B (1968-69) intercept
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
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
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?
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”
50
Naïve Forecasts
Averageforecast next year to be the same as this
year
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
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
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)
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
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
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
57
Ordinary Least Squares
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
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 *ˆˆ)(ˆ
60
Minimize the Sum of Squared Errors
062005
691968
2
2062005
691968
062005
691968
2
]*ˆˆ)([
])(ˆ)([ˆ
tbaty
tytye
61
How to Find a-hat and b-hat?
Methodology grid search differential calculus likelihood function
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
… … … … …
63
Grid Search
a-hat
-
+
+-0
b-hat
Find the point where the sum of squared errors is minimum
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 *ˆˆ
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
66
Ordinary Least Squares(OLS)
Two linear equations in two unknowns, solve for b-hat and a-hat.
67
68
O-Ring Failure Versus launch temperature
69