我的数据具有分类变量和连续变量。我想使用NbClust()函数来确定最佳数目的clusters(k)。因此,我使用了相异矩阵并将距离设置为NULL,但是在使用以下代码时却出现了错误:
res.nb <- NbClust(diss=gower_dist_gender,distance=NULL, min.nc = 1,
max.nc = 30,method = "complete", index ="all")
我该如何解决此问题?是什么问题?
错误是:NbClust中的错误(data = NULL,diss = gower_dist_gender,distance = NULL,:
需要数据矩阵。只能计算frey,mcclain,cindex,sihouette和dunn。
我先谢谢大家。
最佳答案
一些索引需要数字数据。
因此,除非您仅选择不需要坐标的索引,否则不能在您的数据集上使用此函数。
引用错误消息:
Data matrix is needed. Only frey, mcclain, cindex, sihouette and dunn can be computed.
只有这些索引适用于距离矩阵。所有其他索引都需要数字坐标。
关于r - 将NbClust()与不相似矩阵一起使用时,如何解决出现的错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47111320/