You are on page 1of 13

 

Financial  Econometrics  Homework  1  


Dr.  Cai  
Wenbo  Zhang  
FINN  6219   Homework  1   Wenbo  Zhang  
 

1.  Download  weekly  price  data  for  IBM  and  Microsoft  stock.  


IBM  (P1t)  01/02/62  –  01/15/08  
MSFT(P2t)  03/13/86  –  01/15/08  
 
a) Create    a    time    series    of    continuously    compounded    weekly    returns    for    IBM    and  
Microsoft.  
   
Use  the  equation:   ,  we  can  get  the  returns  series.  
b) Use   the   constructed   weekly   returns   to   construct   a   series   of   monthly   returns.   You  
may  assume  for  simplicity  that  one  month  consists  of  four  weeks.  
t =4(k −1)+4
Use   the   equation:   mi,k = ∑ r , where i = 1,2, k = 1,2,3,   ,   we   can   get   the  
t =4(k −1)+1 i,t

returns  series.  
c) Construct  a  graph  of  stock  price  series  (P1t,  P2t)  and  returns  series  (r1t,  r2t).  

600

150
500
400

100
p2t
p1t

300
200

50
100

0 500 1000 1500 2000 0 200 400 600 800 1000

Time Time
   

2  
 
FINN  6219   Homework  1   Wenbo  Zhang  
 

0.6
1.0

0.4
r2t
r1t

0.2
0.5

0.0
0.0

-0.2
0 500 1000 1500 2000 0 200 400 600 800 1000

Time Time
 
d) Compute   and   graph   the   rolling   estimates   of   the   sample   mean   and   variance   for   stock  
prices  and  returns.  In  computation  of  rolling  estimates,  you  may  use  the  last  quarter  
of  data.  
160
600

140
500

120
400

100
p1rm

p2rm
300

80
200

60
40
100

20

0 500 1000 1500 2000 0 200 400 600 800 1000

Time Time
 

3  
 
FINN  6219   Homework  1   Wenbo  Zhang  
 

20000

1500
15000

1000
p1rv

p2rv
10000

500
5000
0

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

Time Time
       

0.08
0.06
0.10

0.04
0.02
0.05

r2rm
r1rm

0.00
-0.02
0.00

-0.04
-0.06

0 500 1000 1500 2000 0 200 400 600 800 1000

Time Time
 

4  
 
FINN  6219   Homework  1   Wenbo  Zhang  
 

0.15

0.04
0.03
0.10

r2rv
r1rv

0.02
0.05

0.01
0.00
0.00

0 500 1000 1500 2000 0 200 400 600 800 1000

Time Time
 
e) What   is   the   definition   of   a   stationary   stochastic   process?   Do   prices   look   like  
stationary  process?  Why?  Do  returns  look  like  a  stationary  process?  Why?  
 
Definition   of   a   stationary   stochastic   process:   In   the   mathematical   sciences,   a  
stationary  process  is  a  stochastic  process  whose  joint  probability  distribution  does  
not  change  when  shifted  in  time  or  space.  As  a  result,  parameters  such  as  the  mean  
and  variance,  if  they  exist,  also  do  not  change  over  time  or  position.  As  an  example,  
white  noise  is  stationary.  
From  the  observation  of  the  graphs  above,  prices  for  both  stocks  are  not  stationary  
process   since   the   rolling   mean   is   changing   over   time   and   rolling   variance   includes  
several  high  values.  
However,   the   rolling   mean   of   return   processes   doesn’t   appear   any   obvious   trend  
over  time.  But  the  big  numbers  in  variance  determine  that  return  processes  are  not  
stationary  either.  
f) Compute  autocorrelation  coefficients  ρk  for  1≤k≤5  for  prices  and  returns  series.  

P1t
[,1]
[1,] 1.0000000
[2,] 0.9952586
[3,] 0.9905095
[4,] 0.9856203
[5,] 0.9807094
[6,] 0.9760011

5  
 
FINN  6219   Homework  1   Wenbo  Zhang  
 

