Learn R Programming

kml3d (version 0.7)

imputation: ~ Function: imputation ~

Description

imputation is a function that offer different methods to impute missing value of a LongData.

Usage

imputation(object, method, imputRange,...)

Arguments

object
[LongData] or [array] : object containing the trajectories to impute.
method
[character]: Name of the imputation method (see detail). The default value is LI-Bissectrice.
imputRange
[matrix]: Specify the imputing range of each variable. The first line gives the minimum, the second gives the maximum. When an imputing range is specified, any value imputed out of the range will be bring back to a possible val
...
For compatibility only.

Value

  • If object is an array, an imputed array (with no missing values) in returned. If object is a LongData, imputation directly modify the internal value of the LongData. In this case, no value is return.

item

  • 'LOCB' (Last Occurence Carried Backward)
  • Missing at the end:
  • 'LI-Global' (linear interpolation, global slope)
  • Missing at start / at the end:
  • 'LI-Local' (linear interpolation, local slope)
  • Missing at start:
  • Missing at the end:
  • 'LI-Bissectrice', (linear interpolation, mixed between global and local)
  • Missing at start / at end:
  • 'LI-LOCBF', (linear interpolation, LOCB and LOCF)
  • Missing at start:
  • Missing at end:

itemize

  • Missing in the middle:

code

LI-Global

Author(s)

Christophe Genolini INSERM U669 / PSIGIAM: Paris Sud Innovation Group in Adolescent Mental Health Modal'X / Universite Paris Ouest-Nanterre- La Defense Contact author : genolini@u-paris10.fr

Details

imputation is a function that impute missing value of trajectories. Several imputation methods are available. For each method, the imputation has to deal with three kind of missing value : at start of the trajectorie (first values are missing), at the end (last values are missing) or in the middle (the missing value have surround by non-missing value). Here is a description of each methods (for all of them, an example is provided in the Examples section):
  • 'LOCF' (Last Occurence Carried Forward)
{
  • Missing in the middle / at the end:
{ the previous non-missing value is dipplicated forward.} Missing at start:{ the first non-missing occurence is dupplicated backward (like LOCB).} }

References

Article "KmL: K-means for Longitudinal Data", in Computational Statistics, Volume 25, Issue 2 (2010), Page 317. Web site: http://christophe.genolini.free.fr/kml

See Also

LongData

Examples

Run this code
##################
### Comparison of the method on a single trajectories

arrayMissing <- array(c(NA,NA,1,NA,6,NA,NA,-1,0,NA,NA),dim=c(1,13,1))
par(ask=TRUE)
plot(arrayMissing,col="red",lwd=3,type="b",ylim=c(-4,8),
   xlab="Example of trajectory with missing values")


plot(imputation(arrayMissing,"LOCF"),col="black",ylim=c(-4,8),xlab="LOCF",lwd=1,type="b")
lines(arrayMissing,col="red",lwd=3,type="b")

plot(imputation(arrayMissing,"LOCB"),col="black",ylim=c(-4,8),xlab="LOCB",lwd=1,type="b")
lines(arrayMissing,col="red",lwd=3,type="b")

plot(imputation(arrayMissing,"LI-Global"),col="black",ylim=c(-4,8),xlab="LI-Global",lwd=1,type="b")
lines(arrayMissing,col="red",lwd=3,type="b")

plot(imputation(arrayMissing,"LI-Local"),col="black",ylim=c(-4,8),xlab="LI-Local",lwd=1,type="b")
lines(arrayMissing,col="red",lwd=3,type="b")

plot(imputation(arrayMissing,"LI-Bissectrice"),col="black",ylim=c(-4,8),xlab="LI-Bissectrice",lwd=1,type="b")
lines(arrayMissing,col="red",lwd=3,type="b")

plot(imputation(arrayMissing,"LI-LOCBF"),col="black",ylim=c(-4,8),xlab="LI-LOCBF",lwd=1,type="b")
lines(arrayMissing,col="red",lwd=3,type="b")

##################
### Real example on array

time=c(1,2,3,4,8,12,16,20)
id2=1:120
f <- function(id,t)((id-1)%%3-1) * t
g <- function(id,t)(id%%2+1)*t
tra2 <- array(cbind(outer(id2,time,f),outer(id2,time,g))+rnorm(120*8*2,0,3),dim=c(120,8,2))
for(i in 1:640){tra2[floor(runif(1,1,120)),floor(runif(1,1,9)),floor(runif(1,1,3))]<-NA}

(tra2)
(tra2imp <- imputation(tra2))

##################
### Real example on LongData

ld2 <- as.longData(tra2)
plot3d(ld2)
imputation(ld2)
plot3d(ld2)

###### EXAMPLE WITH RANGE ######
par(ask=FALSE)

Run the code above in your browser using DataLab