« John Chambers: Interfaces, Efficiency and Big Data | Main | Table comparing the statistical capabilities of software packages »

August 12, 2014

Comments

Feed You can follow this conversation by subscribing to the comment feed for this post.

Interesting post...I'm interested in plotting the dendrogram along with the heatmap.

Apparently it could be done by sligthly modifying your code:

heatmap.2(x=cor(mktRtns), cellnote=round(cor(mktRtns),2), symm=TRUE, dendrogram="row", trace="none", density.info="none", notecol="black")

but according to ?heatmap.2, it's using the default distance matrix dist(x=cor(mktRtns)) which is not correct for correlations - see http://research.stowers-institute.org/mcm/efg/R/Visualization/cor-cluster/index.htm - and should be replaced with:

dissimilarity <- 1 - abs(cor(mktRtns))
distance <- as.dist(dissimilarity)
cluster = hclust(distance)

which should then be plugged into heatmap.2:

heatmap.2(x=cor(mktRtns), Rowv=as.dendrogram(cluster), Colv=as.dendrogram(cluster),revC=T,
cellnote=round(cor(mktRtns),2), symm=TRUE, dendrogram="row", trace="none", density.info="none", notecol="black")


Am I overcomplicating things?

The comments to this entry are closed.


R for the Enterprise

Got comments or suggestions for the blog editor?
Email David Smith.
Follow revodavid on Twitter Follow David on Twitter: @revodavid

Search Revolutions Blog