| calculTrajMean {kml} | R Documentation |
~ Functions: calculTrajMean & calculTrajMeanC ~
Description
Given some longitudinal data and a cluster affectation,
calculTrajMean and calculTrajMeanC compute the mean trajectories of each cluster.
Usage
calculTrajMean(traj, clust, centerMethod = function(x){mean(x, na.rm =TRUE)})
calculTrajMeanC(traj, clust)
Arguments
traj |
|
clust |
|
centerMethod |
|
Details
Given a vector of affectation to a cluster, the function
calculTrajMean compute the "central" trajectory of each
clusters. The "center" can be define using the argument centerMethod.
calculTrajMeanC does the same but
assume that the center definition is the classic "mean".
calculTrajMeanC is writen in C (and is therefor much faster).
affectIndiv used with calculTrajMean simulates one k-means step.
Value
A matrix with k line and t column containing k clusters centers. Each line is a center, each column is a time measurement.
Examples
#######################
### calculMean
### Some trajectories
traj <- gald()["traj"]
### A cluster affectation
clust <- initializePartition(3,200,"randomAll")
### Computation of the cluster's centers
system.time(centers <- calculTrajMean(traj,clust))
system.time(centers <- calculTrajMeanC(traj,clust))