calculTrajMean3d {kml3d}R Documentation

~ Function: calculTrajMean3d ~

Description

Given some joint longitudinal data and a cluster affectation, calculTrajMean3d computes the mean joint-trajectories of each cluster.

Usage

calculTrajMean3d(traj, clust,centerMethod=function(x){mean(x,na.rm=TRUE)})

Arguments

traj

[array(numeric)]: joint longitudinal data. Each line is an individual, each column is a time measurement, the third dimension is for variables.

clust

[vector(numeric)]: affectation of each individual.

centerMethod

[joint-trajectory <- function(array(numeric))]: function used to compute the clusters' centers.

Details

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.

Value

An array of dimension (k,t,v) with k number of groups, t number of time mesurement and v number of variables.

Examples


#######################
### 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))
}


[Package kml3d version 2.4.6.1 Index]