## 
## TraMineR stable version 2.0-11.1 (Built: 2019-04-24)
## Website: http://traminer.unige.ch
## Please type 'citation("TraMineR")' for citation information.
##   ï..Name Reading.1 Reading.2 Reading.3 Reading.4 Reading.5 Reading.6
## 1     Tim         5         5         5         5         5         5
## 2     Tim         3         3         3         3         3         3
## 3     Tim         1         1         1         1         1         1
##   Reading.7 Reading.8 Reading.9 Reading.10 Reading.11 Reading.12
## 1         5         5         5          5          5          5
## 2         3         3         3          3          3          3
## 3         1         1         1          1          1          1
##   Reading.13 Reading.14 Reading.15 Reading.16 Reading.17 Reading.18
## 1          5          5          7          7          7          7
## 2          3          3          3          3          3          3
## 3          1          1          1          1          1          1
##   Reading.19 Reading.20 Reading.21 Reading.22 Reading.23 Reading.24
## 1          7          7          7          7          7          7
## 2          3          3          3          3          3          3
## 3          1          1          1          5          5          5
##   Reading.25 Reading.26 Reading.27 Reading.28 Reading.29 Reading.30
## 1          7          7          7          5          5          5
## 2          3          3          3          3          3          3
## 3          5          5          5          5          5          5
## [1] 147  31
##  [>] 7 distinct states appear in the data:
##      1 = 1
##      2 = 2
##      3 = 3
##      4 = 4
##      5 = 5
##      6 = 6
##      7 = 7
##  [>] state coding:
##        [alphabet]  [label]  [long label]
##      1  1           1        BookShelf
##      2  2           2        PS4
##      3  3           3        Counter
##      4  4           4        Side1
##      5  5           5        Side2
##      6  6           6        Business
##      7  7           7        Corner
##  [>] 147 sequences in the data set
##  [>] min/max sequence length: 30/30

Generate Distance Matrix using 1) Optimal Matching, 2) Lowest common prefix, 3) Lowest Common Subsequence

#the distance matrix is generated using the transition rates in the data
coffeecc <- seqsubm(cafeData.seq, method = "TRATE")
##  [>] creating substitution-cost matrix using transition rates ...
##  [>] computing transition probabilities for states 1/2/3/4/5/6/7 ...
#Compute Optimal Matching, Lowest common prefix, Lowest Common Subsequence distance matrix
coffee.OM <- seqdist(cafeData.seq, method = "OM", sm = coffeecc)
##  [>] 147 sequences with 7 distinct states
##  [>] checking 'sm' (one value for each state, triangle inequality)
##  [>] 115 distinct sequences
##  [>] min/max sequence length: 30/30
##  [>] computing distances using the OM metric
##  [>] elapsed time: 0.05 secs
coffee.LCP <- seqdist(cafeData.seq, method = "LCP")
##  [>] 147 sequences with 7 distinct states
##  [>] 115 distinct sequences
##  [>] min/max sequence length: 30/30
##  [>] computing distances using the LCP metric
##  [>] elapsed time: 0.03 secs
coffee.LCS <- seqdist(cafeData.seq, method = "LCS")
##  [>] 147 sequences with 7 distinct states
##  [>] creating a 'sm' with a substitution cost of 2
##  [>] creating 7x7 substitution-cost matrix using 2 as constant value
##  [>] 115 distinct sequences
##  [>] min/max sequence length: 30/30
##  [>] computing distances using the LCS metric
##  [>] elapsed time: 0.05 secs

Native Cluster Using the distance matrices

