You are on page 1of 7

THE UNIVERSITY OF CHICAGO

Booth School of Business


Multivariate Time Series Analysis, Mr. Ruey S. Tsay

Introduction

Examples of time series used in the lecture. Data can be found on the web at
faculty.chicagobooth.edu/ruey.tsay/teaching/mts/sp2009

1. The monthly unemployment rate of three states in the midwest, namely, Illinois, Michigan
and Ohio.

2. U.S. quarterly GDP and unemployment rate

3. Quaterly data of West Germany, investiment, income and consumption. The data is from
Lutkepohl (2005).

4. Monthly returns of Decile 1 and Decile 9 portfolios of U.S. stock market.

5. Monthly AAA and BAA bond yields of Moody.

6. Monthly US housing series (housing starts and houses sold)

R commands used
% denotes explanation.

%%%% Obtain time series plot using R


> setwd("C:/Users/rst/teaching/mts/sp2009") %set working directory
> da=read.table("m-3state-un.txt",header=T) % load data
> dim(da)
[1] 407 6
> da[1,]
Year Mon Day IL MI OH
1 1976 1 1 6.4 9.8 8.2
> x=da[,4:6]
> un=ts(x,frequency=12,start=c(1976,1)) %create a ts object
> plot(un,type=l) %time-plot

> da=read.table("q-gdpun.txt")
> dim(da)
[1] 228 5
> da[1,]
V1 V2 V3 V4 V5
1 1948 1 1 7.3878 3.7333
> gdpun=ts(da[,4:5],frequency=4,start=c(1948,1))
Figure 1: State unemployment rates: 1976-2009

un

12
10
IL
8
6
14 4 6 8 10 12 14 16 4
MI
12
10
OH
8
6
4

1975 1980 1985 1990 1995 2000 2005 2010

Time

> colnames(gdpun) <- c("gdp","unem")


> plot(gdpun,type=l)

> da=read.table("de-inv.txt",header=T)
> da[1,]
inv income cons
1 180 451 415
> dim(da)
[1] 92 3
> de=ts(da,frequency=4,start=c(1960,1))
> plot(de,type=l)
>
> da=read.table("m-dec19.txt",header=T)
> da[1,]
Date dec1 dec9
1 19700130 0.05438 -0.07308
> decile=ts(da[,2:3],frequency=12,start=c(1970,1))
> plot(decile,type=l)
> acf(decile[,1],lag=36)
> par(mfcol=c(2,1))
> acf(decile[,1],lag=36)
> acf(decile[,2],lag=36)

R commands used continue.

2
%%% More commands used
> da=read.table("gasfur.dat")
> gas=da[,1]
> co2=da[,2]
> dim(da)
> par(mfcol=c(2,1))
> plot(gas,type=l)
> plot(co2,type=l)
> m1=ar(gas)
> names(m1)
[1] "order" "ar" "var.pred" "x.mean" "aic" "n.used" "order.max"
[8] "partialacf" "resid" "method" "series" "frequency" "call" "asy.var.coef"
> m1$order
[1] 14 <== seems too high
> acf(gas)
> pacf(gas) <== Indicates an AR(3) model.
> m1=arima(gas,order=c(3,0,0))
> m1

Call:
arima(x = gas, order = c(3, 0, 0))

Coefficients:
ar1 ar2 ar3 intercept
1.9691 -1.3651 0.3394 -0.0606
s.e. 0.0544 0.0985 0.0543 0.1898

sigma^2 estimated as 0.03530: log likelihood = 72.57, aic = -135.14


> f1=c(1,-m1$coef[1:3]) <== construct the filter.
> f1
ar1 ar2 ar3
1.0000000 -1.9690658 1.3651431 -0.3394045

> co2f=filter(co2,f1,method=c("convo"),sides=1) <== Filter y-series


> yf=co2f[4:296] <=== Start at t=4, because of the AR(3) model used in filtering.
> xf=m1$residuals[4:296]
>
> source("ccm.R") <== Load the CCM command.
> ccm(da,20)
[1] "Covariance matrix:"
V1 V2
V1 1.15 -1.66
V2 -1.66 10.25
[1] "CCM at lag:" "0"
[,1] [,2]

3
[1,] 1.000 -0.484
[2,] -0.484 1.000

> z=cbind(xf,yf) <== Combine filtered series.


> ccm(z,20)
[1] "Covariance matrix:"
xf yf
xf 0.035737 -0.000229
yf -0.000229 0.132980
[1] "CCM at lag:" "0"
[,1] [,2]
[1,] 1.00000 -0.00332
[2,] -0.00332 1.00000
>
> source("tfm.R")
> m2=tfm(co2,gas,3,4,1)
[1] "ARMA coefficients & s.e."
ar1
coef.arma 0.9730
se.arma 0.0175
[1] "Transfer function coefficients & s.e."
intercept X
v 53.73 -0.4845 -0.637 -0.839 -0.428 -0.378
se.v 0.62 0.0929 0.130 0.132 0.130 0.093
> acf(m2$residuals) <=== Indicates the model is not adequate.
> names(m2)
[1] "coef" "se.coef" "coef.arma" "se.arma" "nt" "residuals"

> acf(m2$nt)
> pacf(m2$nt) <== Indicates an AR(2) model for Nt series.

> m2=tfm(co2,gas,3,4,2)
[1] "ARMA coefficients & s.e."
ar1 ar2
coef.arma 1.5379 -0.6291
se.arma 0.0470 0.0509
[1] "Transfer function coefficients & s.e."
intercept X
v 53.376 -0.5558 -0.6445 -0.860 -0.484 -0.3633
se.v 0.155 0.0778 0.0812 0.081 0.081 0.0773
> acf(m2$residuals)

4
Figure 2: U.S. bond yields

Monthly: AAA bond


4 6 8 10 12 14
yield

1960 1970 1980 1990 2000


year

Monthly: BAA bond


4 6 8 10121416
yield

1960 1970 1980 1990 2000


year

Figure 3: U.S. GDP and unemployment rate

gdpun
9.0
8.5
gdp

8.0
10 7.5
8
unem

6
4

1950 1960 1970 1980 1990 2000

Time

5
Figure 4: Investment, Income and Consumption of West Germany

cons income inv


500 1000 1500 2000 500 1000 1500 2000 2500 200 400 600 800

1960
1965
1970
de

Time
1975
1980 Figure 5: Deciles 1 and 9 returns

dec9 dec1

0.2 0.0 0.1 0.2 0.2 0.0 0.2 0.4


1970
1980

Time
decile

1990
2000

6
Figure 6: ACF of Deciles 1 and 9 returns

Series decile[, 1]
0.0 0.4 0.8
ACF

0.0 0.5 1.0 1.5 2.0 2.5 3.0

Lag

Series decile[, 2]
0.0 0.4 0.8
ACF

0.0 0.5 1.0 1.5 2.0 2.5 3.0

Lag

You might also like