normalize: Normalize training data

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/normalize.R

Description

Normalize a vector or matrix to zero mean and unit length columns

Usage

1

Arguments

X

a matrix with the training data with observations down the rows and variables in the columns.

Details

The function can e.g. be used for the training data in sda or smda.

Value

Returns a list with the following attributes:

Xc

The normalized data.

mx

Mean of columns of X.

vx

Length of columns of X.

Id

Logical vector indicating which variables are included in X. If some of the columns have zero length they are omitted.

Author(s)

Line Clemmensen

References

Clemmensen, L., Hastie, T. and Ersboell, K. (2008) "Sparse discriminant analysis", Technical report, IMM, Technical University of Denmark

See Also

normalizetest, sda, smda

Examples

1
2
3
4
5
6
7
8
9
## Data
X<-matrix(sample(seq(3),12,replace=TRUE),nrow=3)

## Normalize data
Nm<-normalize(X)
print(Nm$Xc)

## See if any variables have been removed
which(!Nm$Id)

Example output

           [,1]       [,2]       [,3]       [,4]
[1,] -0.7071068  0.4082483  0.7071068  0.8164966
[2,]  0.0000000  0.4082483 -0.7071068 -0.4082483
[3,]  0.7071068 -0.8164966  0.0000000 -0.4082483
integer(0)

sparseLDA documentation built on May 2, 2019, 4:53 p.m.