#Using Optimal Matching, native Cluster
clusterward <- agnes(coffee.OM, diss = TRUE, method = "ward")
cluster6 <- cutree(clusterward, k = 6)
cluster6 <- factor(cluster6, labels = c("Type 1", "Type 2", "Type 3","Type 4","Type 5","Type 6"))
table(cluster6)
## cluster6
## Type 1 Type 2 Type 3 Type 4 Type 5 Type 6 
##     38     23     18     22     11     35
#Using LCP , native Cluster
clusterward.LCP <- agnes(coffee.LCP, diss = TRUE, method = "ward")
cluster6.LCP <- cutree(clusterward.LCP, k = 6)
cluster6.LCP <- factor(cluster6.LCP, labels = c("Type 1", "Type 2", "Type 3","Type 4","Type 5","Type 6"))
table(cluster6.LCP)
## cluster6.LCP
## Type 1 Type 2 Type 3 Type 4 Type 5 Type 6 
##     19     55     27     13     14     19
#Using LCS , native Cluster
clusterward.LCS <- agnes(coffee.LCS, diss = TRUE, method = "ward")
cluster6.LCS <- cutree(clusterward.LCS, k = 6)
cluster6.LCS <- factor(cluster6.LCS, labels = c("Type 1", "Type 2", "Type 3","Type 4","Type 5","Type 6"))
table(cluster6.LCS)
## cluster6.LCS
## Type 1 Type 2 Type 3 Type 4 Type 5 Type 6 
##     38     23     18     22     11     35

K-Medoid Using the distance matrices

