landmarks1 <- na.exclude(landmarks)
dim(landmarks1)
#[1] 574 198
(num.points <- (dim(landmarks1)[2]) / 3)
#[1] 66
landmarks2 <- landmarks1[1:50,] #In the interests of simplicity of the computation involved.
(n <- dim(landmarks2)[1])
#[1] 50
dg <- array(0,dim = c(num.points,3,n))
for(k in 1:n){
for(l in 1:3){
dg[,l,k] <- as.matrix(as.vector(landmarks2[k,][seq(l,
dim(landmarks2)[2]+(l-1),by=3)]),ncol=1,byrow=T)
}
}
K <- 3 ; alpha <- 0.01 ; Nsteps <- 5 ; niter <- 5 ; stopCr <- 0.0001
res <- trimmedLloydShapes(dg,n,alpha,K,Nsteps,niter,stopCr,TRUE)
#To identify the trimmed women of the optimal iteration:
iter_opt <- res$trimmsIter[length(res$trimmsIter)]
trimm_women <- res$trimmWomen[[iter_opt]][[res$betterNstep]]
#Optimal partition:
table(res$asig)
Run the code above in your browser using DataLab