P2t
[,1]
[1,] 1.0000000
[2,] 0.9808425
[3,] 0.9619482
[4,] 0.9441063
[5,] 0.9262671
[6,] 0.9107144
r1t
[,1]
[1,] 1.000000000
[2,] -0.003720422
[3,] 0.020920001
[4,] 0.015134049
[5,] -0.035417986
[6,] -0.063093877

r2t
[,1]
[1,] 1.000000000
[2,] -0.002964954
[3,] -0.012364290
[4,] 0.015955982
[5,] -0.024635205
[6,] -0.060960500

Series p1t Series p2t


1.0

1.0
0.8
0.8

0.6
0.6
ACF

ACF

0.4
0.4

0.2
0.2

0.0
0.0

0 1 2 3 4 5 0 1 2 3 4 5

Lag Lag
 

6  
 
FINN  6219   Homework  1   Wenbo  Zhang  
 

Series r2t
Series r1t

1.0
1.0

0.8
0.8

0.6
0.6

ACF
ACF

0.4
0.4

0.2
0.2

0.0
0.0

0 1 2 3 4 5 0 1 2 3 4 5

Lag Lag
 
g) Based  on  the  computed  autocorrelations  for  IBM  and  MSFT  stock  prices  and  returns,  
what   can   you   say   about   correlation   between   stock   prices   for   different   days?   What  
can  you  say  about  correlation  between  stock  returns  for  different  days?  
 
From  the  graph  in  (f),  we  can  see  that  the  stock  prices  series  are  highly  correlated,  
since   the   correlation   coefficients   are   very   close   to   1.   So,   the   correlation   between  
stock  prices  for  different  days  is  very  strong.  But,  the  stock  returns  series  are  weakly  
correlated,  since  the  correlation  coefficients  are  very  close  to  0.  So,  the  correlation  
between  stock  returns  for  different  days  is  very  weak.  

h) Using  your  stock  returns  for  IBM  and  MSFT,  rit,  i  =  1,  2,  construct  four  more  series  yit  
=  |rit|λ,  i  =  1,  2  and  λ  =  1,  2.  Compute  autocorrelation  coefficients  ρk  for  1≤k≤5  for  the  
newly  constructed  series.  Compare  the  computed  correlations  for  |rit|λ,  λ  =  1,  2,  and  
|rit|.  Are  results  as  you  expected?  

7  
 
FINN  6219   Homework  1   Wenbo  Zhang  
 

Series absr1t Series absr2t

1.0
1.0

0.8
0.8

0.6
0.6

ACF
ACF

0.4
0.4

0.2
0.2

0.0
0.0

0 1 2 3 4 5 0 1 2 3 4 5

Lag Lag
 
Series absqr1t Series absqr2t
1.0

1.0
0.8

0.8
0.6
0.6
ACF

ACF

0.4
0.4

0.2
0.2

0.0
0.0

0 1 2 3 4 5 0 1 2 3 4 5

Lag Lag
 
The  results  are  as  expected.  
 
i) Use  the  Jarque-­‐Bera  test  (see  Jarque  and  Bera  (1980,  1987))  to  test  the  assumption  
of  return  normality  for  IBM  and  MSFT  stock  returns.  
 
  Jarque  Bera  Test  
 
data:    r1t    
X-­‐squared  =  6966470,  df  =  2,  p-­‐value  <  2.2e-­‐16  
 
  Jarque  Bera  Test  
 
data:    r2t    
X-­‐squared  =  77214.5,  df  =  2,  p-­‐value  <  2.2e-­‐16  
 

8  
 
FINN  6219   Homework  1   Wenbo  Zhang  
 

 
 

2.  Use  R  program  to  estimate  the  probability  density  function  of  standardized  IBM  and  
MSFT  stock  returns.  
(a)   Estimate   and   construct   a   graph   of   the   estimated   probability   density   function   for   IBM  
and  MSFT  stock  returns.  
0.6
0.4
0.2
0.0

-3 -2 -1 0 1 2 3

9  
 
FINN  6219   Homework  1   Wenbo  Zhang  
 

(b)   On   the   same   graph   with   the   empirical   density,   construct   a   graph   of   the   standard  
normal  density  function.  Comment  your  results.  

0.6
0.4
0.2
0.0

-3 -2 -1 0 1 2 3

