昨日の続きをすこしだけ。 クラスター分析の手法による結果の違いを確認してみたいと思います。 ウォード法、K-means法と{cluster}パッケージに入っているPAM(Partitioning Around Medoids)という手法を比較してみます。 data(iris) # 結果を2次元で観察したいので、「花弁の長さ」と「花弁の幅」だけを使う # ウォード法 WA <- cutree(hclust(dist(iris[, 3:4]), "ward"), 3) # K-means法 KM <- kmeans(iris[, 3:4], 3, nstart=100)$cluster # PAM。距離にはマンハッタン距離を使用。 library(cluster) PMM <- pam(iris[, 3:4], 3, metric="manhattan", cluster.only=TRUE)