| ClusterLongData-class {kml} | R Documentation |
~ Class: ClusterLongData ~
Description
ClusterLongData is an object containing trajectories and associated Partition
Objects from the Class
kml is an algorithm that builds a set of Partition
from longitudinal data. ClusterLongData
is the object containing the original longitudinal data and all the Partition that kml finds.
When created, an ClusterLongData object simply contains initial
data (the trajectories). After the execution of kml, it
contains
the original data and the Partition which has
just been calculated by kml.
Note that if kml is executed several times, every new Partition
is added to the original ones, no pre-existing Partition is erased.
Slots
idAll[vector(character)]: Single identifier for each of the trajectory (each individual). Usefull for exporting clusters.idFewNA[vector(character)]: Restriction ofidAllto the trajectories that does not have 'too many' missing value. SeemaxNAfor details.time[numeric]: Time at which measures are made.varNames[character]: Name of the variable measured.traj[matrix(numeric)]: Contains the longitudianl data. Each lines is the trajectories of an individual. Each column is the time at which measures are made.dimTraj[vector2(numeric)]: size of the matrixtraj(iedimTraj=c(length(idFewNA),length(time))).maxNA[numeric]or[vector(numeric)]: Individual whose trajectories contain 'too many' missing value are exclude fromtrajand will no be use in the analysis. Their identifier is preserved inidAllbut not inidFewNA. 'too many' is define bymaxNA: a trajectory with more missing thanmaxNAis exclude.reverse[matrix(numeric)]: if the trajectories are scale using the functionscale, the 'scaling parameters' (probably mean and standard deviation) are saved inreverse. This is usefull to restaure the original data after a scaling operation.criterionActif[character]: Store the criterion name that will be used by functions that need a single criterion (like plotCriterion or ordered).
initializationMethod[vector(chararcter)]: list all the initialization method that has already been used to find some
Partition(usefull to not run several time a deterministic method).sorted[logical]: are thePartitioncurently hold in the object sorted in decreasing order ?c1[list(Partition)]: list of
Partitionwith 1 clusters.c2[list(Partition)]: list of
Partitionwith 2 clusters.c3[list(Partition)]: list of
Partitionwith 3 clusters....c26[list(Partition)]: list of
Partitionwith 26 clusters.
Extends
Class LongData, directly.
Class ListPartition, directly.
Construction
Class ClusterizLongData objects can be constructed via function
clusterLongData that turn a data.frame or a matrix
into a ClusterLongData. Note that some artificial data can be
generated using gald.
Methods
object['xxx']Get the value of the field
xxx. Inherit fromLongDataandListPartition.object['xxx']<-valueSet the field
xxxtovalue.xxx. Inherit fromListPartition.plotDisplay the
ClusterLongDataaccording to aPartition.
Special thanks
Special thanks to Boris Hejblum for debugging the '[' and '[<-' operators (the previous version was not compatible with the matrix package, which is used by lme4).
See Also
Overview: kml-package
Classes : Partition, LongData, ListPartition
Methods : clusterLongData, kml, choice
Plot : plot(ClusterLongData),
plotCriterion
Examples
### Move to tempdir
wd <- getwd()
setwd(tempdir()); getwd()
################
### Creation of some trajectories
traj <- matrix(c(1,2,3,1,4, 3,6,1,8,10, 1,2,1,3,2, 4,2,5,6,3, 4,3,4,4,4, 7,6,5,5,4),6)
myCld <- clusterLongData(
traj=traj,
idAll=as.character(c(100,102,103,109,115,123)),
time=c(1,2,4,8,15),
varNames="P",
maxNA=3
)
################
### get and set
myCld["idAll"]
myCld["varNames"]
myCld["traj"]
################
### Creation of a Partition
part2 <- partition(clusters=rep(1:2,3),myCld)
part3 <- partition(clusters=rep(1:3,2),myCld)
################
### Adding a clusterization to a clusterizLongData
myCld["add"] <- part2
myCld["add"] <- part3
myCld
### Go back to current dir
setwd(wd)