URL <- "http://ichart.finance.yahoo.com/table.csv?s=^KQ11"
dat <- read.csv(URL)
dat$Date <- as.Date(dat$Date, "%Y-%m-%d")
odat<-dat[c(1:170),]
attach(odat)
x<-odat[order(Date),]
ret <- 0
for (i in 1:length(x$Close)) {
ret[i] <- (x$Close[i]-x$Close[1])/x$Close[1]*100
}
par(mfrow=c(2,1))
par(mar=c(3,3,1,2))
sample.t<-seq(1:length(ret))
sample.v<- ret
plot(sample.t, sample.v, type='l')
lines(sample.t, sample.v, lwd=2, col=heat.colors(32)[15])
## FFT stuff goes in here
##
x<- sample.v
per <- abs(fft(x-mean(x)))^2/length(x) # Mod() and abs() same here
# if you want a nice picture:
freq = (1:length(x)-1)/length(x)
plot(freq, per, xlim=c(0,.2), type='o', lwd=2, col=heat.colors(32)[15])
text(freq, per, round(freq,digits=3), cex=0.6, pos=4, col=heat.colors(32)[15])

댓글 없음:
댓글 쓰기