0

I am trying to perform hierarchical clustering and I want to use nbclust in order to identify the optimal number of clusters. However, I keep getting the following error:

Error in t(jeu) %*% jeu : requires numeric/complex matrix/vector arguments

I already produced a dissimilarity matrix and plotted the dendogram. My dataset comprises of 2 numeric variables and 260 observations.

I have tried a couple of solutions suggested in other questions, such asnot including the data in the function and only use the dissimilarity matrix but I get the following error:

Data matrix is needed. Only frey, mcclain, cindex, sihouette and dunn can be computed.

The code I've been using is the following:

dist.gower <- daisy(mydata, metric = "gower")

aggl.clust.c <- hclust(dist.gower, method = "complete")
plot(aggl.clust.c,
     main = "Agglomerative, complete linkages")

NbClust(mydata, diss="dist.gower", method= "complete", index="all")

The dendrogram is plotted succesfully, but I keep getting this error message:

Error in t(jeu) %*% jeu : requires numeric/complex matrix/vector arguments

1 Answer 1

0

Data matrix is needed. Only frey, mcclain, cindex, sihouette and dunn can be computed.

This refers to the fact that some indexes (all but the mentioned ones) require coordinate data. See the definitions of the indexes!

Since some indexes cannot be computed without coordinates, index="all" is not valid the.

Use index="silhouette" and the error should go away.

1
  • 2
    Hi, thank you very much for your answer. However, I was wondering if there was a particular reason that I have to exclude a data matrix in order to use the function. Are the results valid if I just include a similarity matrix?
    – Anna
    Commented Jun 4, 2019 at 10:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.