0

I use MCLUST and specifically specify K=3 clusters, with the covariance matrix type is VII.

library(mclust)
mc <- Mclust(iris[,-5],  G = 2)

How to create a figure like below? It's from my textbook: Applied Multivariate Statistical Analysis by Johnson and Wichern. Notice that this figure has 2 clusters (squares and triangles) in each figure. So the textbook has a mistake here. The textbook used 2 clusters.

enter image description here

Mariana
  • 161
  • 5
  • That is a pairplot. That specific plot is `pairs(iris %>% select(!Species))`. As it stands, it has nothing to do with the clustering results. – cazman Dec 13 '21 at 17:26
  • I try to run your code. But R returns: Error in iris %>% select(!Species) : could not find function "%>%" – Mariana Dec 13 '21 at 17:41
  • install and load the tidyverse package. – cazman Dec 13 '21 at 17:58
  • Thanks. Now I can run your code. It's very similar, almost the same. But it lacks cluster characteristic. If you look at the tetxbook figure carefully (zoom in), you'll find in each figure, there are different marks of points (triangle, square) to represent clusters. – Mariana Dec 13 '21 at 18:08
  • Didn't realize that. See answer. – cazman Dec 13 '21 at 18:50

1 Answers1

1

If you would like to modify the shape based on cluster assignment, you can do so through the use of pch. Using your data:

pairs(mc$data, pch = mc$classification)

enter image description here

If you want to change the shapes, you can map the classification assignment to the desired shape.

cazman
  • 1,452
  • 1
  • 4
  • 11
  • Thanks. You might also help me in this follow-up question: https://stackoverflow.com/questions/70340077/how-to-create-this-scatter-plot-with-clusters-in-mclust-package-in-r – Mariana Dec 13 '21 at 19:40