R/kmeansStepAIC.R

Defines functions kmeansStepAIC

Documented in kmeansStepAIC

kmeansStepAIC <-
function(x, centers = 1, iter.max = 10, nstart = 10, algorithm = c("Hartigan-Wong", "Lloyd", "Forgy", "MacQueen"), trace=FALSE ){
oldAIC <- kmeansAIC(kmeans(x, centers, iter.max, nstart, algorithm, trace))
centers <- centers + 1
newAIC <- kmeansAIC(kmeans(x, centers, iter.max, nstart, algorithm, trace))
while(oldAIC > newAIC)
{
oldAIC <- newAIC
centers <- centers + 1
newAIC <- kmeansAIC(kmeans(x, centers, iter.max, nstart, algorithm, trace))
}
return(list(AIC = oldAIC, kmeans = kmeans(x, centers = centers - 1, iter.max, nstart, algorithm, trace)))
}

Try the kmeansstep package in your browser

Any scripts or data that you put into this service are public.

kmeansstep documentation built on May 2, 2019, 5 p.m.