Learn R Programming

ManlyMix (version 0.1.3)

Manly.Kmeans: k-means algorithm with Manly transformation

Description

Runs the CEM algorithm for k-means clustering with specified initial membership and transformation parameters.

Usage

Manly.Kmeans(X, id = NULL, la = NULL, Mu = NULL, S = NULL, tol = 1e-5, max.iter = 1000)

Arguments

X
dataset matrix (n x p)
id
initial membership vector (length n)
la
initial transformation parameters (K x p)
Mu
initial matrix of mean vectors (K x p)
S
initial vector of variances (K)
tol
tolerance level
max.iter
maximum number of iterations

Value

la
matrix of the estimated transformation parameters (K x p)
Mu
matrix of the estimated mean vectors (K x p)
S
array of the estimated covariance matrices (K)
id
estimated membership vector (length n)
iter
number of EM iterations run
flag
convergence flag (0 - success, 1 - failure)

Details

Runs the CEM algorithm for k-means clustering with Manly transformation for a provided dataset. The model assumes that a multivariate Manly transformation applied to each component allows to reach near-normality. A user has a choice to specify either initial id vector 'id' and transformation parameters 'la' or initial mode parameters 'la', 'Mu', and 'S'. In the case when transformation parameters are not provided, the function runs the EM algorithm without any transformations, i.e., it is equivalent to the EM algorithm for a k-means model. If some transformation parameters have to be excluded from the consideration, in the corresponding positions of matrix 'la', the user has to specify value 0. Notation: n - sample size, p - dimensionality of the dataset X, K - number of mixture components.

See Also

Manly.EM

Examples

Run this code

set.seed(123)

K <- 3; p <- 4
X <- as.matrix(iris[,-5])
id.true <- rep(1:K, each = 50)

# Obtain initial memberships based on the traditional K-means algorithm
id.km <- kmeans(X, K)$cluster

# Run the CEM algorithm for k-means with Manly transformation based on traditional k-means solution
la <- matrix(0.1, K, p)
B <- Manly.Kmeans(X, id.km, la)
id.Manly <- B$id

table(id.true, id.Manly)

Run the code above in your browser using DataLab