Reputation: 1441
I am currently performing hierarchical cluster. I opted to use FactoMineR
due to its nice data exploration pipeline: data->MFA->HCPC.
data("wine")
names(wine)
res<-MFA(wine,group = c(2,5,3,10,9,2),type=c("n",rep("s",5)),
ncp=5,name.group = c("orig","olf","vis","olfag","gust","ens"),
num.group.sup = c(1,6))
res.hcpc<-HCPC(res, nb.clust=0, consol=F, iter.max=10, min=3,
max=NULL, metric="euclidean", method="ward", order=TRUE,
graph.scale="sqrt-inertia", nb.par=5, graph=TRUE, proba=0.05,
cluster.CA="rows",kk=Inf)
#Now for some nice plots
plot(res.hcpc,draw.tree = T,choice = "tree")
plot(res.hcpc,draw.tree = T,choice = "bar")
These are more than sufficient when wanting to extract answers, but I am looking to present these trees. i.e I want them a bit spruced up through library(ape)
- examples
The problem is that these functions require a hclust
object. One option I had was to use the MFA
results and use an hclust
function as: res.hc<-hclust(dist(res$global.pca$ind$coord),method = "ward.D2")
to build a hclust
object.
This does work, however I find the information that HCPC
gives is much more informative (and answers differ from hclust). Thus I want to work with the HCPC
object and not hclust
, but still be able to use the functions in library(ape)
. Any idea how one would coerce HCPC
to hclust
?
Upvotes: 2
Views: 525
Reputation: 869
for library(ape)
hcpcTree<-res.hcpc$call$t$tree
apeTree<-as.phylo(hcpcTree)
for library(stats)
dendextendTree<-as.phylo.dendrogram(hcpcTree)
Upvotes: 2