January, 2016
cl <- hclust(vegdist(dune), "average") groups <- cutree(cl, 4) plot(cl) rect.hclust(cl, 4)
## Hey Joe!
##
##
You must enable Javascript to view this page properly.
.
d <- vegdist(sqrt(mite)) cl <- hclust(d, "complete") plot(cl, hang=-1, cex=0.8) rect.hclust(cl, 4)
gr <- cutree(cl, 4)
Basic analysis
boxplot(WatrCont ~ gr, data=mite.env, col="hotpink", lty=1, pch=16, notch=TRUE)
.
.
.
anova(lm(WatrCont ~ gr, data=mite.env))
## Analysis of Variance Table ## ## Response: WatrCont ## Df Sum Sq Mean Sq F value Pr(>F) ## gr 1 790535 790535 88.427 6.339e-14 *** ## Residuals 68 607917 8940 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
mod <- metaMDS(d, trace = FALSE) plot(mod, dis="si") ordihull(mod, gr, col=1:4, draw="poly") ordispider(mod, gr, col=1:4, label=TRUE)
.
cl <- hclust(vegdist(sqrt(mite))) km <- kmeans(sqrt(mite), 4) plot(cl, hang=-1, label = fitted(km, "classes"), cex=0.7) rect.hclust(cl, 4)
. ## Optimizing \(K\)
plot(cascadeKM(decostand(mite, "hellinger"), 2, 20))
.
fc <- fanny(d, k=4, memb.exp=sqrt(2)) # cluster package head(fc$membership) ## Probability of membership
## [,1] [,2] [,3] [,4] ## 1 0.3918715 0.3618037 0.12316241 0.12316241 ## 2 0.3705928 0.3798974 0.12475488 0.12475488 ## 3 0.3864999 0.3978146 0.10784278 0.10784278 ## 4 0.3754520 0.4383846 0.09308168 0.09308168 ## 5 0.3678309 0.5166475 0.05776076 0.05776076 ## 6 0.3534142 0.5619900 0.04229790 0.04229790
head(fc$clustering) ## Crips clustering
## 1 2 3 4 5 6 ## 1 2 2 2 2 2
.