Learn R Programming

kml3d (version 0.6)

scale: ~ Function: scale for LongData ~

Description

scale normalized the trajectories of the different variable of a LongData object.

Usage

scale(x, center = TRUE, scale = TRUE)

Arguments

x
[LongData]: Object containnig trajectories to be scale.
center
[logical] or [vector(numeric)]: Value that will be substract from each mesurement of a variable. If center=TRUE, the mean of each variable is used. Otherwise, center should have a value fo
scale
[logical] or [vector(numeric)]: Value that will divided, after the substration, each mesurement of a variable. If scale=TRUE, the standard deviation of each variable is used. Otherwise, scale

Value

  • scale directly modify the internal value of the LongData. In this case, no value is return.

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

When variable with different unit are used jointly, it might be necessary to standardize them in order to give the same influance to all of them. scale normalized each variable of a LongData. More precisely, all the value x[i,j,k] of the variable k will be scale according to the classic formula (x[i,j,k]- m_k)/s_k where m_k and s_k are respectively the k-ieme value of the argument center and scale. Note that center=TRUE is a special value that set m_k=mean(x[,,k]). Similarly, scale=TRUE is a special value that set s_k=sd(x[,,k]).

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

Examples

Run this code
##################
### Building LongData

time=c(1,2,3,4,8,12,16,20)
id2=1:12
f <- function(id,t)((id-1)%%3-1) * t
g <- function(id,t)(id%%2+1)*t
ld1 <- as.longData(array(cbind(outer(id2,time,f),outer(id2,time,g))+rnorm(12*8*2,0,3),dim=c(12,8,2)))

### Scaling
plot(ld1)
scale(ld1)

### Only the y-axe change...
plot(ld1)

Run the code above in your browser using DataLab