#K_Med using OM
K_Med.OM <- pam(coffee.OM, 6, diss = TRUE)
summary(K_Med.OM)
## Medoids:
##       ID    
## [1,] 128 128
## [2,] 135 135
## [3,] 101 101
## [4,]  21  21
## [5,]  43  43
## [6,]  42  42
## Clustering vector:
##   [1] 1 2 3 3 4 4 4 2 1 4 4 1 5 2 5 3 1 4 2 2 4 3 4 5 5 1 5 1 3 6 1 5 6 6 5
##  [36] 6 2 5 6 6 6 6 5 1 5 5 2 5 1 1 4 1 4 6 1 1 1 2 2 1 4 1 4 1 1 1 1 2 4 1
##  [71] 4 1 2 2 2 2 5 2 2 4 2 2 4 2 2 2 6 2 2 2 6 6 6 4 2 2 2 3 3 3 3 1 2 3 3
## [106] 3 3 1 2 3 1 3 6 3 2 3 3 3 2 2 3 3 6 6 6 6 2 1 2 2 6 6 6 6 2 6 6 6 4 6
## [141] 5 6 6 6 6 6 2
## Objective function:
##    build     swap 
## 18.55174 17.17313 
## 
## Numerical information per cluster:
##      size max_diss  av_diss diameter separation
## [1,]   26 35.64905 18.20744 45.52449  21.836134
## [2,]   37 58.89997 18.43465 59.27822  11.840090
## [3,]   21 47.59886 17.93506 47.84957  11.840090
## [4,]   18 37.74167 15.49222 37.91262  11.859340
## [5,]   14 29.72154 16.26248 37.54098   7.967779
## [6,]   31 31.84850 15.67108 37.81522   7.967779
## 
## Isolated clusters:
##  L-clusters: character(0)
##  L*-clusters: character(0)
## 
## Silhouette plot information:
##     cluster neighbor    sil_width
## 17        1        3  0.644619532
## 67        1        3  0.644619532
## 72        1        3  0.644619532
## 111       1        3  0.644619532
## 128       1        2  0.614975466
## 52        1        3  0.563035796
## 44        1        5  0.561945064
## 55        1        2  0.556716961
## 56        1        2  0.546693210
## 62        1        2  0.524318406
## 66        1        2  0.511634796
## 60        1        2  0.496797396
## 70        1        2  0.496797396
## 65        1        2  0.480659045
## 49        1        3  0.467830810
## 102       1        3  0.452666393
## 9         1        3  0.422461440
## 50        1        2  0.403759260
## 57        1        2  0.376970308
## 1         1        2  0.344024118
## 26        1        2  0.344024118
## 12        1        3  0.339966138
## 108       1        3  0.216096788
## 64        1        3  0.170245239
## 31        1        5 -0.021607076
## 28        1        5 -0.024031064
## 2         2        3  0.626130123
## 58        2        3  0.626130123
## 73        2        3  0.626130123
## 75        2        3  0.626130123
## 79        2        3  0.626130123
## 84        2        3  0.626130123
## 88        2        3  0.626130123
## 90        2        3  0.626130123
## 95        2        3  0.626130123
## 97        2        3  0.626130123
## 103       2        3  0.626130123
## 130       2        3  0.626130123
## 135       2        3  0.626130123
## 120       2        3  0.596065962
## 147       2        3  0.575001264
## 8         2        3  0.552895441
## 74        2        5  0.427989945
## 85        2        5  0.389700323
## 81        2        3  0.381248661
## 119       2        1  0.381163856
## 109       2        5  0.318950085
## 19        2        3  0.267215765
## 78        2        3  0.212830841
## 127       2        3  0.212830841
## 20        2        3  0.211848973
## 82        2        3  0.192747124
## 89        2        1  0.185127786
## 59        2        4  0.141320608
## 14        2        3  0.133855021
## 115       2        3  0.119015062
## 37        2        5  0.087441366
## 96        2        3  0.059849412
## 68        2        6  0.058665837
## 86        2        3  0.055525789
## 47        2        3  0.055510195
## 129       2        6  0.026721698
## 76        2        3 -0.041340950
## 101       3        4  0.628215039
## 107       3        4  0.628215039
## 114       3        4  0.628215039
## 117       3        4  0.628215039
## 122       3        4  0.628215039
## 16        3        4  0.599125727
## 118       3        4  0.579355400
## 112       3        2  0.577223850
## 3         3        4  0.554552032
## 104       3        6  0.530816353
## 121       3        4  0.502814129
## 116       3        2  0.456566724
## 106       3        4  0.447868023
## 4         3        4  0.429660863
## 100       3        2  0.379968165
## 99        3        4  0.300023566
## 98        3        2  0.182096356
## 29        3        5  0.117502299
## 105       3        2  0.094111279
## 22        3        2  0.075788560
## 110       3        1  0.022699377
## 10        4        3  0.703163918
## 63        4        3  0.703163918
## 80        4        3  0.703163918
## 51        4        2  0.685303772
## 83        4        2  0.655218184
## 21        4        3  0.652120254
## 139       4        3  0.622551525
## 61        4        3  0.615660968
## 94        4        2  0.610166553
## 11        4        3  0.578901110
## 53        4        3  0.569089928
## 23        4        3  0.486490879
## 7         4        3  0.461838585
## 69        4        2  0.403910860
## 18        4        3  0.375730948
## 6         4        3  0.345724848
## 71        4        2  0.321400595
## 5         4        2  0.259081258
## 25        5        2  0.648956593
## 27        5        2  0.648956593
## 35        5        2  0.648956593
## 141       5        2  0.634070150
## 43        5        2  0.599597514
## 15        5        3  0.492619968
## 32        5        6  0.474645018
## 13        5        2  0.468145673
## 48        5        2  0.456681203
## 38        5        2  0.388726450
## 46        5        6  0.332819032
## 24        5        6  0.089395208
## 45        5        6  0.007037486
## 77        5        2 -0.094694916
## 91        6        5  0.682983857
## 131       6        5  0.682983857
## 138       6        5  0.682983857
## 140       6        5  0.682983857
## 142       6        5  0.682983857
## 144       6        5  0.682983857
## 146       6        5  0.682983857
## 42        6        2  0.668400846
## 92        6        2  0.667396701
## 124       6        5  0.665845440
## 134       6        5  0.662738067
## 137       6        5  0.630944627
## 132       6        2  0.618163668
## 54        6        3  0.584357590
## 93        6        2  0.570086122
## 33        6        3  0.559177119
## 30        6        5  0.557714359
## 136       6        2  0.555369756
## 123       6        2  0.525163395
## 125       6        3  0.507911026
## 39        6        3  0.472560514
## 36        6        3  0.418160079
## 145       6        2  0.407781401
## 133       6        2  0.398221030
## 87        6        2  0.366250591
## 126       6        3  0.314363376
## 143       6        3  0.304761470
## 113       6        3  0.297494971
## 40        6        5  0.289086669
## 41        6        5  0.283176584
## 34        6        5  0.172310332
## Average silhouette width per cluster:
## [1] 0.4394022 0.3714020 0.4281547 0.5418157 0.4139938 0.5251072
## Average silhouette width of total data set:
## [1] 0.4488741
## 
## Available components:
## [1] "medoids"    "id.med"     "clustering" "objective"  "isolation" 
## [6] "clusinfo"   "silinfo"    "diss"       "call"
plot(K_Med.OM)

