Learn R Programming

Rdimtools (version 0.1.2)

aux.preprocess: Centering, decorrelating, or whitening of the data

Description

aux.preprocess can perform one of three popular operations; centering, decorrelating, and whitening of data. See below for more details.

Usage

aux.preprocess(data, type = "center")

Arguments

data

an (n-by-p) matrix or data frame whose rows are observations and columns represent independent variables.

type

one of "center", "decorrelate", or "whiten". See below for more details.

Value

named list containing:

pX

an (n-by-p) matrix after preprocessing in accordance with type parameter

info

a list containing

  • type: name of preprocessing procedure.

  • mean: a mean vector of length \(p\).

  • multiplier: a (p-by-p) matrix for "decorrelate" or "whiten" or 1 for "center".

Details

"center" option subtracts mean of each column so that every variable has mean 0. After centering, option "decorrelate" sets the data matrix to have diagonal covariance terms only. "whiten" option sets the sample covariance to have all diagonal terms equal to 1, equally weighting each variable.

Examples

Run this code
# NOT RUN {
## Generate data
X = aux.gensamples()

## 3 types of preprocessing
X_center = aux.preprocess(X)
X_decorr = aux.preprocess(X,type="decorrelate")
X_whiten = aux.preprocess(X,type="whiten")

## Check with Covariance matrix
par(mfrow=c(1,3))
image(cov(X_center$pX),zlim=c(-50,50)); title("center");
image(cov(X_decorr$pX),zlim=c(-50,50)); title("decorrelate");
image(cov(X_whiten$pX),zlim=c(-50,50)); title("whitening")

# }

Run the code above in your browser using DataLab