#termstru <- read.table("term_stru_norway.txt",header=TRUE,sep=";") termstru <- read.table("../data/norway_term_stru.txt",header=TRUE,sep=";") nrows<-dim(termstru)[1] ncols<-dim(termstru)[2] times<-1:nrows mat<-c(1/250,1/52,2/52,1/12,2/12,3/12,6/12,9/12,1,3,5,10) row<-1 date=as.character(termstru[row,1]); titl= paste("Term structure on", date) filenm = paste(date,"_termstru_Rplot.png",sep="") png(filenm,width=500,height=500); plot(mat,termstru[row,2:ncols],xlab="maturity",ylab="yield",type="l",main=titl,) dev.off() row<-100 date=as.character(termstru[row,1]); titl= paste("Term structure on", date); filenm = paste(date,"_termstru_Rplot.png",sep="") png(filenm,width=500,height=500); plot(mat,termstru[row,2:ncols],xlab="maturity",ylab="yield",type="l") dev.off(); row<-200 date=as.character(termstru[row,1]); titl = paste("Term structure on", date); filenm = paste(date,"_termstru_Rplot.png",sep="") png(filenm,width=500,height=500); plot(mat,termstru[row,2:ncols],xlab="maturity",ylab="yield",type="l") dev.off(); row<-230 date = as.character(termstru[row,1]); titl = paste("Term structure on", date); filenm = paste(date,"_termstru_Rplot.png",sep="") png(filenm,width=500,height=500); plot(mat,termstru[row,2:ncols],xlab="maturity",ylab="yield",type="l") dev.off(); D<-as.Date(as.character(termstru[,1]),"%Y%m%d") ydim=range(termstru[,2:ncols]) png("time_series_Rplot.png",width=800,height=500); plot(D,termstru$NIBOR.T.N.nom,ylab="yield",type="l",ylim=ydim,col="black") lines(D,termstru$NIBOR.6M.nom,col="blue") lines(D,termstru$ST10,col="green") legend("topright", legend=c("O.N.","6M","10Y"), col=c("black","blue","green"), lty=c(1,1,1), lwd=c(1,1,1) ) dev.off(); png("time_series_3dplot_Rplot.png",width=1000,height=500) persp(mat,times,t(termstru[,2:ncols]),ylab="time",xlab="maturity",zlab="yield",theta=60) dev.off(); png("time_series_3dplot_alt_persp_Rplot.png",width=1000,height=500) persp(mat,times,t(termstru[,2:ncols]),ylab="time",xlab="maturity",zlab="yield",theta=-130,phi=5) dev.off();