clusplot(coffee.OM,K_Med.OM$clustering, diss = TRUE, shade = TRUE)

#K_Med using LCP
K_Med.LCP <- pam(coffee.LCP, 6, diss = TRUE)
summary(K_Med.LCP)
## Medoids:
##       ID    
## [1,]  35  35
## [2,] 135 135
## [3,] 122 122
## [4,]  80  80
## [5,] 111 111
## [6,] 146 146
## Clustering vector:
##   [1] 1 2 3 2 1 3 3 2 3 4 4 5 2 2 3 3 5 3 1 2 4 3 2 2 1 1 1 1 3 6 2 1 3 3 1
##  [36] 3 2 1 3 6 1 6 2 1 6 1 2 3 3 5 2 3 3 4 2 5 2 2 4 5 4 5 4 3 5 2 5 6 2 5
##  [71] 4 5 2 2 2 2 2 2 2 4 2 2 4 2 2 1 2 2 2 2 6 2 2 4 2 2 2 2 2 2 3 5 2 6 3
## [106] 2 3 3 2 1 5 3 2 3 1 2 3 3 5 2 2 3 2 6 2 6 2 5 6 2 6 6 2 6 2 4 1 6 4 6
## [141] 1 6 6 6 1 6 2
## Objective function:
##    build     swap 
## 31.86395 31.86395 
## 
## Numerical information per cluster:
##      size max_diss  av_diss diameter separation
## [1,]   19       60 43.05263       60         60
## [2,]   55       54 33.30909       54         60
## [3,]   27       52 31.85185       52         60
## [4,]   13       54 31.23077       54         60
## [5,]   14       52 23.71429       52         60
## [6,]   19       52 22.94737       52         60
## 
## Isolated clusters:
##  L-clusters: character(0)
##  L*-clusters: [1] 2 3 4 5 6
## 
## Silhouette plot information:
##     cluster neighbor  sil_width
## 25        1        2 0.24259259
## 27        1        2 0.24259259
## 35        1        2 0.24259259
## 32        1        2 0.21296296
## 1         1        2 0.19629630
## 26        1        2 0.19629630
## 5         1        2 0.18703704
## 19        1        2 0.18703704
## 86        1        2 0.18703704
## 46        1        2 0.18518519
## 115       1        2 0.17222222
## 41        1        2 0.12592593
## 38        1        2 0.12037037
## 28        1        2 0.11666667
## 141       1        2 0.09444444
## 137       1        2 0.08703704
## 44        1        2 0.08148148
## 145       1        2 0.07407407
## 110       1        2 0.06666667
## 2         2        1 0.43456790
## 58        2        1 0.43456790
## 73        2        1 0.43456790
## 75        2        1 0.43456790
## 79        2        1 0.43456790
## 84        2        1 0.43456790
## 88        2        1 0.43456790
## 90        2        1 0.43456790
## 95        2        1 0.43456790
## 97        2        1 0.43456790
## 103       2        1 0.43456790
## 130       2        1 0.43456790
## 135       2        1 0.43456790
## 37        2        1 0.35308642
## 82        2        1 0.32901235
## 76        2        1 0.32037037
## 85        2        1 0.32037037
## 20        2        1 0.31049383
## 74        2        1 0.30000000
## 81        2        1 0.30000000
## 87        2        1 0.30000000
## 57        2        1 0.28765432
## 13        2        1 0.27469136
## 47        2        1 0.27469136
## 100       2        1 0.27469136
## 77        2        1 0.25987654
## 147       2        1 0.25987654
## 109       2        1 0.24382716
## 78        2        1 0.24074074
## 127       2        1 0.24074074
## 98        2        1 0.22716049
## 69        2        1 0.21172840
## 120       2        1 0.21172840
## 43        2        1 0.21111111
## 66        2        1 0.21111111
## 89        2        1 0.21111111
## 113       2        1 0.20864198
## 92        2        1 0.18827160
## 123       2        1 0.18827160
## 93        2        1 0.18765432
## 8         2        1 0.18641975
## 14        2        1 0.18641975
## 55        2        1 0.18641975
## 106       2        1 0.18641975
## 24        2        1 0.18395062
## 4         2        1 0.16851852
## 125       2        1 0.16851852
## 23        2        1 0.16543210
## 31        2        1 0.16172840
## 96        2        1 0.13456790
## 133       2        1 0.13456790
## 99        2        1 0.13209877
## 116       2        1 0.13209877
## 51        2        1 0.10000000
## 121       2        1 0.10000000
## 101       3        1 0.44871795
## 107       3        1 0.44871795
## 114       3        1 0.44871795
## 117       3        1 0.44871795
## 122       3        1 0.44871795
## 16        3        1 0.42820513
## 3         3        1 0.39615385
## 105       3        1 0.35000000
## 108       3        1 0.34102564
## 118       3        1 0.32051282
## 64        3        1 0.31538462
## 112       3        1 0.31538462
## 9         3        1 0.30897436
## 33        3        1 0.29487179
## 36        3        1 0.29487179
## 6         3        1 0.29358974
## 29        3        1 0.29358974
## 49        3        1 0.29358974
## 15        3        1 0.26282051
## 34        3        1 0.26282051
## 7         3        1 0.25256410
## 39        3        1 0.25256410
## 18        3        1 0.22564103
## 48        3        1 0.20256410
## 53        3        1 0.20256410
## 22        3        1 0.19743590
## 52        3        1 0.13333333
## 10        4        1 0.43611111
## 63        4        1 0.43611111
## 80        4        1 0.43611111
## 71        4        1 0.36944444
## 21        4        1 0.33611111
## 59        4        1 0.31388889
## 11        4        1 0.30555556
## 61        4        1 0.30555556
## 83        4        1 0.28611111
## 139       4        1 0.24166667
## 94        4        1 0.21666667
## 136       4        1 0.16111111
## 54        4        1 0.10000000
## 17        5        1 0.57435897
## 67        5        1 0.57435897
## 72        5        1 0.57435897
## 111       5        1 0.57435897
## 56        5        1 0.52820513
## 60        5        1 0.52820513
## 70        5        1 0.52820513
## 12        5        1 0.40000000
## 65        5        1 0.38205128
## 62        5        1 0.34102564
## 102       5        1 0.24871795
## 119       5        1 0.24871795
## 128       5        1 0.16410256
## 50        5        1 0.13333333
## 91        6        1 0.59629630
## 131       6        1 0.59629630
## 138       6        1 0.59629630
## 140       6        1 0.59629630
## 142       6        1 0.59629630
## 144       6        1 0.59629630
## 146       6        1 0.59629630
## 30        6        1 0.51851852
## 40        6        1 0.46666667
## 45        6        1 0.40740741
## 134       6        1 0.40740741
## 68        6        1 0.38148148
## 132       6        1 0.38148148
## 129       6        1 0.34814815
## 124       6        1 0.27592593
## 143       6        1 0.25000000
## 104       6        1 0.19444444
## 126       6        1 0.16481481
## 42        6        1 0.13333333
## Average silhouette width per cluster:
## [1] 0.1588694 0.2713356 0.3141500 0.3034188 0.4142857 0.4265107
## Average silhouette width of total data set:
## [1] 0.3011713
## 
## Available components:
## [1] "medoids"    "id.med"     "clustering" "objective"  "isolation" 
## [6] "clusinfo"   "silinfo"    "diss"       "call"
plot(K_Med.LCP)

