[R-SIG-Finance] Cross correlation problems

Rob Schmidt roschm at ymail.com
Sat Apr 6 14:24:54 CEST 2013


Hi wlblount,

I'm sorry, I think my poor explanation might be  misleading you.  I'm good
at that.   I don't think it is the total data length, rather that each
column has to match the others in the data frame.  (That's another thing
that using the xts object solves for us.)  My cheesy solution of shortening
the columns was to attempt to just make the columns match by getting rid of
missing data, etc.  Here is the five sized example showing the column
lengths not matching.

Best regards,

Rob

library(quantmod)

sym1 <- "SPY"
sym2 <- "ILF"
sym3 <- "EWZ"
sym4 <- "DIA"  
sym5 <- "EPP"
initDate <- "2010-01-01"
getSymbols(sym1,from=initDate)
getSymbols(sym2,from=initDate)
getSymbols(sym3,from=initDate)
getSymbols(sym4,from=initDate)
getSymbols(sym5,from=initDate)
print(length(get(sym1)))
print(length(get(sym2)))
print(length(get(sym3)))
print(length(get(sym4)))
print(length(get(sym5)))

df <- data.frame( dailyReturn(get(sym1)), dailyReturn(get(sym2)),
                  dailyReturn(get(sym3)), dailyReturn(get(sym4)),
                        dailyReturn(get(sym5)))
names(df) <- c(sym1,sym2,sym3,sym4,sym5)
print(round(cor(df),2))




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



More information about the R-SIG-Finance mailing list