
Last chance! 50% off unlimited learning
Sale ends in
Given some joint longitudinal data and a cluster affectation,
calculTrajMean3d
computes the mean joint-trajectories of each cluster.
calculTrajMean3d(traj, clust,centerMethod=function(x){mean(x,na.rm=TRUE)})
An array of dimension (k,t,v)
with k
number of groups, t
number of
time mesurement and v
number of variables.
[array(numeric)]
: joint longitudinal data. Each line is an individual,
each column is a time measurement, the third dimension is for variables.
[vector(numeric)]
: affectation of each individual.
[joint-trajectory <- function(array(numeric))]
: function used
to compute the clusters' centers.
Given a vector of affectation to a cluster, the function
calculTrajMean3d
compute the "central" trajectory of each
clusters. The "center" can be define using the argument centerMethod
.
affectIndiv3d
used with calculTrajMean3d
simulates one k-means step.
#######################
### calculTrajMean3d
### Some LongitudinalData3d
traj <- gald3d()["traj"]
### A partition
part <- floor(runif(150,1,5))
plot(clusterLongData3d(traj),parTraj=parTRAJ(col=part+1))
### Clusters center
(center <- calculTrajMean3d(traj,part))
#################
### K-means simulation (4 steps)
plot(clusterLongData3d(traj),parTraj=parTRAJ(col=part+1))
for (i in 1:4){
part <- affectIndiv3d(traj,center)
center <- calculTrajMean3d(traj,part)
plot(clusterLongData3d(traj),parTraj=parTRAJ(col=part+1))
}
Run the code above in your browser using DataLab