clusplot(coffee.LCP,K_Med.LCP$clustering, diss = TRUE, shade = TRUE)

#K_Med using LCS
K_Med.LCS <- pam(coffee.LCS, 6, diss = TRUE)
summary(K_Med.LCS)
## Medoids:
##       ID    
## [1,] 128 128
## [2,] 135 135
## [3,] 101 101
## [4,]  21  21
## [5,] 141 141
## [6,]  42  42
## Clustering vector:
##   [1] 1 2 3 3 4 4 4 2 1 4 4 1 5 2 5 3 1 4 2 2 4 3 4 6 5 1 5 5 3 6 1 5 6 6 5
##  [36] 6 2 5 6 6 6 6 5 1 6 5 2 5 1 1 4 1 4 6 1 1 1 2 2 1 4 1 4 1 1 1 1 2 4 1
##  [71] 4 1 2 2 2 2 2 2 2 4 2 2 4 2 2 4 6 2 2 2 6 6 6 4 2 1 2 3 3 3 3 1 2 3 3
## [106] 3 3 1 2 3 1 3 6 3 6 3 3 3 2 2 3 3 6 6 6 6 2 1 2 2 6 6 6 6 2 6 6 6 4 6
## [141] 5 6 6 6 6 6 2
## Objective function:
##    build     swap 
## 18.77551 17.38776 
## 
## Numerical information per cluster:
##      size max_diss  av_diss diameter separation
## [1,]   26       44 18.69231       52         22
## [2,]   35       44 16.11429       44         12
## [3,]   21       48 18.19048       48         12
## [4,]   19       60 18.00000       60          8
## [5,]   12       34 15.33333       38         16
## [6,]   34       52 17.58824       60          8
## 
## Isolated clusters:
##  L-clusters: character(0)
##  L*-clusters: character(0)
## 
## Silhouette plot information:
##     cluster neighbor    sil_width
## 17        1        5  0.638300283
## 67        1        5  0.638300283
## 72        1        5  0.638300283
## 111       1        5  0.638300283
## 128       1        2  0.607159353
## 52        1        3  0.557983871
## 55        1        2  0.550617284
## 56        1        2  0.545169082
## 44        1        5  0.536842105
## 62        1        2  0.507509881
## 66        1        2  0.502583979
## 60        1        2  0.491578947
## 70        1        2  0.491578947
## 65        1        2  0.460797799
## 49        1        3  0.453207547
## 102       1        3  0.448057554
## 9         1        3  0.406814815
## 1         1        2  0.370971185
## 26        1        2  0.370971185
## 50        1        2  0.370000000
## 57        1        2  0.341562500
## 12        1        3  0.341507538
## 108       1        3  0.195897436
## 64        1        3  0.157735849
## 31        1        5 -0.031316348
## 96        1        2 -0.079621096
## 2         2        3  0.678047189
## 58        2        3  0.678047189
## 73        2        3  0.678047189
## 75        2        3  0.678047189
## 79        2        3  0.678047189
## 84        2        3  0.678047189
## 88        2        3  0.678047189
## 90        2        3  0.678047189
## 95        2        3  0.678047189
## 97        2        3  0.678047189
## 103       2        3  0.678047189
## 130       2        3  0.678047189
## 135       2        3  0.678047189
## 120       2        3  0.635080418
## 147       2        3  0.607171636
## 8         2        3  0.581750811
## 74        2        5  0.508951407
## 85        2        5  0.475844806
## 119       2        1  0.438533348
## 81        2        3  0.435547425
## 109       2        5  0.409654445
## 82        2        3  0.258823529
## 19        2        3  0.251149358
## 59        2        4  0.232857640
## 20        2        3  0.231372549
## 89        2        1  0.225579161
## 37        2        5  0.204044118
## 78        2        3  0.180946292
## 127       2        3  0.180946292
## 77        2        5  0.146901541
## 68        2        6  0.144144144
## 14        2        3  0.138888889
## 129       2        6  0.097938144
## 47        2        3  0.062880325
## 76        2        3  0.018452604
## 101       3        4  0.634173387
## 107       3        4  0.634173387
## 114       3        4  0.634173387
## 117       3        4  0.634173387
## 122       3        4  0.634173387
## 16        3        2  0.602272727
## 118       3        4  0.581524008
## 112       3        2  0.574382716
## 3         3        4  0.554000000
## 104       3        6  0.535189873
## 121       3        4  0.511926606
## 106       3        4  0.463250000
## 4         3        4  0.449347258
## 116       3        2  0.443061840
## 100       3        2  0.358239095
## 99        3        2  0.293269231
## 98        3        2  0.145204263
## 29        3        5  0.107142857
## 22        3        4  0.094186047
## 105       3        2  0.045164234
## 110       3        1  0.008474576
## 10        4        3  0.662835249
## 63        4        3  0.662835249
## 80        4        3  0.662835249
## 51        4        2  0.639067716
## 83        4        2  0.604787715
## 21        4        3  0.604166667
## 139       4        3  0.576180971
## 61        4        3  0.564074874
## 94        4        2  0.554296110
## 11        4        3  0.525959368
## 53        4        3  0.519313305
## 23        4        3  0.438073394
## 7         4        3  0.405000000
## 69        4        2  0.352802216
## 18        4        3  0.313535912
## 5         4        2  0.306453544
## 6         4        3  0.285256410
## 71        4        2  0.244515216
## 86        4        2 -0.069718698
## 25        5        6  0.678571429
## 27        5        6  0.678571429
## 35        5        6  0.678571429
## 141       5        2  0.659223198
## 43        5        2  0.599107789
## 15        5        3  0.523771633
## 32        5        6  0.514898990
## 13        5        2  0.425646239
## 48        5        2  0.421895006
## 38        5        2  0.367936118
## 46        5        6  0.364942529
## 28        5        1  0.021120294
## 91        6        5  0.661660079
## 131       6        5  0.661660079
## 138       6        5  0.661660079
## 140       6        5  0.661660079
## 142       6        5  0.661660079
## 144       6        5  0.661660079
## 146       6        5  0.661660079
## 124       6        2  0.636159804
## 42        6        2  0.631254405
## 92        6        2  0.630021142
## 134       6        2  0.628488273
## 137       6        2  0.615516650
## 132       6        2  0.579661647
## 30        6        5  0.556388629
## 54        6        3  0.540835181
## 93        6        2  0.524049358
## 136       6        2  0.522856931
## 33        6        3  0.508394758
## 123       6        2  0.476624005
## 125       6        3  0.472429210
## 39        6        3  0.433855799
## 36        6        3  0.394077449
## 145       6        2  0.384309194
## 40        6        5  0.355661882
## 133       6        2  0.353595123
## 87        6        2  0.305120167
## 126       6        3  0.285072952
## 143       6        3  0.279095301
## 113       6        3  0.268181818
## 41        6        5  0.247096516
## 34        6        5  0.165682802
## 45        6        5  0.037549407
## 24        6        5 -0.012820513
## 115       6        2 -0.156226296
## Average silhouette width per cluster:
## [1] 0.4288773 0.4366306 0.4255953 0.4659090 0.4945213 0.4498398
## Average silhouette width of total data set:
## [1] 0.4452481
## 
## Available components:
## [1] "medoids"    "id.med"     "clustering" "objective"  "isolation" 
## [6] "clusinfo"   "silinfo"    "diss"       "call"
plot(K_Med.LCS)

clusplot(coffee.LCS,K_Med.LCS$clustering, diss = TRUE, shade = TRUE)

DB Scan and Compate clusters using Dunn and Calinski

#Note that I tried different values for eps and minPts but not sure whats right. 100 and 5 as shown gave the the most sensible results

#dbscan(coffee.OM, 100, minPts = 5)
#plot(coffee.OM, col=DB$cluster)


intCriteria(coffee.OM,K_Med.OM$clustering,c("C_index","Calinski_Harabasz","Dunn"))
## $c_index
## [1] 0.06378361
## 
## $calinski_harabasz
## [1] 64.58252
## 
## $dunn
## [1] 0.1499339
intCriteria(coffee.LCP,K_Med.LCP$clustering,c("C_index","Calinski_Harabasz","Dunn"))
## $c_index
## [1] 0.09975508
## 
## $calinski_harabasz
## [1] 50.31362
## 
## $dunn
## [1] 0.4136939
intCriteria(coffee.LCS,K_Med.LCS$clustering,c("C_index","Calinski_Harabasz","Dunn"))
## $c_index
## [1] 0.05551035
## 
## $calinski_harabasz
## [1] 65.11953
## 
## $dunn
## [1] 0.1903524