Description Usage Arguments Author(s) References Examples
View source: R/kmeansStepEllbowBIC.R
stepwise modelselection of k-means cluster using BIC and Ellbow-Method
1 | kmeansStepEllbowBIC(x, centers = 1, iter.max = 10, nstart = 10, algorithm = c("Hartigan-Wong", "Lloyd", "Forgy", "MacQueen"), trace = FALSE)
|
x |
|
centers |
|
iter.max |
|
nstart |
|
algorithm |
|
trace |
Markus Mayer
http://sherrytowers.com/2013/10/24/k-means-clustering/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (x, centers = 1, iter.max = 10, nstart = 10, algorithm = c("Hartigan-Wong",
"Lloyd", "Forgy", "MacQueen"), trace = FALSE)
{
firstBIC <- kmeansBIC(kmeans(x, centers, iter.max, nstart,
algorithm, trace))
centers <- centers + 1
secondBIC <- kmeansBIC(kmeans(x, centers, iter.max, nstart,
algorithm, trace))
centers <- centers + 1
thirdBIC <- kmeansBIC(kmeans(x, centers, iter.max, nstart,
algorithm, trace))
centers <- centers + 1
fourthBIC <- kmeansBIC(kmeans(x, centers, iter.max, nstart,
algorithm, trace))
el_first <- (firstBIC - secondBIC)/(secondBIC - thirdBIC)
el_second <- (secondBIC - thirdBIC)/(thirdBIC - fourthBIC)
while (el_second > el_first) {
firstBIC <- secondBIC
secondBIC <- thirdBIC
thirdBIC <- fourthBIC
centers <- centers + 1
fourthBIC <- kmeansBIC(kmeans(x, centers, iter.max, nstart,
algorithm, trace))
el_first <- el_second
el_second <- (secondBIC - thirdBIC)/(thirdBIC - fourthBIC)
}
return(list(BIC = secondBIC, kmeans = kmeans(x, centers = centers -
2, iter.max, nstart, algorithm, trace)))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.