[R-SIG-Finance] Cross correlation problems

Rob Schmidt roschm at ymail.com
Fri Apr 5 15:30:06 CEST 2013


And here is the way that a non-newbie would approach the problem.  (Thanks to
Brian who must be taking pity on us, LOL)

library(quantmod)
symbols <- c("SPY","ILF","EWZ","IBM")
initDate <- "2010-01-01"
getSymbols(symbols,from=initDate)
rets <- xts(do.call(cbind.xts,
                    lapply(symbols,function(sym)
                        dailyReturn(get(sym)))),
            order.by=as.Date(index(get(symbols[1]))))
colnames(rets) <- symbols
print(round(cor(df),2))




--
View this message in context: http://r.789695.n4.nabble.com/Cross-correlation-problems-tp4663151p4663425.html
Sent from the Rmetrics mailing list archive at Nabble.com.



More information about the R-SIG-Finance mailing list