Learn R Programming

kml (version 1.1.3)

affectIndiv: ~ Function: affectIndiv ~

Description

Given some longitudinal data (trajectories) and k clusters centers, affectIndiv affecte each individual to the cluster whose center is the closest.

Usage

affectIndiv(traj, clustersCenter, distance = "euclidean", power = 2)

Arguments

traj
[matrix]: longitudinal data. Each line is an individual, each colomn is a time mesurement.
clustersCenter
[matrix]: clusters center. Each line is a cluster center, each colomn is a time mesurement.
distance
[character]: use to estimate the distance between an individual and a clusters center. Should be one off "manhattan","euclidean","minkowski","maximum","canberra" or "binary".
power
[numeric]: if the distance is "minkowski", power give the power to use.

Value

  • Object of class[LongitudinalData]{Partition}. ####################### ### affectIndiv ### Some LongitudinalData traj <- as.cld(gald())["traj"] ### 4 clusters centers center <- traj[runif(4,1,nrow(traj)),] ### Affectation of each individual affectIndiv(traj,center)

Details

EM algorithm (like k-means) altern two phases : Esperance and Maximisation. During Maximisation, each individual is affected to the closest cluster. This is what affectIndiv does. Note that affectIndiv does not work with ClusterizLongData object but with a matrix. affectIndiv used with calculMean does simulate one k-means step. This function is programmed in C, it is expect to be fast.