# NOT RUN {
# load whitening library
library("whitening")
######
# example data set
# E. Anderson. 1935. The irises of the Gaspe Peninsula.
# Bull. Am. Iris Soc. 59: 2--5
data("iris")
X = as.matrix(iris[,1:4])
d = ncol(X) # 4
n = nrow(X) # 150
colnames(X) # "Sepal.Length" "Sepal.Width" "Petal.Length" "Petal.Width"
# estimate covariance
S = cov(X)
# ZCA-cor whitening matrix
W.ZCAcor = whiteningMatrix(S, method="ZCA-cor")
# whitened data
Z.ZCAcor.1 = tcrossprod(X, W.ZCAcor)
zapsmall( cov(Z.ZCAcor.1) )
# directly compute whitened data from X
Z.ZCAcor.2 = whiten(X, method="ZCA-cor")
zapsmall( cov(Z.ZCAcor.2) )
# }
Run the code above in your browser using DataLab