R Under development (unstable) (2024-12-05 r87423 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(cluster) > ## Compare on these: > nms <- c("clustering", "objective", "isolation", "clusinfo", "silinfo") > nm2 <- c("medoids", "id.med", nms) > nm3 <- nm2[- pmatch("obj", nm2)] > > (x <- x0 <- cbind(V1 = (-3:4)^2, V2 = c(0:6,NA), V3 = c(1,2,NA,7,NA,8:9,8))) V1 V2 V3 [1,] 9 0 1 [2,] 4 1 2 [3,] 1 2 NA [4,] 0 3 7 [5,] 1 4 NA [6,] 4 5 8 [7,] 9 6 9 [8,] 16 NA 8 > (px <- pam(x,2, metric="manhattan")) Medoids: ID V1 V2 V3 [1,] 2 4 1 2 [2,] 6 4 5 8 Clustering vector: [1] 1 1 1 2 2 2 2 2 Objective function: build swap 6.375 6.375 Available components: [1] "medoids" "id.med" "clustering" "objective" "isolation" [6] "clusinfo" "silinfo" "diss" "call" "data" > stopifnot(identical(x,x0))# DUP=FALSE .. > pd <- pam(dist(x,"manhattan"), 2) > px2 <- pam(x,2, metric="manhattan", keep.diss=FALSE, keep.data=FALSE) > pdC <- pam(x,2, metric="manhattan", cluster.only = TRUE) > p1 <- pam(x,1, metric="manhattan") > > stopifnot(identical(px[nms], pd[nms]), + identical(px[nms], px2[nms]), + identical(pdC, px2$clustering), + ## and for default dist "euclidean": + identical(pam(x, 2)[nms], + pam(dist(x),2)[nms]), + identical(p1[c("id.med", "objective", "clusinfo")], + list(id.med = 6L, objective = c(build=9.25, swap=9.25), + clusinfo = array(c(8, 18, 9.25, 45, 0), dim = c(1, 5), + dimnames=list(NULL, c("size", "max_diss", "av_diss", + "diameter", "separation"))))), + p1$clustering == 1, is.null(p1$silinfo) + ) > > set.seed(253) > ## generate 250 objects, divided into 2 clusters. > x <- rbind(cbind(rnorm(120, 0,8), rnorm(120, 0,8)), + cbind(rnorm(130,50,8), rnorm(130,10,8))) > > .proctime00 <- proc.time() > > summary(px2 <- pam(x, 2)) Medoids: ID [1,] 61 -0.7697828 -0.2330187 [2,] 163 49.1392167 9.4097259 Clustering vector: [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [38] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [75] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [112] 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 [149] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 [186] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 [223] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 Objective function: build swap 13.25843 10.20817 Numerical information per cluster: size max_diss av_diss diameter separation [1,] 120 31.04843 10.18584 53.22082 9.419035 [2,] 130 26.94337 10.22878 47.86442 9.419035 Isolated clusters: L-clusters: character(0) L*-clusters: character(0) Silhouette plot information: cluster neighbor sil_width 117 1 2 0.80638966 75 1 2 0.80600824 81 1 2 0.80556624 107 1 2 0.80535252 6 1 2 0.80526675 100 1 2 0.80385505 68 1 2 0.80369702 113 1 2 0.80331774 61 1 2 0.80315322 57 1 2 0.80313945 12 1 2 0.80161573 59 1 2 0.80047745 82 1 2 0.79630964 67 1 2 0.79559589 63 1 2 0.79488886 47 1 2 0.79458809 21 1 2 0.79379540 9 1 2 0.79343081 95 1 2 0.79332153 4 1 2 0.79136081 3 1 2 0.79130879 39 1 2 0.79052367 120 1 2 0.78877423 90 1 2 0.78767224 85 1 2 0.78588359 106 1 2 0.78504452 92 1 2 0.78303000 83 1 2 0.78245915 19 1 2 0.78228359 14 1 2 0.78139236 10 1 2 0.77825678 49 1 2 0.77597087 64 1 2 0.77482761 44 1 2 0.77397394 89 1 2 0.77297318 119 1 2 0.77238705 108 1 2 0.77137189 104 1 2 0.76871378 32 1 2 0.76856251 115 1 2 0.76843312 27 1 2 0.76811698 88 1 2 0.76810713 109 1 2 0.76681303 62 1 2 0.76655954 36 1 2 0.76547988 66 1 2 0.76535606 74 1 2 0.76491406 26 1 2 0.76441455 24 1 2 0.76436188 65 1 2 0.76381352 40 1 2 0.76061109 52 1 2 0.75748679 54 1 2 0.75746436 13 1 2 0.75594073 56 1 2 0.75353784 96 1 2 0.75268786 116 1 2 0.75267215 110 1 2 0.75266614 112 1 2 0.75150872 78 1 2 0.75083708 7 1 2 0.74905187 86 1 2 0.74190424 18 1 2 0.74162144 111 1 2 0.74085474 69 1 2 0.74044653 76 1 2 0.73911707 50 1 2 0.73847075 93 1 2 0.73616384 31 1 2 0.73462007 33 1 2 0.73455252 43 1 2 0.73396232 102 1 2 0.72930751 118 1 2 0.72778023 15 1 2 0.72588122 53 1 2 0.72542363 8 1 2 0.72535191 77 1 2 0.72467809 16 1 2 0.72446952 48 1 2 0.72331213 105 1 2 0.72325095 37 1 2 0.72055248 101 1 2 0.71783562 22 1 2 0.71217552 23 1 2 0.71078375 84 1 2 0.70573352 17 1 2 0.70221946 38 1 2 0.69947240 2 1 2 0.69718780 98 1 2 0.69601237 1 1 2 0.69373841 35 1 2 0.69179546 70 1 2 0.69074915 28 1 2 0.68434091 97 1 2 0.68351978 5 1 2 0.67662675 72 1 2 0.67420722 34 1 2 0.67315267 11 1 2 0.67226046 103 1 2 0.67188668 87 1 2 0.67172802 58 1 2 0.67090513 46 1 2 0.66835116 60 1 2 0.66565445 80 1 2 0.65983842 73 1 2 0.65093947 55 1 2 0.64709226 20 1 2 0.64439401 45 1 2 0.63403361 51 1 2 0.63303101 42 1 2 0.62906268 94 1 2 0.60916406 91 1 2 0.59905996 41 1 2 0.57245485 29 1 2 0.55594781 99 1 2 0.55035955 79 1 2 0.50808544 71 1 2 0.46663954 25 1 2 0.43797346 114 1 2 0.16645003 30 1 2 0.08928664 121 2 1 0.80353953 137 2 1 0.80253721 146 2 1 0.80106653 173 2 1 0.80039417 216 2 1 0.79969919 124 2 1 0.79964913 163 2 1 0.79901674 157 2 1 0.79779188 242 2 1 0.79744315 227 2 1 0.79708130 207 2 1 0.79653829 130 2 1 0.79574204 188 2 1 0.79496670 250 2 1 0.79302877 145 2 1 0.79190501 126 2 1 0.79156003 166 2 1 0.79068795 222 2 1 0.78986170 232 2 1 0.78839216 176 2 1 0.78819086 198 2 1 0.78782877 225 2 1 0.78747329 230 2 1 0.78689375 205 2 1 0.78683641 160 2 1 0.78643596 150 2 1 0.78484046 136 2 1 0.78455577 228 2 1 0.78198238 206 2 1 0.78137390 152 2 1 0.78044944 200 2 1 0.77843458 149 2 1 0.77822272 221 2 1 0.77758324 226 2 1 0.77611981 129 2 1 0.77531368 199 2 1 0.77491451 154 2 1 0.77136276 241 2 1 0.77076783 179 2 1 0.77010597 174 2 1 0.76893758 214 2 1 0.76776510 181 2 1 0.76763087 213 2 1 0.76683151 215 2 1 0.76639087 236 2 1 0.76637552 218 2 1 0.76563050 182 2 1 0.76450873 219 2 1 0.76370712 208 2 1 0.76090426 151 2 1 0.75957536 164 2 1 0.75914844 248 2 1 0.75849775 224 2 1 0.75826151 168 2 1 0.75782023 189 2 1 0.75555083 128 2 1 0.75550519 125 2 1 0.75510766 177 2 1 0.75128941 147 2 1 0.75086382 158 2 1 0.75029192 245 2 1 0.74993652 186 2 1 0.74741247 165 2 1 0.74681005 156 2 1 0.74478894 122 2 1 0.74315425 247 2 1 0.74107328 220 2 1 0.74054057 183 2 1 0.73818743 184 2 1 0.73743259 169 2 1 0.73712431 180 2 1 0.73419669 240 2 1 0.73390938 134 2 1 0.73382823 190 2 1 0.73379720 217 2 1 0.73311931 171 2 1 0.73110365 143 2 1 0.72986022 153 2 1 0.72891371 223 2 1 0.72887340 238 2 1 0.72789416 175 2 1 0.72311665 138 2 1 0.72290131 235 2 1 0.72157157 237 2 1 0.71591233 132 2 1 0.71549875 204 2 1 0.71381083 201 2 1 0.71263881 170 2 1 0.70812568 191 2 1 0.70747428 243 2 1 0.70588929 193 2 1 0.70499170 141 2 1 0.70489885 161 2 1 0.70303117 249 2 1 0.69300988 229 2 1 0.69231982 196 2 1 0.69162302 211 2 1 0.69128644 246 2 1 0.68757678 159 2 1 0.68619850 133 2 1 0.68605444 194 2 1 0.68538064 155 2 1 0.68278455 234 2 1 0.68202095 127 2 1 0.68111027 144 2 1 0.67559517 131 2 1 0.65959281 139 2 1 0.65895024 209 2 1 0.65844942 148 2 1 0.65180336 185 2 1 0.64989675 212 2 1 0.63954685 192 2 1 0.63470144 123 2 1 0.63005333 202 2 1 0.61735843 135 2 1 0.61493992 210 2 1 0.60680456 140 2 1 0.58410004 187 2 1 0.58193543 239 2 1 0.57088679 203 2 1 0.56761998 244 2 1 0.55321123 231 2 1 0.55043439 197 2 1 0.52364031 195 2 1 0.51955678 142 2 1 0.47466260 162 2 1 0.46155841 172 2 1 0.45167576 178 2 1 0.42686872 233 2 1 0.37013099 167 2 1 0.32442373 Average silhouette width per cluster: [1] 0.7196104 0.7148520 Average silhouette width of total data set: [1] 0.717136 Available components: [1] "medoids" "id.med" "clustering" "objective" "isolation" [6] "clusinfo" "silinfo" "diss" "call" "data" > pdx <- pam(dist(x), 2) > all.equal(px2[nms], pdx[nms], tol = 1e-12) ## TRUE [1] TRUE > pdxK <- pam(dist(x), 2, keep.diss = TRUE) > stopifnot(identical(pdx[nm2], pdxK[nm2])) > > spdx <- silhouette(pdx) > summary(spdx) Silhouette of 250 units in 2 clusters from pam(x = dist(x), k = 2) : Cluster sizes and average silhouette widths: 120 130 0.7196104 0.7148520 Individual silhouette widths: Min. 1st Qu. Median Mean 3rd Qu. Max. 0.08929 0.69137 0.74397 0.71714 0.77806 0.80639 > spdx cluster neighbor sil_width 117 1 2 0.80638966 75 1 2 0.80600824 81 1 2 0.80556624 107 1 2 0.80535252 6 1 2 0.80526675 100 1 2 0.80385505 68 1 2 0.80369702 113 1 2 0.80331774 61 1 2 0.80315322 57 1 2 0.80313945 12 1 2 0.80161573 59 1 2 0.80047745 82 1 2 0.79630964 67 1 2 0.79559589 63 1 2 0.79488886 47 1 2 0.79458809 21 1 2 0.79379540 9 1 2 0.79343081 95 1 2 0.79332153 4 1 2 0.79136081 3 1 2 0.79130879 39 1 2 0.79052367 120 1 2 0.78877423 90 1 2 0.78767224 85 1 2 0.78588359 106 1 2 0.78504452 92 1 2 0.78303000 83 1 2 0.78245915 19 1 2 0.78228359 14 1 2 0.78139236 10 1 2 0.77825678 49 1 2 0.77597087 64 1 2 0.77482761 44 1 2 0.77397394 89 1 2 0.77297318 119 1 2 0.77238705 108 1 2 0.77137189 104 1 2 0.76871378 32 1 2 0.76856251 115 1 2 0.76843312 27 1 2 0.76811698 88 1 2 0.76810713 109 1 2 0.76681303 62 1 2 0.76655954 36 1 2 0.76547988 66 1 2 0.76535606 74 1 2 0.76491406 26 1 2 0.76441455 24 1 2 0.76436188 65 1 2 0.76381352 40 1 2 0.76061109 52 1 2 0.75748679 54 1 2 0.75746436 13 1 2 0.75594073 56 1 2 0.75353784 96 1 2 0.75268786 116 1 2 0.75267215 110 1 2 0.75266614 112 1 2 0.75150872 78 1 2 0.75083708 7 1 2 0.74905187 86 1 2 0.74190424 18 1 2 0.74162144 111 1 2 0.74085474 69 1 2 0.74044653 76 1 2 0.73911707 50 1 2 0.73847075 93 1 2 0.73616384 31 1 2 0.73462007 33 1 2 0.73455252 43 1 2 0.73396232 102 1 2 0.72930751 118 1 2 0.72778023 15 1 2 0.72588122 53 1 2 0.72542363 8 1 2 0.72535191 77 1 2 0.72467809 16 1 2 0.72446952 48 1 2 0.72331213 105 1 2 0.72325095 37 1 2 0.72055248 101 1 2 0.71783562 22 1 2 0.71217552 23 1 2 0.71078375 84 1 2 0.70573352 17 1 2 0.70221946 38 1 2 0.69947240 2 1 2 0.69718780 98 1 2 0.69601237 1 1 2 0.69373841 35 1 2 0.69179546 70 1 2 0.69074915 28 1 2 0.68434091 97 1 2 0.68351978 5 1 2 0.67662675 72 1 2 0.67420722 34 1 2 0.67315267 11 1 2 0.67226046 103 1 2 0.67188668 87 1 2 0.67172802 58 1 2 0.67090513 46 1 2 0.66835116 60 1 2 0.66565445 80 1 2 0.65983842 73 1 2 0.65093947 55 1 2 0.64709226 20 1 2 0.64439401 45 1 2 0.63403361 51 1 2 0.63303101 42 1 2 0.62906268 94 1 2 0.60916406 91 1 2 0.59905996 41 1 2 0.57245485 29 1 2 0.55594781 99 1 2 0.55035955 79 1 2 0.50808544 71 1 2 0.46663954 25 1 2 0.43797346 114 1 2 0.16645003 30 1 2 0.08928664 121 2 1 0.80353953 137 2 1 0.80253721 146 2 1 0.80106653 173 2 1 0.80039417 216 2 1 0.79969919 124 2 1 0.79964913 163 2 1 0.79901674 157 2 1 0.79779188 242 2 1 0.79744315 227 2 1 0.79708130 207 2 1 0.79653829 130 2 1 0.79574204 188 2 1 0.79496670 250 2 1 0.79302877 145 2 1 0.79190501 126 2 1 0.79156003 166 2 1 0.79068795 222 2 1 0.78986170 232 2 1 0.78839216 176 2 1 0.78819086 198 2 1 0.78782877 225 2 1 0.78747329 230 2 1 0.78689375 205 2 1 0.78683641 160 2 1 0.78643596 150 2 1 0.78484046 136 2 1 0.78455577 228 2 1 0.78198238 206 2 1 0.78137390 152 2 1 0.78044944 200 2 1 0.77843458 149 2 1 0.77822272 221 2 1 0.77758324 226 2 1 0.77611981 129 2 1 0.77531368 199 2 1 0.77491451 154 2 1 0.77136276 241 2 1 0.77076783 179 2 1 0.77010597 174 2 1 0.76893758 214 2 1 0.76776510 181 2 1 0.76763087 213 2 1 0.76683151 215 2 1 0.76639087 236 2 1 0.76637552 218 2 1 0.76563050 182 2 1 0.76450873 219 2 1 0.76370712 208 2 1 0.76090426 151 2 1 0.75957536 164 2 1 0.75914844 248 2 1 0.75849775 224 2 1 0.75826151 168 2 1 0.75782023 189 2 1 0.75555083 128 2 1 0.75550519 125 2 1 0.75510766 177 2 1 0.75128941 147 2 1 0.75086382 158 2 1 0.75029192 245 2 1 0.74993652 186 2 1 0.74741247 165 2 1 0.74681005 156 2 1 0.74478894 122 2 1 0.74315425 247 2 1 0.74107328 220 2 1 0.74054057 183 2 1 0.73818743 184 2 1 0.73743259 169 2 1 0.73712431 180 2 1 0.73419669 240 2 1 0.73390938 134 2 1 0.73382823 190 2 1 0.73379720 217 2 1 0.73311931 171 2 1 0.73110365 143 2 1 0.72986022 153 2 1 0.72891371 223 2 1 0.72887340 238 2 1 0.72789416 175 2 1 0.72311665 138 2 1 0.72290131 235 2 1 0.72157157 237 2 1 0.71591233 132 2 1 0.71549875 204 2 1 0.71381083 201 2 1 0.71263881 170 2 1 0.70812568 191 2 1 0.70747428 243 2 1 0.70588929 193 2 1 0.70499170 141 2 1 0.70489885 161 2 1 0.70303117 249 2 1 0.69300988 229 2 1 0.69231982 196 2 1 0.69162302 211 2 1 0.69128644 246 2 1 0.68757678 159 2 1 0.68619850 133 2 1 0.68605444 194 2 1 0.68538064 155 2 1 0.68278455 234 2 1 0.68202095 127 2 1 0.68111027 144 2 1 0.67559517 131 2 1 0.65959281 139 2 1 0.65895024 209 2 1 0.65844942 148 2 1 0.65180336 185 2 1 0.64989675 212 2 1 0.63954685 192 2 1 0.63470144 123 2 1 0.63005333 202 2 1 0.61735843 135 2 1 0.61493992 210 2 1 0.60680456 140 2 1 0.58410004 187 2 1 0.58193543 239 2 1 0.57088679 203 2 1 0.56761998 244 2 1 0.55321123 231 2 1 0.55043439 197 2 1 0.52364031 195 2 1 0.51955678 142 2 1 0.47466260 162 2 1 0.46155841 172 2 1 0.45167576 178 2 1 0.42686872 233 2 1 0.37013099 167 2 1 0.32442373 attr(,"Ordered") [1] TRUE attr(,"call") pam(x = dist(x), k = 2) attr(,"class") [1] "silhouette" > postscript("pam-tst.ps") > if(FALSE) + plot(spdx)# the silhouette > ## is now identical : > plot(pdx)# failed in 1.7.0 -- now only does silhouette > > par(mfrow = 2:1) > ## new 'dist' argument for clusplot(): > plot(pdx, dist=dist(x)) > ## but this should work automagically (via eval()) as well: > plot(pdx) > ## or this > clusplot(pdx) > > data(ruspini) > summary(pr4 <- pam(ruspini, 4)) Medoids: ID x y 10 10 19 65 32 32 44 149 52 52 99 119 70 70 69 21 Clustering vector: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 Objective function: build swap 17.22898 11.48637 Numerical information per cluster: size max_diss av_diss diameter separation [1,] 20 24.04163 12.55362 40.24922 40.49691 [2,] 23 26.92582 10.44238 36.61967 24.04163 [3,] 17 33.97058 13.84800 47.63402 24.04163 [4,] 15 17.02939 8.98767 27.07397 40.49691 Isolated clusters: L-clusters: character(0) L*-clusters: [1] 1 4 Silhouette plot information: cluster neighbor sil_width 10 1 4 0.8056096 6 1 4 0.7954977 9 1 4 0.7923048 11 1 4 0.7831672 8 1 2 0.7811793 12 1 4 0.7658171 3 1 4 0.7587961 14 1 4 0.7569107 2 1 4 0.7456150 16 1 4 0.7436018 13 1 4 0.7398841 4 1 2 0.7361533 18 1 4 0.7080079 15 1 4 0.7006854 19 1 4 0.7000938 1 1 4 0.6798381 5 1 4 0.6646571 20 1 4 0.6619626 17 1 4 0.6148541 7 1 2 0.5900575 26 2 3 0.8357433 32 2 3 0.8332753 27 2 3 0.8290271 25 2 3 0.8285547 28 2 3 0.8192636 35 2 3 0.8186309 33 2 3 0.8175087 23 2 3 0.8089969 22 2 3 0.8025389 34 2 3 0.8013310 31 2 3 0.7949677 36 2 3 0.7943536 24 2 3 0.7930770 29 2 3 0.7897346 30 2 3 0.7892027 21 2 3 0.7698024 37 2 3 0.7684502 39 2 3 0.7631648 38 2 3 0.7438848 40 2 3 0.7083130 42 2 3 0.5291270 43 2 3 0.4931623 41 2 3 0.4290814 54 3 2 0.7741745 57 3 2 0.7703455 55 3 2 0.7641810 50 3 2 0.7619943 52 3 2 0.7616220 56 3 2 0.7575313 59 3 2 0.7327828 49 3 2 0.7317002 51 3 2 0.7209864 60 3 2 0.7206840 58 3 2 0.7019611 53 3 2 0.6775322 45 3 2 0.5974787 46 3 2 0.5740823 47 3 2 0.4835635 48 3 2 0.4247331 44 3 2 0.4196093 70 4 1 0.8548947 67 4 1 0.8527439 65 4 1 0.8503105 69 4 1 0.8391810 71 4 1 0.8381065 66 4 1 0.8229841 62 4 1 0.8153092 64 4 1 0.8061254 73 4 1 0.7950213 63 4 1 0.7795369 72 4 1 0.7748121 61 4 1 0.7701103 68 4 1 0.7620559 74 4 1 0.7596815 75 4 1 0.7425538 Average silhouette width per cluster: [1] 0.7262347 0.7548344 0.6691154 0.8042285 Average silhouette width of total data set: [1] 0.737657 2775 dissimilarities, summarized : Min. 1st Qu. Median Mean 3rd Qu. Max. 1.414 40.106 75.591 71.538 99.169 154.500 Metric : euclidean Number of objects : 75 Available components: [1] "medoids" "id.med" "clustering" "objective" "isolation" [6] "clusinfo" "silinfo" "diss" "call" "data" > (pr3 <- pam(ruspini, 3)) Medoids: ID x y 17 17 30 52 32 32 44 149 52 52 99 119 Clustering vector: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 3 3 3 3 3 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Objective function: build swap 25.68229 21.59293 Available components: [1] "medoids" "id.med" "clustering" "objective" "isolation" [6] "clusinfo" "silinfo" "diss" "call" "data" > (pr5 <- pam(ruspini, 5)) Medoids: ID x y 10 10 19 65 32 32 44 149 52 52 99 119 47 47 78 94 70 70 69 21 Clustering vector: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 4 4 4 3 3 3 3 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 3 3 3 3 3 3 3 3 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 Objective function: build swap 12.09864 10.39579 Available components: [1] "medoids" "id.med" "clustering" "objective" "isolation" [6] "clusinfo" "silinfo" "diss" "call" "data" > > data(votes.repub) > summary(pv3 <- pam(votes.repub, 3)) Medoids: ID X1856 X1860 X1864 X1868 X1872 X1876 X1880 X1884 X1888 X1892 X1896 Alabama 1 NA NA NA 51.44 53.19 40.02 36.98 38.44 32.28 3.95 28.13 Alaska 2 NA NA NA NA NA NA NA NA NA NA NA New Mexico 31 NA NA NA NA NA NA NA NA NA NA NA X1900 X1904 X1908 X1912 X1916 X1920 X1924 X1928 X1932 X1936 X1940 Alabama 34.67 20.65 24.38 8.26 21.97 30.98 27.01 48.49 14.15 12.82 14.34 Alaska NA NA NA NA NA NA NA NA NA NA NA New Mexico NA NA NA 35.91 46.53 54.68 48.52 59.01 35.76 36.50 43.28 X1944 X1948 X1952 X1956 X1960 X1964 X1968 X1972 X1976 Alabama 18.20 19.04 35.02 39.39 41.75 69.5 14.0 72.4 43.48 Alaska NA NA NA NA 50.94 34.1 45.3 58.1 62.91 New Mexico 46.44 42.93 55.39 57.81 49.41 41.0 51.8 61.0 51.04 Clustering vector: Alabama Alaska Arizona Arkansas California 1 2 3 1 2 Colorado Connecticut Delaware Florida Georgia 2 2 3 1 1 Hawaii Idaho Illinois Indiana Iowa 2 3 2 3 3 Kansas Kentucky Louisiana Maine Maryland 2 3 1 2 3 Massachusetts Michigan Minnesota Mississippi Missouri 3 2 3 1 3 Montana Nebraska Nevada New Hampshire New Jersey 3 3 2 2 2 New Mexico New York North Carolina North Dakota Ohio 3 3 3 2 3 Oklahoma Oregon Pennsylvania Rhode Island South Carolina 3 3 2 3 2 South Dakota Tennessee Texas Utah Vermont 3 3 2 3 2 Virginia Washington West Virginia Wisconsin Wyoming 2 3 3 3 3 Objective function: build swap 38.32548 38.32548 Numerical information per cluster: size max_diss av_diss diameter separation [1,] 6 78.92731 51.59134 116.7048 50.14189 [2,] 18 86.54675 38.47068 271.2455 19.42184 [3,] 26 60.03879 35.16361 124.8324 19.42184 Isolated clusters: L-clusters: character(0) L*-clusters: character(0) Silhouette plot information: cluster neighbor sil_width Louisiana 1 3 0.54689535 Alabama 1 3 0.52839272 Georgia 1 3 0.52730253 Mississippi 1 2 0.52454810 Florida 1 3 0.25211631 Arkansas 1 3 0.24131701 Alaska 2 3 0.15699268 Hawaii 2 3 0.08479842 Vermont 2 3 -0.02620975 Maine 2 3 -0.03284950 Michigan 2 3 -0.11524982 Pennsylvania 2 3 -0.15341477 New Hampshire 2 3 -0.17099889 Connecticut 2 3 -0.19095000 New Jersey 2 3 -0.19281567 Kansas 2 3 -0.19719316 California 2 3 -0.24006293 Illinois 2 3 -0.25236336 North Dakota 2 3 -0.25464430 Virginia 2 3 -0.26262534 Nevada 2 3 -0.27016336 Colorado 2 3 -0.27885043 Texas 2 1 -0.47297583 South Carolina 2 1 -0.50899710 New Mexico 3 2 0.39555584 Washington 3 2 0.32989454 Oklahoma 3 2 0.30953823 Wyoming 3 2 0.30163169 Idaho 3 2 0.29915132 Montana 3 2 0.29105494 Missouri 3 2 0.29038462 Oregon 3 2 0.27710695 Maryland 3 2 0.27437520 West Virginia 3 2 0.27089938 Utah 3 2 0.26964380 Tennessee 3 2 0.26846440 Arizona 3 2 0.25968564 Delaware 3 2 0.25920434 Kentucky 3 2 0.25868341 South Dakota 3 2 0.25615670 Indiana 3 2 0.25031548 Wisconsin 3 2 0.21808013 Ohio 3 2 0.21477474 Nebraska 3 2 0.20965953 North Carolina 3 2 0.19201537 Minnesota 3 2 0.18955165 New York 3 2 0.18820394 Iowa 3 2 0.17296046 Rhode Island 3 2 0.12599915 Massachusetts 3 2 0.12106770 Average silhouette width per cluster: [1] 0.4367620 -0.1876985 0.2497715 Average silhouette width of total data set: [1] 0.1147212 1225 dissimilarities, summarized : Min. 1st Qu. Median Mean 3rd Qu. Max. 17.20 48.34 64.68 82.23 105.49 281.95 Metric : euclidean Number of objects : 50 Available components: [1] "medoids" "id.med" "clustering" "objective" "isolation" [6] "clusinfo" "silinfo" "diss" "call" "data" > (pv4 <- pam(votes.repub, 4)) Medoids: ID X1856 X1860 X1864 X1868 X1872 X1876 X1880 X1884 X1888 X1892 X1896 Alabama 1 NA NA NA 51.44 53.19 40.02 36.98 38.44 32.28 3.95 28.13 Alaska 2 NA NA NA NA NA NA NA NA NA NA NA New Mexico 31 NA NA NA NA NA NA NA NA NA NA NA Iowa 15 49.13 54.87 64.23 61.92 64.18 58.58 56.85 52.42 52.36 49.60 55.46 X1900 X1904 X1908 X1912 X1916 X1920 X1924 X1928 X1932 X1936 X1940 Alabama 34.67 20.65 24.38 8.26 21.97 30.98 27.01 48.49 14.15 12.82 14.34 Alaska NA NA NA NA NA NA NA NA NA NA NA New Mexico NA NA NA 35.91 46.53 54.68 48.52 59.01 35.76 36.50 43.28 Iowa 57.99 63.37 55.62 24.30 54.06 70.91 55.06 61.80 39.98 42.70 52.03 X1944 X1948 X1952 X1956 X1960 X1964 X1968 X1972 X1976 Alabama 18.20 19.04 35.02 39.39 41.75 69.5 14.0 72.4 43.48 Alaska NA NA NA NA 50.94 34.1 45.3 58.1 62.91 New Mexico 46.44 42.93 55.39 57.81 49.41 41.0 51.8 61.0 51.04 Iowa 51.99 47.58 63.76 59.06 56.71 38.1 53.0 57.6 50.51 Clustering vector: Alabama Alaska Arizona Arkansas California 1 2 3 1 2 Colorado Connecticut Delaware Florida Georgia 2 2 3 1 1 Hawaii Idaho Illinois Indiana Iowa 2 3 4 3 4 Kansas Kentucky Louisiana Maine Maryland 4 3 1 2 3 Massachusetts Michigan Minnesota Mississippi Missouri 4 2 4 1 3 Montana Nebraska Nevada New Hampshire New Jersey 3 4 2 2 2 New Mexico New York North Carolina North Dakota Ohio 3 3 3 4 4 Oklahoma Oregon Pennsylvania Rhode Island South Carolina 3 3 4 4 2 South Dakota Tennessee Texas Utah Vermont 4 3 2 3 2 Virginia Washington West Virginia Wisconsin Wyoming 2 3 3 4 3 Objective function: build swap 35.84182 35.84182 Available components: [1] "medoids" "id.med" "clustering" "objective" "isolation" [6] "clusinfo" "silinfo" "diss" "call" "data" > (pv6 <- pam(votes.repub, 6, trace = 3)) C pam(): computing 1226 dissimilarities from 50 x 31 matrix: [Ok] pam()'s bswap(*, s=281.951, pamonce=0): build 6 medoids: new repr. 2 new repr. 1 new repr. 31 new repr. 15 new repr. 46 new repr. 40 after build: medoids are 1 2 15 31 40 46 and min.dist dysma[1:n] are 0 0 37.7 56 35.8 28.5 28.6 31.7 54.1 48.2 51.7 33.2 27.3 30.5 0 35.1 25.4 60.9 36.9 26.7 48.4 28.1 33.2 63.1 21.1 28.6 37.5 35.8 29.8 31.3 0 32 29.9 35.7 30.9 35.1 27.8 35.7 50.2 0 26.2 30.2 45.2 34.1 33.8 0 28.5 35.1 34.2 28.8 swp new 10 <-> 1 old; decreasing diss. 1579.03 by -2.57067 end{bswap()}, end{cstat()} Medoids: ID X1856 X1860 X1864 X1868 X1872 X1876 X1880 X1884 X1888 X1892 Georgia 10 NA NA NA 35.72 43.77 27.94 34.33 33.84 28.33 21.80 Alaska 2 NA NA NA NA NA NA NA NA NA NA Virginia 46 0.19 1.15 NA NA 50.48 40.62 39.52 48.90 49.47 38.75 New Mexico 31 NA NA NA NA NA NA NA NA NA NA Iowa 15 49.13 54.87 64.23 61.92 64.18 58.58 56.85 52.42 52.36 49.60 South Carolina 40 NA NA NA 57.93 75.95 50.26 33.97 23.72 17.27 18.99 X1896 X1900 X1904 X1908 X1912 X1916 X1920 X1924 X1928 X1932 Georgia 36.82 28.56 18.32 31.40 4.27 7.07 28.57 18.19 43.37 7.77 Alaska NA NA NA NA NA NA NA NA NA NA Virginia 45.90 43.81 36.67 38.36 17.00 32.05 37.85 32.79 53.91 30.09 New Mexico NA NA NA NA 35.91 46.53 54.68 48.52 59.01 35.76 Iowa 55.46 57.99 63.37 55.62 24.30 54.06 70.91 55.06 61.80 39.98 South Carolina 13.51 7.04 4.63 5.97 1.06 2.43 3.90 2.21 8.54 1.89 X1936 X1940 X1944 X1948 X1952 X1956 X1960 X1964 X1968 X1972 Georgia 12.60 14.84 18.25 18.31 30.34 33.22 37.44 54.1 30.4 75.0 Alaska NA NA NA NA NA NA 50.94 34.1 45.3 58.1 Virginia 29.39 31.55 37.39 41.04 56.32 55.37 52.44 46.5 41.4 67.8 New Mexico 36.50 43.28 46.44 42.93 55.39 57.81 49.41 41.0 51.8 61.0 Iowa 42.70 52.03 51.99 47.58 63.76 59.06 56.71 38.1 53.0 57.6 South Carolina 1.43 4.37 4.46 3.78 49.28 25.18 48.76 58.9 38.1 70.8 X1976 Georgia 33.02 Alaska 62.91 Virginia 50.73 New Mexico 51.04 Iowa 50.51 South Carolina 43.54 Clustering vector: Alabama Alaska Arizona Arkansas California 1 2 3 3 2 Colorado Connecticut Delaware Florida Georgia 2 2 4 3 1 Hawaii Idaho Illinois Indiana Iowa 2 4 5 4 5 Kansas Kentucky Louisiana Maine Maryland 5 4 1 2 4 Massachusetts Michigan Minnesota Mississippi Missouri 5 2 5 6 4 Montana Nebraska Nevada New Hampshire New Jersey 4 5 2 2 2 New Mexico New York North Carolina North Dakota Ohio 4 4 3 5 5 Oklahoma Oregon Pennsylvania Rhode Island South Carolina 4 4 5 5 6 South Dakota Tennessee Texas Utah Vermont 5 3 2 4 2 Virginia Washington West Virginia Wisconsin Wyoming 3 4 4 5 4 Objective function: build swap 31.58067 31.52926 Available components: [1] "medoids" "id.med" "clustering" "objective" "isolation" [6] "clusinfo" "silinfo" "diss" "call" "data" > > cat('Time elapsed: ', proc.time() - .proctime00,'\n') Time elapsed: 1.04 0.1 1.12 NA NA > > ## re-starting with medoids from pv6 shouldn't change: > pv6. <- pam(votes.repub, 6, medoids = pv6$id.med, trace = 3) C pam(): computing 1226 dissimilarities from 50 x 31 matrix: [Ok] pam()'s bswap(*, s=281.951, pamonce=0): medoids given; after build: medoids are 2 10 15 31 40 46 and min.dist dysma[1:n] are 48.2 0 37.7 56 35.8 28.5 28.6 31.7 54.1 0 51.7 33.2 27.3 30.5 0 35.1 25.4 58.3 36.9 26.7 48.4 28.1 33.2 63.1 21.1 28.6 37.5 35.8 29.8 31.3 0 32 29.9 35.7 30.9 35.1 27.8 35.7 50.2 0 26.2 30.2 45.2 34.1 33.8 0 28.5 35.1 34.2 28.8 end{bswap()}, end{cstat()} > identical(pv6[nm3], pv6.[nm3]) [1] TRUE > > ## This example seg.faulted at some point: > d.st <- data.frame(V1= c(9, 12, 12, 15, 9, 9, 13, 11, 15, 10, 13, 13, + 13, 15, 8, 13, 13, 10, 7, 9, 6, 11, 3), + V2= c(5, 9, 3, 5, 1, 1, 2, NA, 10, 1, 4, 7, + 4, NA, NA, 5, 2, 4, 3, 3, 6, 1, 1), + V3 = c(63, 41, 59, 50, 290, 226, 60, 36, 32, 121, 70, 51, + 79, 32, 42, 39, 76, 60, 56, 88, 57, 309, 254), + V4 = c(146, 43, 78, 88, 314, 149, 78, NA, 238, 153, 159, 222, + 203, NA, NA, 74, 100, 111, 9, 180, 50, 256, 107)) > dd <- daisy(d.st, stand = TRUE) > (r0 <- pam(dd, 5))# cluster 5 = { 23 } -- on single observation Medoids: ID [1,] 15 15 [2,] 8 8 [3,] 14 14 [4,] 22 22 [5,] 23 23 Clustering vector: [1] 1 2 2 3 4 4 2 2 3 2 2 2 2 3 1 2 2 2 1 1 1 4 5 Objective function: build swap 0.9368049 0.8621860 Available components: [1] "medoids" "id.med" "clustering" "objective" "isolation" [6] "clusinfo" "silinfo" "diss" "call" > ## pam doing the "daisy" computation internally: > r0s <- pam(d.st, 5, stand=TRUE, keep.diss=FALSE, keep.data=FALSE) > (ii <- which(names(r0) %in% c("call","medoids"))) [1] 1 9 > stopifnot(all.equal(r0[-ii], r0s[-ii], tol=1e-14), + identical(r0s$medoids, data.matrix(d.st)[r0$medoids, ])) > > ## This gave only 3 different medoids -> and seg.fault: > (r5 <- pam(dd, 5, medoids = c(1,3,20,2,5), trace = 2)) # now "fine" pam()'s bswap(*, s=8.51931, pamonce=0): medoids given; after build: medoids are 1 2 3 5 20 swp new 14 <-> 2 old; decreasing diss. 29.8745 by -5.50096 swp new 15 <-> 1 old; decreasing diss. 24.3735 by -2.20162 swp new 6 <-> 20 old; decreasing diss. 22.1719 by -2.12745 swp new 8 <-> 3 old; decreasing diss. 20.0444 by -0.201608 end{bswap()}, end{cstat()} Medoids: ID [1,] 15 15 [2,] 8 8 [3,] 14 14 [4,] 5 5 [5,] 6 6 Clustering vector: [1] 1 2 2 3 4 5 2 2 3 5 2 2 2 3 1 2 2 2 1 1 1 4 5 Objective function: build swap 1.2988899 0.8627319 Available components: [1] "medoids" "id.med" "clustering" "objective" "isolation" [6] "clusinfo" "silinfo" "diss" "call" > > dev.off() null device 1 > > ##------------------------ Testing pam() with new "pamonce" argument: > > ## This is from "next version of Matrix" test-tools-1.R: > showSys.time <- function(expr) { + ## prepend 'Time' for R CMD Rdiff + st <- system.time(expr) + writeLines(paste("Time", capture.output(print(st)))) + invisible(st) + } > show6Ratios <- function(...) { + stopifnot(length(rgs <- list(...)) == 6, + nchar(ns <- names(rgs)) > 0) + r <- round(cbind(..1, ..2, ..3, ..4, ..5, ..6)[c(1,5),], 5) + dimnames(r) <- list(paste("Time ", rownames(r)), ns) + r + } > > > n <- 1000 > ## If not enough cases, all CPU times equals 0. > n <- 500 # for now, and automatic testing > > sd <- 0.5 > set.seed(13) > n2 <- as.integer(round(n * 1.5)) > x <- rbind(cbind(rnorm( n,0,sd), rnorm( n,0,sd)), + cbind(rnorm(n2,5,sd), rnorm(n2,5,sd)), + cbind(rnorm(n2,7,sd), rnorm(n2,7,sd)), + cbind(rnorm(n2,9,sd), rnorm(n2,9,sd))) > > > ## original algorithm > st0 <- showSys.time(pamx <- pam(x, 4, trace.lev=2))# 8.157 0.024 8.233 C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok] pam()'s bswap(*, s=15.7788, pamonce=0): build 4 medoids: new repr. 1268 new repr. 414 new repr. 2153 new repr. 915 after build: medoids are 414 915 1268 2153 swp new 1793 <-> 1268 old; decreasing diss. 1862.37 by -129.13 end{bswap()}, end{cstat()} Time user system elapsed Time 1.05 0.01 1.06 > ## bswapPamOnce algorithm > st1 <- showSys.time(pamxonce <- pam(x, 4, pamonce=TRUE, trace.lev=2))# 6.122 0.024 6.181 C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok] pam()'s bswap(*, s=15.7788, pamonce=1): build 4 medoids: new repr. 1268 new repr. 414 new repr. 2153 new repr. 915 after build: medoids are 414 915 1268 2153 swp new 1793 <-> 1268 old; decreasing diss. 1862.37 by -129.13 end{bswap()}, end{cstat()} Time user system elapsed Time 0.69 0.00 0.69 > ## bswapPamOnceDistIndice > st2 <- showSys.time(pamxonce2 <- pam(x, 4, pamonce = 2, trace.lev=2))# 4.101 0.024 4.151 C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok] pam()'s bswap(*, s=15.7788, pamonce=2): build 4 medoids: new repr. 1268 new repr. 414 new repr. 2153 new repr. 915 after build: medoids are 414 915 1268 2153 swp new 1793 <-> 1268 old; decreasing diss. 1862.37 by -129.13 end{bswap()}, end{cstat()} Time user system elapsed Time 0.51 0.01 0.53 > ## bswapPamSchubert FastPAM1 > st3 <- showSys.time(pamxonce3 <- pam(x, 4, pamonce = 3, trace.lev=2))# C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok] pam()'s bswap(*, s=15.7788, pamonce=3): build 4 medoids: new repr. 1268 new repr. 414 new repr. 2153 new repr. 915 after build: medoids are 414 915 1268 2153 swp new 1793 <-> 1268 old; decreasing diss. 1862.37 by -129.13 end{bswap()}, end{cstat()} Time user system elapsed Time 0.47 0.01 0.49 > ## bswapPamSchubert FastPAM2 > st4 <- showSys.time(pamxonce4 <- pam(x, 4, pamonce = 4, trace.lev=2))# C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok] pam()'s bswap(*, s=15.7788, pamonce=4): build 4 medoids: new repr. 1268 new repr. 414 new repr. 2153 new repr. 915 after build: medoids are 414 915 1268 2153 swp new 1793 <-> 1268 old; decreasing diss. 1862.37 by -129.13 end{bswap()}, end{cstat()} Time user system elapsed Time 0.34 0.03 0.37 > ## bswapPamSchubert FastPAM2 with linearized memory access > st5 <- showSys.time(pamxonce5 <- pam(x, 4, pamonce = 5, trace.lev=2))# C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok] pam()'s bswap(*, s=15.7788, pamonce=5): build 4 medoids: new repr. 1268 new repr. 414 new repr. 2153 new repr. 915 after build: medoids are 414 915 1268 2153 swp new 1793 <-> 1268 old; decreasing diss. 1862.37 by -129.13 end{bswap()}, end{cstat()} Time user system elapsed Time 0.41 0.00 0.41 > ## bswapPamSchubert FasterPAM > st6 <- showSys.time(pamxonce6 <- pam(x, 4, pamonce = 6, trace.lev=2))# C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok] pam()'s bswap(*, s=15.7788, pamonce=6): build 4 medoids: new repr. 1268 new repr. 414 new repr. 2153 new repr. 915 after build: medoids are 414 915 1268 2153 swp new 1251 <-> 1268 old; decreasing diss. 1862.37 by -27.6945 swp new 1255 <-> 1251 old; decreasing diss. 1834.68 by -81.213 swp new 1259 <-> 1255 old; decreasing diss. 1753.46 by -4.71205 swp new 1265 <-> 1259 old; decreasing diss. 1748.75 by -1.5194 swp new 1280 <-> 1265 old; decreasing diss. 1747.23 by -1.34867 swp new 1300 <-> 1280 old; decreasing diss. 1745.88 by -9.69283 swp new 1421 <-> 1300 old; decreasing diss. 1736.19 by -2.94296 swp new 1793 <-> 1421 old; decreasing diss. 1733.25 by -0.00639415 end{bswap()}, end{cstat()} Time user system elapsed Time 0.37 0.01 0.39 > show6Ratios('6:orig' = st6/st0, '5:orig' = st5/st0, '4:orig' = st4/st0, '3:orig' = st3/st0, '2:orig' = st2/st0, '1:orig' = st1/st0) 6:orig 5:orig 4:orig 3:orig 2:orig 1:orig Time user.self 0.35238 0.39048 0.32381 0.44762 0.48571 0.65714 Time sys.child NA NA NA NA NA NA > > ## only call element is not equal > (icall <- which(names(pamx) == "call")) [1] 9 > pamx[[icall]] pam(x = x, k = 4, trace.lev = 2) > stopifnot(all.equal(pamx [-icall], pamxonce [-icall]), + all.equal(pamxonce[-icall], pamxonce2[-icall]), + all.equal(pamxonce[-icall], pamxonce3[-icall]), + all.equal(pamxonce[-icall], pamxonce4[-icall]), + all.equal(pamxonce[-icall], pamxonce5[-icall]), + all.equal(pamxonce[-icall], pamxonce6[-icall])) > > ## Same using specified medoids > (med0 <- 1 + round(n* c(0,1, 2.5, 4)))# lynne (~ 2010, AMD Phenom II X4 925) [1] 1 501 1251 2001 > st0 <- showSys.time(pamxst <- pam(x, 4, medoids = med0, trace.lev=2))# 13.071 0.024 13.177 C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok] pam()'s bswap(*, s=15.7788, pamonce=0): medoids given; after build: medoids are 1 501 1251 2001 swp new 915 <-> 501 old; decreasing diss. 2126.83 by -197.507 swp new 1793 <-> 1251 old; decreasing diss. 1929.32 by -101.336 swp new 414 <-> 1 old; decreasing diss. 1827.98 by -86.3404 swp new 2153 <-> 2001 old; decreasing diss. 1741.64 by -8.40201 end{bswap()}, end{cstat()} Time user system elapsed Time 1.86 0.00 1.86 > st1 <- showSys.time(pamxoncest <- pam(x, 4, medoids = med0, pamonce=TRUE, trace.lev=2))# 8.503 0.024 8.578 C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok] pam()'s bswap(*, s=15.7788, pamonce=1): medoids given; after build: medoids are 1 501 1251 2001 swp new 915 <-> 501 old; decreasing diss. 2126.83 by -197.507 swp new 1793 <-> 1251 old; decreasing diss. 1929.32 by -101.336 swp new 414 <-> 1 old; decreasing diss. 1827.98 by -86.3404 swp new 2153 <-> 2001 old; decreasing diss. 1741.64 by -8.40201 end{bswap()}, end{cstat()} Time user system elapsed Time 1.17 0.01 1.19 > st2 <- showSys.time(pamxonce2st <- pam(x, 4, medoids = med0, pamonce=2, trace.lev=2))# 5.587 0.025 5.647 C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok] pam()'s bswap(*, s=15.7788, pamonce=2): medoids given; after build: medoids are 1 501 1251 2001 swp new 915 <-> 501 old; decreasing diss. 2126.83 by -197.507 swp new 1793 <-> 1251 old; decreasing diss. 1929.32 by -101.336 swp new 414 <-> 1 old; decreasing diss. 1827.98 by -86.3404 swp new 2153 <-> 2001 old; decreasing diss. 1741.64 by -8.40201 end{bswap()}, end{cstat()} Time user system elapsed Time 0.75 0.02 0.77 > st3 <- showSys.time(pamxonce3st <- pam(x, 4, medoids = med0, pamonce=3, trace.lev=2))# C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok] pam()'s bswap(*, s=15.7788, pamonce=3): medoids given; after build: medoids are 1 501 1251 2001 swp new 915 <-> 501 old; decreasing diss. 2126.83 by -197.507 swp new 1793 <-> 1251 old; decreasing diss. 1929.32 by -101.336 swp new 414 <-> 1 old; decreasing diss. 1827.98 by -86.3404 swp new 2153 <-> 2001 old; decreasing diss. 1741.64 by -8.40201 end{bswap()}, end{cstat()} Time user system elapsed Time 0.41 0.02 0.42 > st4 <- showSys.time(pamxonce4st <- pam(x, 4, medoids = med0, pamonce=4, trace.lev=2))# C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok] pam()'s bswap(*, s=15.7788, pamonce=4): medoids given; after build: medoids are 1 501 1251 2001 swp new 915 <-> 501 old; decreasing diss. 2126.83 by -197.507 fswp new 1421 <-> 1251 old; decreasing diss. 1929.32 by -101.326 fswp new 414 <-> 1 old; decreasing diss. 1827.99 by -86.3404 fswp new 2153 <-> 2001 old; decreasing diss. 1741.65 by -8.40546 swp new 1793 <-> 1421 old; decreasing diss. 1733.25 by -0.00639415 end{bswap()}, end{cstat()} Time user system elapsed Time 0.3 0.0 0.3 > st5 <- showSys.time(pamxonce5st <- pam(x, 4, medoids = med0, pamonce=5, trace.lev=2))# C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok] pam()'s bswap(*, s=15.7788, pamonce=5): medoids given; after build: medoids are 1 501 1251 2001 swp new 915 <-> 501 old; decreasing diss. 2126.83 by -197.507 fswp new 1421 <-> 1251 old; decreasing diss. 1929.32 by -101.326 fswp new 414 <-> 1 old; decreasing diss. 1827.99 by -86.3404 fswp new 2153 <-> 2001 old; decreasing diss. 1741.65 by -8.40546 swp new 1793 <-> 1421 old; decreasing diss. 1733.25 by -0.00639415 end{bswap()}, end{cstat()} Time user system elapsed Time 0.27 0.00 0.26 > st6 <- showSys.time(pamxonce6st <- pam(x, 4, medoids = med0, pamonce=6, trace.lev=2))# C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok] pam()'s bswap(*, s=15.7788, pamonce=6): medoids given; after build: medoids are 1 501 1251 2001 swp new 8 <-> 1 old; decreasing diss. 2126.83 by -33.2528 swp new 12 <-> 8 old; decreasing diss. 2093.57 by -32.0203 swp new 15 <-> 12 old; decreasing diss. 2061.55 by -2.88573 swp new 16 <-> 15 old; decreasing diss. 2058.67 by -3.50571 swp new 33 <-> 16 old; decreasing diss. 2055.16 by -0.382726 swp new 56 <-> 33 old; decreasing diss. 2054.78 by -0.660581 swp new 70 <-> 56 old; decreasing diss. 2054.12 by -9.63432 swp new 86 <-> 70 old; decreasing diss. 2044.48 by -2.56554 swp new 123 <-> 86 old; decreasing diss. 2041.92 by -1.30247 swp new 414 <-> 123 old; decreasing diss. 2040.62 by -0.130313 swp new 502 <-> 501 old; decreasing diss. 2040.49 by -36.5109 swp new 507 <-> 502 old; decreasing diss. 2003.97 by -131.351 swp new 509 <-> 507 old; decreasing diss. 1872.62 by -14.3528 swp new 530 <-> 509 old; decreasing diss. 1858.27 by -7.60641 swp new 542 <-> 530 old; decreasing diss. 1850.66 by -2.78128 swp new 574 <-> 542 old; decreasing diss. 1847.88 by -4.18202 swp new 913 <-> 574 old; decreasing diss. 1843.7 by -0.343729 swp new 915 <-> 913 old; decreasing diss. 1843.36 by -0.378301 swp new 1255 <-> 1251 old; decreasing diss. 1842.98 by -81.0222 swp new 1259 <-> 1255 old; decreasing diss. 1761.96 by -4.71205 swp new 1265 <-> 1259 old; decreasing diss. 1757.24 by -1.6954 swp new 1280 <-> 1265 old; decreasing diss. 1755.55 by -1.25118 swp new 1300 <-> 1280 old; decreasing diss. 1754.3 by -9.70566 swp new 1421 <-> 1300 old; decreasing diss. 1744.59 by -2.93951 swp new 1793 <-> 1421 old; decreasing diss. 1741.65 by -0.00984953 swp new 2089 <-> 2001 old; decreasing diss. 1741.64 by -3.18091 swp new 2153 <-> 2089 old; decreasing diss. 1738.46 by -5.2211 end{bswap()}, end{cstat()} Time user system elapsed Time 0.22 0.02 0.23 > show6Ratios('6:orig' = st6/st0, '5:orig' = st5/st0, '4:orig' = st4/st0, '3:orig' = st3/st0, '2:orig' = st2/st0, '1:orig' = st1/st0) 6:orig 5:orig 4:orig 3:orig 2:orig 1:orig Time user.self 0.11828 0.14516 0.16129 0.22043 0.40323 0.62903 Time sys.child NA NA NA NA NA NA > > ## only call element is not equal > stopifnot(all.equal(pamxst [-icall], pamxoncest [-icall]), + all.equal(pamxoncest[-icall], pamxonce2st[-icall]), + all.equal(pamxoncest[-icall], pamxonce3st[-icall]), + all.equal(pamxoncest[-icall], pamxonce4st[-icall]), + all.equal(pamxoncest[-icall], pamxonce5st[-icall]), + all.equal(pamxoncest[-icall], pamxonce6st[-icall])) > > ## Different starting values > med0 <- 1:4 # lynne (~ 2010, AMD Phenom II X4 925) > st0 <- showSys.time(pamxst <- pam(x, 4, medoids = med0, trace.lev=2))# 13.416 0.023 13.529 C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok] pam()'s bswap(*, s=15.7788, pamonce=0): medoids given; after build: medoids are 1 2 3 4 swp new 1421 <-> 4 old; decreasing diss. 21009.4 by -15939.9 swp new 2153 <-> 3 old; decreasing diss. 5069.52 by -1657.88 swp new 915 <-> 2 old; decreasing diss. 3411.65 by -1592.06 swp new 414 <-> 1 old; decreasing diss. 1819.59 by -86.3404 swp new 1793 <-> 1421 old; decreasing diss. 1733.25 by -0.00639415 end{bswap()}, end{cstat()} Time user system elapsed Time 2.18 0.01 2.22 > st1 <- showSys.time(pamxoncest <- pam(x, 4, medoids = med0, pamonce=TRUE, trace.lev=2))# 8.384 0.024 8.459 C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok] pam()'s bswap(*, s=15.7788, pamonce=1): medoids given; after build: medoids are 1 2 3 4 swp new 1421 <-> 4 old; decreasing diss. 21009.4 by -15939.9 swp new 2153 <-> 3 old; decreasing diss. 5069.52 by -1657.88 swp new 915 <-> 2 old; decreasing diss. 3411.65 by -1592.06 swp new 414 <-> 1 old; decreasing diss. 1819.59 by -86.3404 swp new 1793 <-> 1421 old; decreasing diss. 1733.25 by -0.00639415 end{bswap()}, end{cstat()} Time user system elapsed Time 1.16 0.02 1.17 > st2 <- showSys.time(pamxonce2st <- pam(x, 4, medoids = med0, pamonce=2, trace.lev=2))# 5.455 0.030 5.520 C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok] pam()'s bswap(*, s=15.7788, pamonce=2): medoids given; after build: medoids are 1 2 3 4 swp new 1421 <-> 4 old; decreasing diss. 21009.4 by -15939.9 swp new 2153 <-> 3 old; decreasing diss. 5069.52 by -1657.88 swp new 915 <-> 2 old; decreasing diss. 3411.65 by -1592.06 swp new 414 <-> 1 old; decreasing diss. 1819.59 by -86.3404 swp new 1793 <-> 1421 old; decreasing diss. 1733.25 by -0.00639415 end{bswap()}, end{cstat()} Time user system elapsed Time 0.89 0.01 0.91 > st3 <- showSys.time(pamxonce3st <- pam(x, 4, medoids = med0, pamonce=3, trace.lev=2))# C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok] pam()'s bswap(*, s=15.7788, pamonce=3): medoids given; after build: medoids are 1 2 3 4 swp new 1421 <-> 4 old; decreasing diss. 21009.4 by -15939.9 swp new 2153 <-> 3 old; decreasing diss. 5069.52 by -1657.88 swp new 915 <-> 2 old; decreasing diss. 3411.65 by -1592.06 swp new 414 <-> 1 old; decreasing diss. 1819.59 by -86.3404 swp new 1793 <-> 1421 old; decreasing diss. 1733.25 by -0.00639415 end{bswap()}, end{cstat()} Time user system elapsed Time 0.56 0.00 0.56 > st4 <- showSys.time(pamxonce4st <- pam(x, 4, medoids = med0, pamonce=4, trace.lev=2))# C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok] pam()'s bswap(*, s=15.7788, pamonce=4): medoids given; after build: medoids are 1 2 3 4 swp new 1421 <-> 4 old; decreasing diss. 21009.4 by -15939.9 swp new 2153 <-> 3 old; decreasing diss. 5069.52 by -1657.88 swp new 915 <-> 2 old; decreasing diss. 3411.65 by -1592.06 swp new 414 <-> 1 old; decreasing diss. 1819.59 by -86.3404 fswp new 1793 <-> 1421 old; decreasing diss. 1733.25 by -0.00639415 end{bswap()}, end{cstat()} Time user system elapsed Time 0.40 0.05 0.45 > st5 <- showSys.time(pamxonce5st <- pam(x, 4, medoids = med0, pamonce=5, trace.lev=2))# C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok] pam()'s bswap(*, s=15.7788, pamonce=5): medoids given; after build: medoids are 1 2 3 4 swp new 1421 <-> 4 old; decreasing diss. 21009.4 by -15939.9 swp new 2153 <-> 3 old; decreasing diss. 5069.52 by -1657.88 swp new 915 <-> 2 old; decreasing diss. 3411.65 by -1592.06 swp new 414 <-> 1 old; decreasing diss. 1819.59 by -86.3404 fswp new 1793 <-> 1421 old; decreasing diss. 1733.25 by -0.00639415 end{bswap()}, end{cstat()} Time user system elapsed Time 0.34 0.01 0.36 > st6 <- showSys.time(pamxonce6st <- pam(x, 4, medoids = med0, pamonce=6, trace.lev=2))# C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok] pam()'s bswap(*, s=15.7788, pamonce=6): medoids given; after build: medoids are 1 2 3 4 swp new 7 <-> 3 old; decreasing diss. 21009.4 by -4.9986 swp new 8 <-> 2 old; decreasing diss. 21004.4 by -16.4723 swp new 11 <-> 7 old; decreasing diss. 20987.9 by -12.0798 swp new 12 <-> 8 old; decreasing diss. 20975.9 by -3.31491 swp new 13 <-> 1 old; decreasing diss. 20972.5 by -4.88251 swp new 14 <-> 13 old; decreasing diss. 20967.7 by -1.90148 swp new 15 <-> 14 old; decreasing diss. 20965.8 by -9.59363 swp new 22 <-> 11 old; decreasing diss. 20956.2 by -10.0478 swp new 24 <-> 15 old; decreasing diss. 20946.1 by -7.99457 swp new 26 <-> 12 old; decreasing diss. 20938.1 by -3.0991 swp new 44 <-> 22 old; decreasing diss. 20935 by -880.436 swp new 45 <-> 4 old; decreasing diss. 20054.6 by -9.44638 swp new 55 <-> 26 old; decreasing diss. 20045.1 by -1.77816 swp new 57 <-> 24 old; decreasing diss. 20043.4 by -1.76138 swp new 58 <-> 44 old; decreasing diss. 20041.6 by -178.122 swp new 63 <-> 45 old; decreasing diss. 19863.5 by -0.34634 swp new 71 <-> 57 old; decreasing diss. 19863.1 by -1.49747 swp new 75 <-> 63 old; decreasing diss. 19861.6 by -1.31804 swp new 76 <-> 71 old; decreasing diss. 19860.3 by -1.42789 swp new 80 <-> 55 old; decreasing diss. 19858.9 by -5.29615 swp new 81 <-> 75 old; decreasing diss. 19853.6 by -0.164308 swp new 83 <-> 76 old; decreasing diss. 19853.4 by -0.0877432 swp new 115 <-> 81 old; decreasing diss. 19853.3 by -0.303527 swp new 171 <-> 58 old; decreasing diss. 19853 by -971.874 swp new 185 <-> 115 old; decreasing diss. 18881.2 by -0.471238 swp new 192 <-> 80 old; decreasing diss. 18880.7 by -0.294662 swp new 257 <-> 185 old; decreasing diss. 18880.4 by -0.466733 swp new 290 <-> 257 old; decreasing diss. 18879.9 by -0.105762 swp new 309 <-> 83 old; decreasing diss. 18879.8 by -0.0395709 swp new 419 <-> 192 old; decreasing diss. 18879.8 by -0.0439214 swp new 425 <-> 309 old; decreasing diss. 18879.7 by -0.136105 swp new 471 <-> 425 old; decreasing diss. 18879.6 by -0.244642 swp new 501 <-> 171 old; decreasing diss. 18879.4 by -11830.7 swp new 502 <-> 471 old; decreasing diss. 7048.64 by -273.113 swp new 503 <-> 290 old; decreasing diss. 6775.52 by -813.133 swp new 504 <-> 502 old; decreasing diss. 5962.39 by -20.8894 swp new 507 <-> 504 old; decreasing diss. 5941.5 by -42.7153 swp new 515 <-> 501 old; decreasing diss. 5898.79 by -0.453931 swp new 523 <-> 515 old; decreasing diss. 5898.33 by -67.1248 swp new 526 <-> 507 old; decreasing diss. 5831.21 by -0.673248 swp new 527 <-> 526 old; decreasing diss. 5830.53 by -2.26904 swp new 537 <-> 503 old; decreasing diss. 5828.26 by -3.1636 swp new 542 <-> 527 old; decreasing diss. 5825.1 by -2.0623 swp new 545 <-> 542 old; decreasing diss. 5823.04 by -17.9136 swp new 547 <-> 523 old; decreasing diss. 5805.13 by -194.143 swp new 573 <-> 547 old; decreasing diss. 5610.98 by -607.192 swp new 576 <-> 545 old; decreasing diss. 5003.79 by -0.801911 swp new 579 <-> 573 old; decreasing diss. 5002.99 by -347.734 swp new 592 <-> 576 old; decreasing diss. 4655.26 by -0.997177 swp new 604 <-> 592 old; decreasing diss. 4654.26 by -0.808458 swp new 617 <-> 604 old; decreasing diss. 4653.45 by -1.02162 swp new 813 <-> 537 old; decreasing diss. 4652.43 by -0.254896 swp new 883 <-> 617 old; decreasing diss. 4652.17 by -1.83048 swp new 955 <-> 813 old; decreasing diss. 4650.34 by -0.591944 swp new 1015 <-> 883 old; decreasing diss. 4649.75 by -0.0303283 swp new 1016 <-> 955 old; decreasing diss. 4649.72 by -0.343593 swp new 1086 <-> 1016 old; decreasing diss. 4649.38 by -0.0942057 swp new 1088 <-> 1015 old; decreasing diss. 4649.28 by -0.0747132 swp new 1111 <-> 1086 old; decreasing diss. 4649.21 by -0.996659 swp new 1131 <-> 1088 old; decreasing diss. 4648.21 by -0.773913 swp new 1134 <-> 1111 old; decreasing diss. 4647.44 by -0.174449 swp new 1151 <-> 1131 old; decreasing diss. 4647.26 by -0.319467 swp new 1251 <-> 579 old; decreasing diss. 4646.94 by -1367.16 swp new 1252 <-> 1251 old; decreasing diss. 3279.79 by -27.203 swp new 1253 <-> 1151 old; decreasing diss. 3252.58 by -137.657 swp new 1255 <-> 1252 old; decreasing diss. 3114.93 by -52.4651 swp new 1257 <-> 1253 old; decreasing diss. 3062.46 by -42.3678 swp new 1259 <-> 1255 old; decreasing diss. 3020.09 by -1.87135 swp new 1266 <-> 1257 old; decreasing diss. 3018.22 by -90.6385 swp new 1280 <-> 1259 old; decreasing diss. 2927.58 by -20.3614 swp new 1283 <-> 1266 old; decreasing diss. 2907.22 by -272.98 swp new 1288 <-> 1280 old; decreasing diss. 2634.24 by -1.69952 swp new 1300 <-> 1288 old; decreasing diss. 2632.54 by -9.58469 swp new 1325 <-> 1300 old; decreasing diss. 2622.96 by -7.37653 swp new 1612 <-> 1283 old; decreasing diss. 2615.58 by -2.38886 swp new 2001 <-> 1612 old; decreasing diss. 2613.19 by -788.545 swp new 2089 <-> 2001 old; decreasing diss. 1824.65 by -3.28836 swp new 2153 <-> 2089 old; decreasing diss. 1821.36 by -5.16445 swp new 12 <-> 419 old; decreasing diss. 1816.19 by -28.3676 swp new 15 <-> 12 old; decreasing diss. 1787.83 by -2.88573 swp new 16 <-> 15 old; decreasing diss. 1784.94 by -3.50571 swp new 33 <-> 16 old; decreasing diss. 1781.43 by -0.382726 swp new 56 <-> 33 old; decreasing diss. 1781.05 by -0.660581 swp new 70 <-> 56 old; decreasing diss. 1780.39 by -9.63432 swp new 86 <-> 70 old; decreasing diss. 1770.76 by -2.56554 swp new 123 <-> 86 old; decreasing diss. 1768.19 by -1.30247 swp new 414 <-> 123 old; decreasing diss. 1766.89 by -0.130313 swp new 507 <-> 1134 old; decreasing diss. 1766.76 by -1.67967 swp new 509 <-> 507 old; decreasing diss. 1765.08 by -11.8255 swp new 530 <-> 509 old; decreasing diss. 1753.25 by -9.54887 swp new 542 <-> 530 old; decreasing diss. 1743.7 by -2.59694 swp new 574 <-> 542 old; decreasing diss. 1741.11 by -3.50085 swp new 913 <-> 574 old; decreasing diss. 1737.61 by -0.356354 swp new 915 <-> 913 old; decreasing diss. 1737.25 by -0.471447 swp new 1300 <-> 1325 old; decreasing diss. 1736.78 by -0.589135 swp new 1421 <-> 1300 old; decreasing diss. 1736.19 by -2.94296 swp new 1793 <-> 1421 old; decreasing diss. 1733.25 by -0.00639415 end{bswap()}, end{cstat()} Time user system elapsed Time 0.27 0.00 0.26 > show6Ratios('6:orig' = st6/st0, '5:orig' = st5/st0, '4:orig' = st4/st0, '3:orig' = st3/st0, '2:orig' = st2/st0, '1:orig' = st1/st0) 6:orig 5:orig 4:orig 3:orig 2:orig 1:orig Time user.self 0.12385 0.15596 0.18349 0.25688 0.40826 0.53211 Time sys.child NA NA NA NA NA NA > > ## only call element is not equal > stopifnot(all.equal(pamxst [-icall], pamxoncest [-icall]), + all.equal(pamxoncest[-icall], pamxonce2st[-icall]), + all.equal(pamxoncest[-icall], pamxonce3st[-icall]), + all.equal(pamxoncest[-icall], pamxonce4st[-icall]), + all.equal(pamxoncest[-icall], pamxonce5st[-icall]), + all.equal(pamxoncest[-icall], pamxonce6st[-icall])) > > > ## Medoid bug --- MM: Fixed, well "0L+ hack", in my pam.q, on 2012-01-31 > ## ---------- > med0 <- (1:6) > st0 <- showSys.time(pamxst <- pam(x, 6, medoids = med0 , trace.lev=2)) C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok] pam()'s bswap(*, s=15.7788, pamonce=0): medoids given; after build: medoids are 1 2 3 4 5 6 swp new 1421 <-> 6 old; decreasing diss. 20991.1 by -15949.5 swp new 2153 <-> 4 old; decreasing diss. 5041.66 by -1676.25 swp new 915 <-> 3 old; decreasing diss. 3365.41 by -1671.37 swp new 325 <-> 2 old; decreasing diss. 1694.04 by -53.8582 swp new 2720 <-> 5 old; decreasing diss. 1640.18 by -26.6572 swp new 2696 <-> 2153 old; decreasing diss. 1613.53 by -19.0531 swp new 52 <-> 1 old; decreasing diss. 1594.47 by -13.965 swp new 2709 <-> 2720 old; decreasing diss. 1580.51 by -5.81848 swp new 199 <-> 325 old; decreasing diss. 1574.69 by -2.65496 swp new 438 <-> 52 old; decreasing diss. 1572.03 by -1.77054 swp new 2082 <-> 2696 old; decreasing diss. 1570.26 by -0.187256 end{bswap()}, end{cstat()} Time user system elapsed Time 5.85 0.03 5.89 > stopifnot(identical(med0, 1:6)) > med0 <- (1:6) > st1 <- showSys.time(pamxst.1 <- pam(x, 6, medoids = med0 , pamonce=1, trace.lev=2)) C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok] pam()'s bswap(*, s=15.7788, pamonce=1): medoids given; after build: medoids are 1 2 3 4 5 6 swp new 1421 <-> 6 old; decreasing diss. 20991.1 by -15949.5 swp new 2153 <-> 4 old; decreasing diss. 5041.66 by -1676.25 swp new 915 <-> 3 old; decreasing diss. 3365.41 by -1671.37 swp new 325 <-> 2 old; decreasing diss. 1694.04 by -53.8582 swp new 2720 <-> 5 old; decreasing diss. 1640.18 by -26.6572 swp new 2696 <-> 2153 old; decreasing diss. 1613.53 by -19.0531 swp new 52 <-> 1 old; decreasing diss. 1594.47 by -13.965 swp new 2709 <-> 2720 old; decreasing diss. 1580.51 by -5.81848 swp new 199 <-> 325 old; decreasing diss. 1574.69 by -2.65496 swp new 438 <-> 52 old; decreasing diss. 1572.03 by -1.77054 swp new 2082 <-> 2696 old; decreasing diss. 1570.26 by -0.187256 end{bswap()}, end{cstat()} Time user system elapsed Time 3.55 0.02 3.56 > stopifnot(identical(med0, 1:6)) > med0 <- (1:6) > st2 <- showSys.time(pamxst.2 <- pam(x, 6, medoids = med0 , pamonce=2, trace.lev=2)) C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok] pam()'s bswap(*, s=15.7788, pamonce=2): medoids given; after build: medoids are 1 2 3 4 5 6 swp new 1421 <-> 6 old; decreasing diss. 20991.1 by -15949.5 swp new 2153 <-> 4 old; decreasing diss. 5041.66 by -1676.25 swp new 915 <-> 3 old; decreasing diss. 3365.41 by -1671.37 swp new 325 <-> 2 old; decreasing diss. 1694.04 by -53.8582 swp new 2720 <-> 5 old; decreasing diss. 1640.18 by -26.6572 swp new 2696 <-> 2153 old; decreasing diss. 1613.53 by -19.0531 swp new 52 <-> 1 old; decreasing diss. 1594.47 by -13.965 swp new 2709 <-> 2720 old; decreasing diss. 1580.51 by -5.81848 swp new 199 <-> 325 old; decreasing diss. 1574.69 by -2.65496 swp new 438 <-> 52 old; decreasing diss. 1572.03 by -1.77054 swp new 2082 <-> 2696 old; decreasing diss. 1570.26 by -0.187256 end{bswap()}, end{cstat()} Time user system elapsed Time 2.56 0.02 2.58 > stopifnot(identical(med0, 1:6)) > med0 <- (1:6) > st3 <- showSys.time(pamxst.3 <- pam(x, 6, medoids = med0 , pamonce=3, trace.lev=2)) C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok] pam()'s bswap(*, s=15.7788, pamonce=3): medoids given; after build: medoids are 1 2 3 4 5 6 swp new 1421 <-> 6 old; decreasing diss. 20991.1 by -15949.5 swp new 2153 <-> 4 old; decreasing diss. 5041.66 by -1676.25 swp new 915 <-> 3 old; decreasing diss. 3365.41 by -1671.37 swp new 325 <-> 2 old; decreasing diss. 1694.04 by -53.8582 swp new 2720 <-> 5 old; decreasing diss. 1640.18 by -26.6572 swp new 2696 <-> 2153 old; decreasing diss. 1613.53 by -19.0531 swp new 52 <-> 1 old; decreasing diss. 1594.47 by -13.965 swp new 2709 <-> 2720 old; decreasing diss. 1580.51 by -5.81848 swp new 199 <-> 325 old; decreasing diss. 1574.69 by -2.65496 swp new 438 <-> 52 old; decreasing diss. 1572.03 by -1.77054 swp new 2082 <-> 2696 old; decreasing diss. 1570.26 by -0.187256 end{bswap()}, end{cstat()} Time user system elapsed Time 0.86 0.01 0.87 > stopifnot(identical(med0, 1:6)) > med0 <- (1:6) > st4 <- showSys.time(pamxst.4 <- pam(x, 6, medoids = med0 , pamonce=4, trace.lev=2)) C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok] pam()'s bswap(*, s=15.7788, pamonce=4): medoids given; after build: medoids are 1 2 3 4 5 6 swp new 1421 <-> 6 old; decreasing diss. 20991.1 by -15949.5 swp new 2153 <-> 4 old; decreasing diss. 5041.66 by -1676.25 swp new 915 <-> 3 old; decreasing diss. 3365.41 by -1671.37 swp new 325 <-> 2 old; decreasing diss. 1694.04 by -53.8582 fswp new 2720 <-> 5 old; decreasing diss. 1640.18 by -26.6572 swp new 2696 <-> 2153 old; decreasing diss. 1613.53 by -19.0531 fswp new 52 <-> 1 old; decreasing diss. 1594.47 by -13.965 swp new 2709 <-> 2720 old; decreasing diss. 1580.51 by -5.81848 fswp new 199 <-> 325 old; decreasing diss. 1574.69 by -2.65496 swp new 438 <-> 52 old; decreasing diss. 1572.03 by -1.77054 fswp new 2082 <-> 2696 old; decreasing diss. 1570.26 by -0.187256 end{bswap()}, end{cstat()} Time user system elapsed Time 0.56 0.02 0.58 > stopifnot(identical(med0, 1:6)) > med0 <- (1:6) > st5 <- showSys.time(pamxst.5 <- pam(x, 6, medoids = med0 , pamonce=5, trace.lev=2)) C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok] pam()'s bswap(*, s=15.7788, pamonce=5): medoids given; after build: medoids are 1 2 3 4 5 6 swp new 1421 <-> 6 old; decreasing diss. 20991.1 by -15949.5 swp new 2153 <-> 4 old; decreasing diss. 5041.66 by -1676.25 swp new 915 <-> 3 old; decreasing diss. 3365.41 by -1671.37 swp new 325 <-> 2 old; decreasing diss. 1694.04 by -53.8582 fswp new 2720 <-> 5 old; decreasing diss. 1640.18 by -26.6572 swp new 2696 <-> 2153 old; decreasing diss. 1613.53 by -19.0531 fswp new 52 <-> 1 old; decreasing diss. 1594.47 by -13.965 swp new 2709 <-> 2720 old; decreasing diss. 1580.51 by -5.81848 fswp new 199 <-> 325 old; decreasing diss. 1574.69 by -2.65496 swp new 438 <-> 52 old; decreasing diss. 1572.03 by -1.77054 fswp new 2082 <-> 2696 old; decreasing diss. 1570.26 by -0.187256 end{bswap()}, end{cstat()} Time user system elapsed Time 0.49 0.03 0.52 > stopifnot(identical(med0, 1:6)) > med0 <- (1:6) > st6 <- showSys.time(pamxst.6 <- pam(x, 6, medoids = med0 , pamonce=6, trace.lev=2)) C pam(): computing 3779876 dissimilarities from 2750 x 2 matrix: [Ok] pam()'s bswap(*, s=15.7788, pamonce=6): medoids given; after build: medoids are 1 2 3 4 5 6 swp new 7 <-> 6 old; decreasing diss. 20991.1 by -3.78677 swp new 8 <-> 5 old; decreasing diss. 20987.4 by -25.0122 swp new 9 <-> 2 old; decreasing diss. 20962.3 by -6.53934 swp new 10 <-> 7 old; decreasing diss. 20955.8 by -0.133503 swp new 11 <-> 9 old; decreasing diss. 20955.7 by -14.9294 swp new 12 <-> 10 old; decreasing diss. 20940.7 by -2.35016 swp new 13 <-> 12 old; decreasing diss. 20938.4 by -12.1267 swp new 14 <-> 11 old; decreasing diss. 20926.3 by -2.99664 swp new 15 <-> 13 old; decreasing diss. 20923.3 by -11.5871 swp new 20 <-> 1 old; decreasing diss. 20911.7 by -0.0423835 swp new 22 <-> 3 old; decreasing diss. 20911.6 by -8.76936 swp new 23 <-> 20 old; decreasing diss. 20902.9 by -0.779336 swp new 39 <-> 15 old; decreasing diss. 20902.1 by -0.285867 swp new 44 <-> 4 old; decreasing diss. 20901.8 by -889.012 swp new 45 <-> 14 old; decreasing diss. 20012.8 by -0.586001 swp new 46 <-> 45 old; decreasing diss. 20012.2 by -1.1479 swp new 57 <-> 39 old; decreasing diss. 20011.1 by -3.67274 swp new 58 <-> 44 old; decreasing diss. 20007.4 by -189.36 swp new 62 <-> 23 old; decreasing diss. 19818 by -0.626154 swp new 66 <-> 46 old; decreasing diss. 19817.4 by -1.29082 swp new 68 <-> 22 old; decreasing diss. 19816.1 by -0.580804 swp new 75 <-> 62 old; decreasing diss. 19815.5 by -0.860328 swp new 76 <-> 57 old; decreasing diss. 19814.7 by -1.97434 swp new 171 <-> 58 old; decreasing diss. 19812.7 by -968.625 swp new 185 <-> 75 old; decreasing diss. 18844.1 by -0.12972 swp new 198 <-> 68 old; decreasing diss. 18843.9 by -0.533904 swp new 204 <-> 198 old; decreasing diss. 18843.4 by -0.00928895 swp new 218 <-> 185 old; decreasing diss. 18843.4 by -0.0287215 swp new 280 <-> 204 old; decreasing diss. 18843.4 by -0.913559 swp new 329 <-> 280 old; decreasing diss. 18842.5 by -0.101916 swp new 361 <-> 8 old; decreasing diss. 18842.3 by -0.0966188 swp new 402 <-> 361 old; decreasing diss. 18842.3 by -0.0394578 swp new 501 <-> 171 old; decreasing diss. 18842.2 by -11833 swp new 502 <-> 66 old; decreasing diss. 7009.24 by -309.206 swp new 503 <-> 329 old; decreasing diss. 6700.03 by -887.644 swp new 504 <-> 76 old; decreasing diss. 5812.39 by -28.554 swp new 506 <-> 504 old; decreasing diss. 5783.83 by -14.2809 swp new 507 <-> 506 old; decreasing diss. 5769.55 by -19.8604 swp new 508 <-> 507 old; decreasing diss. 5749.69 by -7.88586 swp new 515 <-> 501 old; decreasing diss. 5741.8 by -3.36477 swp new 519 <-> 502 old; decreasing diss. 5738.44 by -1.16993 swp new 523 <-> 515 old; decreasing diss. 5737.27 by -71.9147 swp new 526 <-> 508 old; decreasing diss. 5665.35 by -1.56708 swp new 533 <-> 526 old; decreasing diss. 5663.79 by -1.652 swp new 537 <-> 519 old; decreasing diss. 5662.14 by -0.283073 swp new 540 <-> 537 old; decreasing diss. 5661.85 by -2.35314 swp new 545 <-> 533 old; decreasing diss. 5659.5 by -2.94604 swp new 547 <-> 503 old; decreasing diss. 5656.55 by -221.229 swp new 573 <-> 547 old; decreasing diss. 5435.32 by -574.75 swp new 575 <-> 523 old; decreasing diss. 4860.57 by -17.1525 swp new 579 <-> 573 old; decreasing diss. 4843.42 by -346.495 swp new 593 <-> 575 old; decreasing diss. 4496.93 by -2.83188 swp new 594 <-> 540 old; decreasing diss. 4494.1 by -0.50804 swp new 618 <-> 545 old; decreasing diss. 4493.59 by -0.137577 swp new 660 <-> 618 old; decreasing diss. 4493.45 by -4.45459 swp new 663 <-> 593 old; decreasing diss. 4489 by -0.912682 swp new 709 <-> 663 old; decreasing diss. 4488.08 by -1.44419 swp new 848 <-> 594 old; decreasing diss. 4486.64 by -0.00137738 swp new 991 <-> 709 old; decreasing diss. 4486.64 by -0.173764 swp new 1242 <-> 660 old; decreasing diss. 4486.46 by -0.244432 swp new 1251 <-> 579 old; decreasing diss. 4486.22 by -1369.29 swp new 1252 <-> 402 old; decreasing diss. 3116.93 by -58.5165 swp new 1253 <-> 1252 old; decreasing diss. 3058.42 by -169.451 swp new 1255 <-> 1251 old; decreasing diss. 2888.97 by -30.8092 swp new 1257 <-> 848 old; decreasing diss. 2858.16 by -70.3794 swp new 1262 <-> 1255 old; decreasing diss. 2787.78 by -29.3154 swp new 1266 <-> 1253 old; decreasing diss. 2758.46 by -64.8733 swp new 1282 <-> 1262 old; decreasing diss. 2693.59 by -0.803303 swp new 1283 <-> 1257 old; decreasing diss. 2692.79 by -238.314 swp new 1284 <-> 1266 old; decreasing diss. 2454.47 by -6.79018 swp new 1289 <-> 1284 old; decreasing diss. 2447.68 by -6.25715 swp new 1291 <-> 1289 old; decreasing diss. 2441.42 by -1.33251 swp new 1293 <-> 1291 old; decreasing diss. 2440.09 by -4.73682 swp new 1299 <-> 1293 old; decreasing diss. 2435.35 by -5.10123 swp new 1301 <-> 1282 old; decreasing diss. 2430.25 by -3.83834 swp new 1322 <-> 1301 old; decreasing diss. 2426.41 by -1.61521 swp new 1332 <-> 1322 old; decreasing diss. 2424.8 by -1.66893 swp new 1335 <-> 1299 old; decreasing diss. 2423.13 by -9.28429 swp new 1374 <-> 1332 old; decreasing diss. 2413.85 by -1.14706 swp new 1469 <-> 1374 old; decreasing diss. 2412.7 by -0.0376604 swp new 1583 <-> 1335 old; decreasing diss. 2412.66 by -0.0266074 swp new 1612 <-> 1283 old; decreasing diss. 2412.64 by -1.78413 swp new 2001 <-> 1612 old; decreasing diss. 2410.85 by -794.078 swp new 2089 <-> 2001 old; decreasing diss. 1616.77 by -3.16676 swp new 2153 <-> 2089 old; decreasing diss. 1613.61 by -5.2914 swp new 12 <-> 218 old; decreasing diss. 1608.32 by -9.02144 swp new 15 <-> 12 old; decreasing diss. 1599.29 by -2.88573 swp new 16 <-> 15 old; decreasing diss. 1596.41 by -3.50571 swp new 33 <-> 16 old; decreasing diss. 1592.9 by -0.382726 swp new 56 <-> 33 old; decreasing diss. 1592.52 by -0.660581 swp new 70 <-> 56 old; decreasing diss. 1591.86 by -9.63432 swp new 86 <-> 70 old; decreasing diss. 1582.22 by -2.56554 swp new 123 <-> 86 old; decreasing diss. 1579.66 by -1.30247 swp new 414 <-> 123 old; decreasing diss. 1578.36 by -0.130313 swp new 507 <-> 1242 old; decreasing diss. 1578.23 by -16.7114 swp new 513 <-> 991 old; decreasing diss. 1561.51 by -2.15127 swp new 518 <-> 507 old; decreasing diss. 1559.36 by -7.23052 swp new 556 <-> 518 old; decreasing diss. 1552.13 by -1.79073 swp new 622 <-> 513 old; decreasing diss. 1550.34 by -0.947204 swp new 822 <-> 556 old; decreasing diss. 1549.4 by -0.320612 swp new 926 <-> 622 old; decreasing diss. 1549.07 by -1.31521 swp new 1106 <-> 926 old; decreasing diss. 1547.76 by -0.187491 swp new 1124 <-> 822 old; decreasing diss. 1547.57 by -0.261824 swp new 1194 <-> 1124 old; decreasing diss. 1547.31 by -0.0387596 swp new 1256 <-> 1583 old; decreasing diss. 1547.27 by -1.04235 swp new 1262 <-> 1469 old; decreasing diss. 1546.23 by -2.25214 swp new 1429 <-> 1256 old; decreasing diss. 1543.98 by -0.359624 swp new 1592 <-> 1429 old; decreasing diss. 1543.62 by -0.641983 swp new 2286 <-> 2153 old; decreasing diss. 1542.98 by -0.109986 swp new 2482 <-> 2286 old; decreasing diss. 1542.87 by -0.0744393 end{bswap()}, end{cstat()} Time user system elapsed Time 0.25 0.05 0.29 > stopifnot(identical(med0, 1:6)) > stopifnot(all.equal(pamxst[-icall], pamxst.1 [-icall]), + all.equal(pamxst[-icall], pamxst.2 [-icall]), + all.equal(pamxst[-icall], pamxst.3 [-icall]), + all.equal(pamxst[-icall], pamxst.4 [-icall]), + all.equal(pamxst[-icall], pamxst.5 [-icall])) > # FasterPAM finds a better solution here, by chance > stopifnot(pamxst$objective >= pamxst.6$objective) > > > ## Last Line: > cat('Time elapsed: ', proc.time() - .proctime00,'\n') Time elapsed: 31.11 0.74 31.89 NA NA > > > proc.time() user system elapsed 31.21 0.89 32.12