fanny(x, k, diss = F, metric = "euclidean", stand = F)
In case of a matrix or dataframe, each row corresponds to an observation, and each column corresponds to a variable. All variables must be numeric. Missing values (NAs) are allowed.
In case of a dissimilarity matrix, x is typically the output of daisy or dist. Also a vector with length n*(n-1)/2 is allowed (where n is the number of objects), and will be interpreted in the same way as the output of the above-mentioned functions. Missing values (NAs) are not allowed.
Fanny aims to minimize the objective function n n 2 2 k sum sum u (i,v) u (j,v) d(i,j) i=1 j=1 sum ------------------------------------ n 2 v=1 2 sum u (j,v) j=1 where n is the number of objects, k is the number of clusters and d(i,j) is the dissimilarity between objects i and j.
# generate 25 objects, divided into two clusters, # and 3 objects lying between those clusters. x <- rbind(cbind(rnorm(10,0,0.5), rnorm(10,0,0.5)), cbind(rnorm(15,5,0.5), rnorm(15,5,0.5)), cbind(rnorm(3,3.5,0.5), rnorm(3,3.5,0.5)))fannyx <- fanny(x, 2) fannyx summary(fannyx) plot(fannyx)
fanny(daisy(x, metric = "manhattan"), 2, diss = T)