[prev in list] [next in list] [prev in thread] [next in thread] 

List:       r-sig-finance
Subject:    [R-SIG-Finance] fastCluster Clustering
From:       Evelyn Mitchell <efm () linsomniac ! com>
Date:       2013-06-23 17:50:31
Message-ID: 51C73567.3060600 () linsomniac ! com
[Download RAW message or body]

Following on jab's request, and modifying Soren's code to use the
fastcluster library from
http://math.stanford.edu/~muellner/fastcluster.html
<http://math.stanford.edu/%7Emuellner/fastcluster.html>


require(quantmod)
require(fastcluster)
require(graphics)
symList <- c('MSN','GOOG','YHOO', 'BA', 'SI', 'BP', 'AMD','AMGN.MX')
getSymbols(symList)

# Matrix of daily returns. Or use weekly, monthly returns...
returns.mat <- NULL
for (sym in symList) returns.mat<- cbind( returns.mat,
                                          dailyReturn( Ad(get(sym)) ) )

colnames(returns.mat) <- symList
returns.mat
na.omit(returns.mat)

hc <- hclust(dist(t(na.omit(returns.mat))), "ave")
plot(hc)
plot(hc, hang = -1)

Evelyn Mitchell
efm@linsomniac.com

	[[alternative HTML version deleted]]

_______________________________________________
R-SIG-Finance@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic