1
$\begingroup$

I have the following data set:

 a          b   c   d
  51 163.000000 244 161
  87 225.000000 343  59
  43 124.000000 189 179
  53  89.000000 177 154
  55 116.000000 224 127
  53 116.000000 185  90
  69 123.000000 223  69
  55 127.000000 202 151
  62 108.000000 183 174
  68 104.000000 188 128
  89  46.000000 146  87
  42  46.000000  99  75
  54 141.000000 216 102
  56  99.000000 171  67
  52  79.000000 145 121
  36  70.000000 136  91
  30  91.000000 150 193
  47 115.000000 185 133
  74  85.000000 174 112
  84 145.000000 238 288
  54 127.000000 205  67
  40 158.000000 244  59
  99 104.000000 230  80
  43 102.000000 163  76
  54 108.000000 176 136
  98  77.000000 191 170
  57  92.000000 180  86
  97  80.000000 192  49
  48 164.000000 232 130
  66  81.000000 176  66
  72 132.000000 216 108
  44 126.000000 201 137
  45  99.000000 209  74
  44 117.000000 186  83
  28  67.000000 138 121
  21   0.000001 134 133
  80 133.000000 225  78
  48 156.000000 237 148
  52  71.000000 138 130
  65 100.000000 181  73
  78  84.000000 171 125
  53  81.000000 153  90
  34  80.000000 140 176
  30 140.000000 197 115
  60 198.000000 299  86
  43 132.000000 204  67
  56 111.000000 184  82
  46  58.000000 113 116
  84 128.000000 222 136
  71 136.000000 223 188
  57  57.000000 136 115
  70 123.000000 215  95
  38  91.000000 189  88
  43 108.000000 201  78
  42 149.000000 234 114
  59 101.000000 188 111
  56 133.000000 219 209
  49 119.000000 191 186
  36  81.000000 143  72
  48  72.000000 134 145
  62  67.000000 139 409
  74 172.000000 263 118
  75 142.000000 270 197
  48  67.000000 142 107
  34 191.000000 271  93
  60 104.000000 182  92
  74  71.000000 156  81
  49  72.000000 137  78
 156  87.000000 254  67
  84 108.000000 211  65
  69 104.000000 191  72
  60 132.000000 216 147
  29 134.000000 205 151
  47  90.000000 149 191
  67  94.000000 191 131
  56  95.000000 165 102
  61 112.000000 188  93
  39  92.000000 149 225
  36  47.000000 117 141
  82  55.000000 147  93
  47 128.000000 191 207
  46 101.000000 171 133
  43  68.000000 138 110
  56 122.000000 202 173
  52  68.000000 135  89
  66 127.000000 210 116
  62 151.000000 245 132
  64 147.000000 225  68
  51 134.000000 205 298
  40 140.000000 217 164
  17  66.000000 104 107
  71  61.000000 143  66
  41  34.000000 108 130
  48  74.000000 152  78
  32  72.000000 132 103
  40  42.000000 113 180
  42 108.000000 179 126
  34  71.000000 137  97
  35 105.000000 159  76
  56  77.000000 161 215
  34 134.000000 189  80
  61 125.000000 211  47
  58  79.000000 161  58
  37  95.000000 166 112
  30 152.000000 223 163
  70  76.000000 163  57
  51 112.000000 203  69
  39  67.000000 115 103
  74 134.000000 223  63
  82 162.000000 268 134
  44  71.000000 130 166
  58  99.000000 183  43
  72 233.000000 336 287
  55 161.000000 233 144
  68 138.000000 215  59
  85 132.000000 234  74
  33 109.000000 181  99
  71 105.000000 193  86
  64 133.000000 217  95
  62  92.000000 170  98
  46 107.000000 169 101
  53 101.000000 187  82
  85  97.000000 205 106
  46 124.000000 215  69
  33  91.000000 147  76
  31 138.000000 246 121
  36  68.000000 124 151
  71 106.000000 191 228
  45 167.000000 234 100
  67 105.000000 183  74
  46 189.000000 258  54
  43 122.000000 182 108
  48 108.000000 183  54
  66 103.000000 186 137
  60 109.000000 189  78
  63  95.000000 180  75
  80 118.000000 215  52
  54 142.000000 235 132
  35  63.000000 138 130
  44 126.000000 194  56
  58 149.000000 223  45
  56  73.000000 141  49
  67 108.000000 203 136
  54  67.000000 150  89
  68 189.000000 276 135
  89  42.000000 140 102
  90  73.000000 171 126
  38  98.000000 163  65
  68 118.000000 206 140
  67  61.000000 139  52
  98  69.000000 175  76
  70  87.000000 171  80
  84 107.000000 207  89
  33  61.000000 122 138

I wish to determine the presence of clusters in it (if they exist). To achieve this, the first thing i did was scale the data:

scale_data_cast<-scale(data_cast)

then I used the "cluster" and "factoextra" packages in R:

First I determined the number of clusters:

library(cluster)
library(factoextra)
fviz_nbclust(scale_data_cast, pam, method = "silhouette")+theme_classic()

With this I obtained that there were two clusters. Then I determined the clusters using the PAM (factoextra package) method (using CLARA I get the same results):

pam.res <- pam(scale_data_cast, 2)
print(pam.res)
fviz_cluster(pam.res,
palette = c("#00AFBB", "#FC4E07"), # color palette
ellipse.type = "t", # Concentration ellipse
repel = TRUE, # Avoid label overplotting (slow)
ggtheme = theme_classic()
)

I obtained with this method that there were two clusters: one presented 94 cases and the other 60 cases.

Now using agglomerative methods:

res.dist <- dist(scale_data_cast, method = "euclidean")
res.hc <- hclust(d = res.dist, method = "average")
res.coph <- cophenetic(res.hc)
cor(res.dist, res.coph)

Here I get the correlation between cophenetic distance and the original distance of 0.77. When I make the cut in 2:

grp <- cutree(res.hc, k = 2)
table(grp)

Here I get one group with 153 cases and the other with one case.

Are there really clusters in this data? Why are the number of cases different when I use agglomerative clustering when compared to the PAM method (similar to k-means)?

Thanks in advance

$\endgroup$
0
1
$\begingroup$

If you plot(res.hc) you can see the tree is highly unbalanced and thus when you specify a cut of two, one is making the cut at the first branching point. In this case the tree has a single branch on one side of the tree at the first break, thus providing your second result.

enter image description here

Compare that plot with plot(pam.res, labels=3) where the PAM method is taking more of average approach so neither cluster is a particular good fit. As one increases the number of clusters with the PAM it will become more and more similar to the hclust method with more cuts (cutting at lower heights).

enter image description here

The extreme points from the hclust are still the extreme points from the PAM cluster. PAM is merging them into 2 cluster while the hclust would have separated them into about 6 or 7 clusters.

$\endgroup$
2
  • $\begingroup$ Can I use the results obtained by the PAM method (in case this result is in accordance with reality)?. Excuse me, wouldn't there be a method that would allow us to group this data? $\endgroup$ – nilrem Apr 5 '20 at 22:30
  • $\begingroup$ It all depends on what the final objectives are. This dataset does appear to have several outlying points complicating matters. Both the methods have their advantages and disadvantages. Be aware of the assumptions and take a look at the total error before making a final decision. $\endgroup$ – Dave2e Apr 5 '20 at 23:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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