Professional Documents
Culture Documents
0.1
0.0
0.2
ibm
0.2
0.3
data=read.table("m-ibm6708.txt",header=T)
ibm=data$ibm
sp=data$sprtn
plot(sp,ibm)
0.2
0.1
0.0
sp
cor(ibm,sp,method="pearson")
## [1] 0.5949041
cor(sp,ibm,method="kendall")
## [1] 0.4223351
1
0.1
0.05
0.15
rtn
0.05
0.15
2004
2006
2008
2010
year
2012
2014
50
Frequency
Percentage returns
15
10
percentage
d1<-density(percentage)
plot(d1$x,d1$y,xlab='returns',ylab='den',type='l',main="Density")
10
15
0.10
0.00
0.05
den
0.15
0.20
Density
20
15
10
returns
data1<-read.table("m-tb3ms.txt",header=T)
data2<-read.table("m-tb6ms.txt",header=T)
dim(data1);dim(data2)# unequal time frame
## [1] 914
## [1] 615
914-615 #difference
## [1] 299
window=cbind(data1[300:914,4],data2[,4]) # Window from 299 + 1
index=(c(1:dim(data2)[1])+11)/12+1959 # start from 1958 Dec
plot(index,window[,1],xlab='year',ylab='rate',type='l')
lines(index,window[,2],lty=2) # Plot the 6m-TB rate on the same frame
10
15
15
10
0
rate
1960
1970
1980
1990
2000
year
plot(index,window[,2]-window[,1],xlab='year',ylab='spread',type='l')
abline(h=c(0),col=2)
2010
1.5
1.0
0.5
0.0
1.0
0.5
spread
1960
1970
1980
1990
year
data=read.table("q-ko-earns8309.txt",header=T)
index=c(1:dim(data)[1])/12+1983
plot(index,data[,3],xlab='year',ylab='earnings',type='l')
title(main='EPS of Coca Cola: 1983-2009')
points(index,data[,3])
2000
2010
0.6
0.4
0.0
0.2
earnings
0.8
1.0
1984
1986
1988
1990
year
1992
1.2
0.8
1.0
eu
1.4
1.6
2000
2002
2004
2006
2008
year
2010
2012
0.00
0.02
rtn
0.02
0.04
lnrtn: USEU
2000
2002
2004
2006
year
10
2008
2010
2012
Frequency
0.02
0.00
0.02
0.04
logrt
Reference:
Tsay, Ruey S. Analysis of financial time series. Vol. 543. John
Wiley & Sons, 2005.
11