60
1 Power 2 Power 2 Econ 240C Econ 240C

1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

  • View
    221

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

11

Power 2Power 2

Econ 240CEcon 240C

Page 2: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

22

Lab 1 RetrospectiveLab 1 Retrospective

• Exercise:– GDP_CAN = a +b*GDP_CAN(-1) + e– GDP_FRA = a +b*GDP_FRA(-1) + e

Page 3: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

33

Page 4: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

44

Page 5: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

55

Page 6: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

66

Data in ExcelData in ExcelYear GDP_CAN GDP_CAN(-1 C_CAN

1950 13049

1951 13384 13049 1

1952 14036 13384 1

1953 14242 14036 1

Page 7: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

77

StackingStacking

• So for stacking, the data start with 1951

Page 8: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

88

Data in ExcelData in Excelyear GDP_CAN GDP_CAN(-1) C_CAN

1989 17758 17394 1

1990 17308 17758 1

1991 16444 17308 1

1992 16413 16444 1

Page 9: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

99

StackingStacking• So the dependent variable starts with

gdp_can(1951) and goes through gdp_can(1992). Then the next value in the stack is gdp_fra(1951) and the data continues ending with gdp_fra(1992).

• The independent variable for Canada starts with gdp_can(1950) and goes through gdp_can(1991). Then the rest of the stack is 42 zeros

Page 10: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

1010

StackingStacking• The independent variable for France starts

with a stack of 42 zeros. Then the next observation is gdp_fra(1950), the following is gdp_fra(1951) etc. ending with gdp_fra(1991)

• The constant stack for Canada is 42 ones followed by 42 zeros

• The constant term for France is 42 zeros followed by 42 ones

Page 11: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

1111

Page 12: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

1212

Page 13: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

1313

OutlineOutline

• Time Series Concepts– Inertial models– Conceptual time series components– Simulation and synthesis– Simulated white noise, wn(t)– Spreadsheet, trace, and histogram of wn(t)– Independence of wn(t)

Page 14: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

1414

Univariate Time Series ConceptsUnivariate Time Series Concepts

• Inertial models: Predicting the future from own past behavior– Example: trend models– Other example: autoregressive moving

average (ARMA) models– Assumption: underlying structure and forces

have not changed

Page 15: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

1515Conceptual time series Conceptual time series

components modelcomponents model

• Time series = trend + seasonal + cycle + random

• Example: linear trend model– Y(t) = a + b*t + e(t)

• Example linear trend with seasonal– Y(t) = a + b*t + c1*Q1(t) + c2*Q2(t) + c3*Q3(t) + e(t)

Page 16: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

1616

How to model the cycle?How to model the cycle?• We have learned how to model:

– Trend: linear and exponential– Seasonality: dummy variables– Error: e.g. autoregressive

• How do you model the cyclical component?

Page 17: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

1717

Cyclical time series behaviorCyclical time series behavior

• Many economic time series vary with the business cycle

• Model the cycle using ARMA models

• That is what the first half of 240C is all about

Page 18: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

1818

Simulation and SynthesisSimulation and Synthesis

• Build ARMA models from noise, white noise, in a process called synthesis

• The idea is to start with a time series of simple structure, and build ARMA models by transforming white noise

Page 19: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

1919

Simulated white noiseSimulated white noise

• Generate a sequence of values drawn from a normal distribution with mean zero and variance one, i.e. N(0, 1)

• In EViews: Gen wn = nrnd

Page 20: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

2020The first ten values of simulated white noise, wn(t)

Value draw = time index-0.628093683959 1-0.627803051549 20.00723255412415 31.94192735344 4-1.10119663665 50.514236967572 6-0.843129585702 7-0.0153352207678 81.25353192311 91.48589824393 10

Page 21: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

2121

Trace (plot) of first 100 values of wn(t)Trace (plot) of first 100 values of wn(t)

No obvious timeDependence, i.e.Stationary, notTrended, notseasonal

Page 22: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

2222

Histogram and Statistics, 1000 Obs.Histogram and Statistics, 1000 Obs.

Page 23: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

2323

IndependenceIndependence• We know each drawn value is from the

same distribution, i.e. N(0,1)

• We know every value drawn is independent from all other values

• So wn(t) should be iid, independent and identically distributed

Page 24: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

2424

Independence: conceptualIndependence: conceptual• Suppose the mean series, m(t), of white

noise is zero, i.e. E wn(t) = m(t) = 0

• This is a good suppose because every generated value has expectation zero since it is from N(0,1)

• Then E[wn(t)*wn(t-1)] = 0, i.e. a value is independent from the previous or lagged value

Page 25: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

2525

Independence: conceptualIndependence: conceptual• In general: cov [wn(t)*wn(t-u)], where wn(t-u)

is lagged u periods from t is defined as cov[wn(t)*wn(t-u)] = E{[wn(t) – Ewn(t)]*[wn(t-u) – Ewn(t-u)]} = E [wn(t)*wn(t-u)], since E wn(t) = 0

• This is called the autocovarince, i.e. the covariance of white noise with lagged values of itself

Page 26: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

2626

Independence: ConceptualIndependence: Conceptual• For every value of lag except zero, the

autocovarince function of white noise is zero by independence

• At lag zero, the autocovariance of white noise is just its variance, equal to one cov [wn(t)*wn(t)] = E[wn(t)*wn(t)] =1

Page 27: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

2727

Independence: ConceptualIndependence: Conceptual• the autocovariance function can be

standardized, i,e, made free of units or scale, by dividing by the variance to obtain the autocorrelation function, symbolized for wn(t) by wn, wn (u) = cov [wn(t)*wn(t-u)/Var wn(t)

• In general, the autocorrelation function for a time series depends both on time, t, and lag, u. However, for stationary time series it depends only on lag.

Page 28: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

2828Theoretical Autocorrelation Theoretical Autocorrelation

Function: White NoiseFunction: White Noise

Theoretical Autocorrelation Function: White Noise

0

0.2

0.4

0.6

0.8

1

1.2

0 1 2 3 4 5 6 7 8

Lag

Rh

o

Page 29: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

2929What use is the autocorrelation What use is the autocorrelation

function in practice?function in practice?

• Estimated Autocorrelations in EViews

Page 30: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

3030

Page 31: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

3131

1000 observations ofWhite Noise

Page 32: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

3232

AnalysisAnalysis

• Breaking down the structure of an observed time series, i.e. modeling it

• Example: weekly closing price of gold, Handy & Harmon, $ per ounce

Page 33: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

3333

PRICE OF GOLDPRICE OF GOLDDate Week Price

4/16/04 0 $400.85

4/23/04 1 $394.50

4/30/04 2 $388.50

5/07/04 3 $380.80

5/13/04 4 $376.50

5/20/04 5 $385.30

Page 34: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

3434

Weekly Closing Price of Gold, Handy & Harmon, April 16, '04-March 24, '05

370

380

390

400

410

420

430

440

450

460

0 10 20 30 40 50 60

Week

$/o

z

Page 35: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

3535

Page 36: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

3636

Price of gold doesNot look like white noise

Page 37: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

3737

What now?What now?

• How about week to week changes in the price of gold?

• In EViews: Gen dgold = gold –gold(-1)

Page 38: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

3838

Page 39: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

3939

Page 40: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

4040

Page 41: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

4141

Page 42: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

4242

Changes in the price of goldChanges in the price of gold

• If changes in the price of gold are not significantly different from white noise, then we have a use for our white noise model: dgold(t) = c + wn(t)

• Ignore the constant for the moment

• What sort of time series is the price of gold?

Page 43: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

4343

The price of goldThe price of gold

• dgold(t) = gold(t) – gold(t-1) = wn(t)

• i.e. gold(t) = gold(t-1) + wn(t)

• Lag by one: dgold(t-1) = gold(t-1) – gold(t-2) =wn(t-1)

• i.e., gold (t-1) = gold(t-2) + wn (t-1), so gold(t) = wn(t) + wn(t-1)+ gold(t-2)

Page 44: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

4444

The price of goldThe price of gold• Keep lagging and substituting, and

• gold(t) = wn(t) + wn(t-1) + wn(t-2) + ….

• i.e. the price of gold is the current shock, wn(t), plus last week’s shock, wn(t-1), plus the shock from the week before that, wn(t-2) etc.

• These shocks are also called innovations

Page 45: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

4545

The price of goldThe price of gold• This time series for gold, i.e. the sum of

current and previous shocks is called a random walk, rw(t)

• So rw(t) = wn(t) + wn(t-1) + wn(t-2) + …

• Lagging by one:

• rw(t-1) = wn(t-1) + wn(t-2) + wn(t-3) + …

• So drw(t) = rw(t) –rw(t-1) = wn(t)

Page 46: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

4646

The first difference of a random walkThe first difference of a random walk

• The first difference of a random walk is white noise

Page 47: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

4747

Random walk plus trendRandom walk plus trend• If the price of gold is trend plus a random

walk: gold(t) = a + b*t + rw(t), it is said to be a random walk with drift

• Lagging by one, gold(t-1) = a + b*(t-1) + rw(t-1)

• And subtracting, dgold(t) = b + drw(t), i.e.

• dgold(t) = constant + white noise

Page 48: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

4848

The time series is too short for the constantTo be significant

Page 49: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

4949

Simulated Random walkSimulated Random walk

• EViews, sample 1 1, gen rw = wn

• Sample 2 1000, gen rw = rw(-1) + wn

Page 50: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

5050

Simulated random walkSimulated random walktime White noise Random walk

1 -0.628094 -0.628094

2 -0.627803 -1.255897

3 0.007233 -1.248664

4 1.941927 0.693263

Page 51: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

5151

-40

-30

-20

-10

0

10

20

30

200 400 600 800 1000

RW WN

Page 52: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

5252

Page 53: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

5353

Page 54: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

5454

Random walkRandom walk

• Is a random walk evolutionary or stationary?

Page 55: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

5555

Random walkRandom walk

• Mean function for a random walk, m(t)

• m(t) = E[rw(t)] = E[ wn(t) +wn(t-1) + …]

• m(t) = 0 + 0 + 0 ….= 0

Page 56: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

5656

Variance of an infinite rw(t)Variance of an infinite rw(t)

• Var[rw(t)] = E[rw(t)*rw(t)]

• Var[rw(t)] =E{[wn(t) + wn(t-1) + wn(t-2) …]*[wn(t) + wn(t-1) + wn(t-2) ….]

• Var rw(t) = ∞

• So the variance of an infinitely long random walk is not bounded, but infinite, and a random walk can go wandering off.

Page 57: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

5757

Random walk modelRandom walk model

• The price of gold is bounded below by zero and is not likely to go wandering off to infinity either, so the random walk model is an approximation for the price of gold.

Page 58: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

5858

QuestionQuestion• What does the autocovariance function of

an infinite random walk look like plotted against lag?

lag0

rw, rw

Page 59: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

5959

Recall the autocorrelation functionFor a finite sample of a simulatedRandom walk decays slowly

Page 60: 1 Power 2 Econ 240C. 2 Lab 1 Retrospective Exercise: –GDP_CAN = a +b*GDP_CAN(-1) + e –GDP_FRA = a +b*GDP_FRA(-1) + e

6060

SummarySummary• We are now familiar with two time series,

white noise and random walks• We have looked at the theoretical

autocorrelation functions, or are in the process of doing so.

• We have simulated sample of both and looked at their empirically estimated autocorrelation functions, benchmarks for identification