library(MASS)

ps.options(horizontal=FALSE,onefile=FALSE)
ps.options(pagecentre=TRUE)
ps.options(paper="letter")
ps.options(width=7.0,height=10.0)

dataname <- "stocks_s.dat"
simname  <- "sdf.snp_parms.sim"
plotname <- "sdf.snp_parms.eps"

vnames <- c("date","SP500","NASDAQ")
stocks <- read.table(file=dataname,col.names=vnames)

n <- nrow(stocks)

time <- seq(1,n)

year  <- floor(stocks[,1] / 10000.0)
month <- floor((stocks[,1] - year*10000.0) / 100.0)
day   <- floor((stocks[,1] - year*10000.0 - month*100))

time <- year + month/12.1 + day/310.1

tmp <- scan(simname);

cols <- 2
rows <- length(tmp)/cols
sim <- matrix(tmp,nrow=rows,ncol=cols)

postscript(file=plotname)
par(mfrow=c(3,1),mar=c(2.5,4,1.5,2)+0.1) # mar=c(b,l,t,r)

title <- paste(vnames[2],"vs","time")

plot(time,sim[,1],type="n",ylab="",xlab="",main=title)
  lines(time,sim[,1],lty="solid")

title <- paste(vnames[3],"vs","time")

plot(time,sim[,2],type="n",ylab="",xlab="",main=title)
  lines(time,sim[,2],lty="solid")

title <- paste(vnames[2],"vs",vnames[3])

plot(sim[,1],sim[,2],type="n",ylab="",xlab="",main=title)
  points(sim[,1],sim[,2],pch="o")


dev.off()
