~ Function: scale for LongData ~

Share:

Description

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

Usage

1
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-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.

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).

Value

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

Author

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

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
##################
### 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)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.