if (FALSE) {
library(quantmod)
prices.spy <- getSymbols("SPY", from="2013-01-01", to="2014-01-01",
auto.assign = FALSE)$SPY.Adjusted
prices.voo <- getSymbols("VOO", from="2013-01-01", to="2014-01-01",
auto.assign = FALSE)$VOO.Adjusted
egcm(prices.spy, prices.voo)
plot(egcm(prices.spy, prices.voo))
summary(egcm(prices.spy, prices.voo))
# The yegcm method provides a convenient interface to the TTR
# package, which can fetch closing prices from Yahoo. Thus,
# the above can be simplified as follows:
e <- yegcm("SPY", "VOO", start="2013-01-01", end="2014-01-01")
print(e)
plot(e)
summary(e)
}
Run the code above in your browser using DataLab