affectIndiv3d {kml3d} | R Documentation |
~ Function: affectIndiv3d ~
Description
Given some longitudinal data (trajectories) and k clusters centers, affectIndiv3d
affects each individual to the cluster whose center is the closest.
Usage
affectIndiv3d(traj, clustersCenter, distance = dist3d)
Arguments
traj |
|
clustersCenter |
|
distance |
|
Details
Given an array of clusters center clustersCenter
(each plan of
the first dimension is
a cluster center, that is clusterCenter[2,,] is the second cluster
center), the function affectIndiv3d
affect each
individual of the array traj
to the closest clusters,
according to distance
.
affectIndiv3d
used with calculTrajMean3d
simulates one k-means 3D step.
Value
Object of classPartition
.
Examples
#######################
### affectIndiv
### Some trajectories
traj <- gald3d()["traj"]
### 4 clusters centers
center <- traj[runif(4,1,nrow(traj)),,]
### Affectation of each individual
part <- affectIndiv3d(traj,center)
#################
### K-means simulation (3 steps)
plot(clusterLongData3d(traj),parTraj=parTRAJ(col=part+1))
for (i in 1:3){
center <- calculTrajMean3d(traj,part)
part <- affectIndiv3d(traj,center)
plot(clusterLongData3d(traj),parTraj=parTRAJ(col=part+1))
}