#--- EXAMPLE 1 ------------------------------------------
sig <- diag (2)
cen <- rep (1,2)
x <- rbind (
rmvnorm (360, cen * 0, sig),
rmvnorm (540, cen * 5, sig * 6 - 2),
rmvnorm (100, cen * 2.5, sig * 50)
)
# Two groups and 10\% trimming level
clus <- tclust (x, k=2, alpha=0.1, restr.fact=12)
plot (clus)
plot (clus, labels = "observation")
plot (clus, labels = "cluster")
# Three groups (one of them very scattered) and 0\% trimming level
clus <- tclust (x, k=3, alpha=0.0, restr.fact = 50)
plot (clus)
#--- EXAMPLE 2 ------------------------------------------
data (geyser2)
clus <- tkmeans(geyser2,k=3, alpha=0.03)
plot(clus)
#--- EXAMPLE 3 ------------------------------------------
data (M5data)
x <- M5data[,1:2]
clus.a <- tclust (x,k = 3, alpha=0.1, restr.fact = 1, restr= "eigen", equal.weights = TRUE)
clus.b <- tclust (x,k = 3, alpha=0.1, restr.fact = 1, restr= "sigma", equal.weights = TRUE)
clus.c <- tclust (x,k = 3, alpha=0.1, restr.fact = 1, restr= "deter", equal.weights = TRUE)
clus.d <- tclust (x,k = 3, alpha=0.1, restr.fact = 50, restr= "deter", equal.weights = FALSE)
par(mfrow=c(2,2))
plot(clus.a,main="(a) tkmeans")
plot(clus.b,main="(b) Gallegos and Ritter")
plot(clus.c,main="(c) Gallegos")
plot(clus.d,main="(d) tclust")
#--- EXAMPLE 4 ------------------------------------------
data (swissbank)
# Two clusters and 8\% trimming level
clus <- tclust(swissbank,k = 2, alpha=0.08, restr.fact = 15)
pairs(swissbank,col=clus$assig+1) # Pairs plot of the clustering solution
plot(swissbank[,4],swissbank[,6],col=clus$assig+1,xlab="Distance of the inner frame to lower border", ylab="Length of the diagonal") # Two coordinates
plot(clus)
# Three clusters and 0\% trimming level
clus <- tclust(swissbank,k = 3, alpha=0.0, restr.fact = 15)
pairs(swissbank,col=clus$assig+1) # Pairs plot of the clustering solution
plot(swissbank[,4],swissbank[,6],col=clus$assig+1,xlab="Distance of the inner frame to lower border", ylab="Length of the diagonal") # Two coordinates
plot(clus)Run the code above in your browser using DataLab