Learn R Programming

longitudinalData (version 2.4.7)

scale: ~ Function: scale for LongData ~

Description

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

Usage

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

Value

scale directly modify the internal value of the LongData. No value is return.

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-trajectory is used. Otherwise, center should have a value for each variables.

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-trajectory is used. Otherwise, scale should have a value for each variables.

Author

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

Details

When variable with different unit are used jointly, it might be necessary to change their scale them in order to change their individual influance. This is what scale do.

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],na.rm=TRUE). Similarly, scale=TRUE is a special value that set s_k=sd(x[,,k],na.rm=TRUE).

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

restoreRealData

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 <- longData3d(array(cbind(outer(id2,time,f),outer(id2,time,g))+rnorm(12*8*2,0,1),dim=c(12,8,2)))
plotTrajMeans3d(ld1)

##################
### Scaling by 'mean' and 'standard deviation'
plotTrajMeans3d(ld1)
scale(ld1)
plotTrajMeans3d(ld1)

### Scaling by some parameters
scale(ld1,center=c(10,100),scale=c(3,-1))
plotTrajMeans3d(ld1)

##################
### To restore the data
restoreRealData(ld1)

Run the code above in your browser using DataLab