/ Published in: R

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
fw20 <- read.csv("fw20_d.csv") esf <- read.csv("es_f_d.csv") nrow(fw20); nrow(esf) D_Change <- log(esf$Close[-1]/esf$Close[-nrow(esf)]) esfc <- cbind(esf[2:nrow(esf),],D_Change) D_Change <- log(fw20$Close[-1]/fw20$Close[-nrow(fw20)]) OC_Change <- log(fw20$Close/fw20$Open)[2:nrow(fw20)] fw20c <- cbind(fw20[2:nrow(fw20),],D_Change,OC_Change) dates <- function(x) { strptime(x$Date,"%Y-%m-%d") } fw20c <- fw20c[which(!is.na(match(as.numeric(dates(fw20c))-86400,as.numeric(dates(esfc))))),] esfc <- esfc[which(!is.na(match(as.numeric(dates(esfc))+86400,as.numeric(dates(fw20c))))),] nrow(fw20c); nrow(esfc) fw20c[1:10,] esfc[1:10,] cor(esfc$D_Change,fw20c$D_Change) cor(esfc$D_Change,fw20c$OC_Change) cor(fw20c$D_Change,fw20c$OC_Change)
URL: http://www.reakkt.com/2011/10/correlation-doesnt-mean-easy-prediction.html
Comments
