Learn R Programming

kml (version 1.1.3)

affectIndivGeneralized: ~ Function: affectIndivGeneralized ~

Description

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

Usage

affectIndivGeneralized(traj, clustersCenter, distance = function(x, y) {
    return(dist(t(cbind(x, y))))
})

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
[function]: function use to estimate the distance between an individual and a clusters center. It can be use to deal with non classical distance.

Value

  • Object of class[LongitudinalData]{Partition}. ####################### ### affectIndiv ### Some LongitudinalData traj <- as.cld(gald())["traj"] ### 4 clusters centers center <- traj[runif(4,1,nrow(traj)),] ### Distance unusual distCor <- function(x,y){return(cor(x,y))} ### Affectation of each individual affectIndivGeneralized(traj,center,distance=distCor)methods

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 affectIndivGeneralized does. In addition to affectIndiv, it also let the user to define a non-classical distance. Note that affectIndiv does not work with ClusterizLongData object but with a matrix. affectIndivGenerized used with calculCenterGeneralized does simulate one step of EM-algorithm. This function is programmed in R, it is not expect to be as fast as affectIndiv.