简体   繁体   中英

R ClustOfVar cutree height error

ClustOfVar is a package for clustering columns.

mtcars[] = lapply(mtcars,as.character)

fit = ClustOfVar::hclustvar(X.quali  = mtcars)

labels = cutree(fit,h=0.5)

But when I cutree for some fits, I get the following message.

Warning: Error in cutree: the 'height' component of 'tree' is not sorted (increasingly)

The data on which this problem occurs is both private and big. The fit is generated successfully. I will try my best to find a reproducible data example but if you have met this kind of problem before, please let me know how to deal with it.

With certain linkage methods, it can happen that there is a non-monotonicty in the tree. Then this error occurs. If I'm not mistaken, centroid linkage is particularly prone to this.

The problem looks like this: C is created from A and B. Subtree A is created at height x. Subtree B is created at height y. Usually A and B would merge at a height such that z > x and z > y. But with some linkages, this property may be violated and eg z < x. Now if we want to cut the tree at height h with z < h < x, then we have the contradiction that subtree C should be merged (becaude z < h) but A should be split (because h < x) - but A is part of C.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM