calculTrajMean: ~ Functions: calculTrajMean & calculTrajMeanC ~

View source: R/kml.R

calculTrajMeanR 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

[matrix(numeric)]: longitudinal data. Each line is an individual, each column is a time measurement.

clust

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

centerMethod

[trajectory <- function(matrix(numeric))]: function that compute the mean trajectory of a group of trajectories.

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

kml documentation built on Oct. 30, 2024, 9:09 a.m.