Learn R Programming

longitudinalData (version 2.0)

generateArtificialLongData3d: ~ Function: generateArtificialLongData3d (or gald3d) ~

Description

This function builp up an artificial longitudinal data set (joint trajectories) an turn them into an object of class LongData.

Usage

gald3d(nbEachClusters=50,time=0:10,varNames=c("V","T"),
    functionClusters=list(function(t){c(0,0)},function(t){c(10,10)},function(t){c(10-t,10-t)}),
    constantPersonal=function(t){c(rnorm(1,0,2),rnorm(1,0,2))},
    functionNoise=function(t){c(rnorm(1,0,2),rnorm(1,0,2))},
    decimal=2,percentOfMissing=0)

generateArtificialLongData3d(nbEachClusters=50,time=0:10,varNames=c("V","T"),
    functionClusters=list(function(t){c(0,0)},function(t){c(10,10)},function(t){c(10-t,10-t)}),
    constantPersonal=function(t){c(rnorm(1,0,2),rnorm(1,0,2))},
    functionNoise=function(t){c(rnorm(1,0,2),rnorm(1,0,2))},
    decimal=2,percentOfMissing=0)

Arguments

nbEachClusters
[vector(numeric)]: number of trajectories that each cluster must contain. If a single number is given, it is duplicated for all groups.
time
[vector(numeric)]: time at which measures are made.
varNames
[vector(character)]: names of the variables.
functionClusters
[list(function)]: lists the functions that define the average trajectories of each cluster. Each functions shall return a vector containing one value for each variable of varNames.
constantPersonal
[function] or [list(function)]: lists the functions defining the personnal variation between an individual and the mean trajectories of its cluster. Note that these function should be constant function (the persona
functionNoise
[function] or [list(function)]: lists the functions generating the noise of each trajectory within its own cluster. Each functions shall return a vector containing one value for each variable of varNames
decimal
[numeric]: number of decimals used to round up values.
percentOfMissing
[numeric]: percentage (between 0 and 1) of missing data generated in each cluster. If a single value is given, it is duplicated for all groups. The missing values are Missing Completly At Random (MCAR).

Value

  • Object of class LongData.

Author

Christophe Genolini 1. UMR U1027, INSERM, Universit� Paul Sabatier / Toulouse III / France 2. CeRSME, EA 2931, UFR STAPS, Universit� de Paris Ouest-Nanterre-La D�fense / Nanterre / France

Details

generateArtificialLongData3d (gald3d in short) is a function that contruct a set of artificial joint longitudinal data. Each individual is considered as belonging to a group. This group follows a theoretical trajectory, function of time. These functions (one per group) are given via the argument functionClusters. Even if it belong to a clusers, individual does not perfectly follow the mean trajectories. So a personal variation is added via the argument constantPersonal. This personal variation is constant over time. Then some residual noise is added to all the trajectories via the argument functionNoise. The number of individuals in each group is given by nbEachClusters. Finally, it is possible to add missing values randomly (MCAR) striking the data thanks to percentOfMissing.

References

[1] C. Genolini and B. Falissard "KmL: k-means for longitudinal data" Computational Statistics, vol 25(2), pp 317-328, 2010 [2] C. Genolini and B. Falissard "KmL: A package to cluster longitudinal data" Computer Methods and Programs in Biomedicine, 104, pp e112-121, 2011

See Also

LongData3d, longData3d, generateArtificialLongData

Examples

Run this code
#####################
### Default example

ex1 <- generateArtificialLongData3d()
plot3d(ex1)
part1 <- partition(rep(1:3,each=50))
plot3d(ex1,part1)


#####################
### 4 lines with unbalanced groups

ex2 <- generateArtificialLongData3d(
  nbEachClusters=c(5,10,20,40),
  functionClusters=list(
     function(t)c(t,t^3/100),
     function(t)c(0,t),
     function(t)c(t,t),
     function(t)c(0,t^3/100)
  ),
  functionNoise = function(t){c(rnorm(1,0,1),rnorm(1,0,1))}
)
plot3d(ex2)
part2 <- partition(rep(1:4,time=c(5,10,20,40)))
plot3d(ex2,part2)

Run the code above in your browser using DataLab