Compared  to  the  standard  normal  distribution,  which  is  the  green  curve  in  this  
graph,  the  two  empirical  distributions  have  a  higher  peak  and  heavy-­‐tail,  which  is  
normal  according  to  the  textbook.  

10  
 
FINN  6219   Homework  1   Wenbo  Zhang  
 

(c)  Construct  QQ-­‐plot  for  standardized  IBM  and  MSFT  returns.  You  may  use  the  R  
command  for  this.  Comment  your  results.  

Normal Q-Q Plot

25
20
Sample Quantiles

15
10
5
0

-3 -2 -1 0 1 2 3

Theoretical Quantiles

Normal Q-Q Plot


10
8
6
Sample Quantiles

4
2
0
-2

-3 -2 -1 0 1 2 3

Theoretical Quantiles
 
According  to  the  two  QQplot  graphs  above,  it’s  only  similar  to  standard  normal  
distribution  from  -­‐2  to  1.5  for  IBM  stock  return.  And  it’s  -­‐1.5  to  1.5  for  MSFT  stock  
return.  

11  
 
FINN  6219   Homework  1   Wenbo  Zhang  
 

R  codes  
Problem  1  
 
library(fTrading)
library(tseries)
IBM=read.csv(file="/Users/brianzwb/Documents/Financial
Econometrics/IBM.csv",header=T,skip=1)
MSFT=read.csv(file="/Users/brianzwb/Documents/Financial
Econometrics/MSFT.csv",header=T,skip=1)
IBMprice=IBM[,5]
IBMreturn=diff(log(IBMprice))
MSFTprice=MSFT[,5]
MSFTreturn=diff(log(MSFTprice))
MSFTreturn

r1t=IBMreturn
r2t=MSFTreturn
dim(r1t)=c(4,length(r1t)/4)
monthly1=colSums(r1t)
r1t=IBMreturn
dim(r2t)=c(4,length(r2t)/4)
r2t=r2t[1:1136]
dim(r2t)=c(4,length(r2t)/4)
monthly2=colSums(r2t)
r2t=MSFTreturn

p1t=IBMprice
p2t=MSFTprice
ts.plot(p1t)
ts.plot(p2t)
ts.plot(r1t)
ts.plot(r2t)

p1rm=rollMean(p1t,13)
p1rv=rollVar(p1t,13)
p2rm=rollMean(p2t,13)
p2rv=rollVar(p2t,13)
r1rm=rollMean(r1t,13)
r1rv=rollVar(r1t,13)
r2rm=rollMean(r2t,13)
r2rv=rollVar(r2t,13)
ts.plot(p1rm)
ts.plot(p2rm)
ts.plot(p1rv)
ts.plot(p2rv)
ts.plot(t1rm)

12  
 
FINN  6219   Homework  1   Wenbo  Zhang  
 

ts.plot(r1rm)
ts.plot(r2rm)
ts.plot(r1rv)
ts.plot(r2rv)

acf(p1t,5)$acf
acf(p2t,5)$acf
acf(r1t,5)$acf
acf(r2t,5)$acf

absr1t=abs(r1t)
absr2t=abs(r2t)
absqr1t=r1t^2
absqr2t=r2t^2
acf(absr1t)$acf
acf(absr1t,5)$acf
acf(absr2t,5)$acf
acf(absqr1t,5)$acf
acf(absqr2t,5)$acf

jarque.bera.test(r1t)
jarque.bera.test(r2t)

Problem  2  
 
d1={r1t-mean(r1t)}/sd(r1t)
d2={r2t-mean(r2t)}/sd(r2t)

x0=seq(-3,3,length=100)

y0=density(d1,n=100,from=-3,to=3)
y1=y0$y
qqnorm(d1)
qqline(d1,col=2)

y2=density(d2,n=100,from=-3,to=3)
y3=y2$y
qqnorm(d2)
qqline(d2,col=2)

matplot(x0,cbind(y1,y3),type="l",lty=1:3,xlab="",ylab="")
matplot(x0,cbind(y1,y3,dnorm(x0)),type="l",lty=c(1,2),xlab="",ylab="")

13  
 

You might also like