robjhyndman / anomalous-acm

Anomalous time series package for R (ACM)
119 stars 30 forks source link

Use only first two principal components with non-robust PCA #2

Closed mmolaro closed 9 years ago

mmolaro commented 9 years ago

Using the robust=FALSE flag results in an error "number of items to replace is not a multiple of replacement length" because PCA a scores matrix with greater than 2 components which princomp will do, but won't occur because of k=2 in the call to pcaPP::PCAproj

Suggested fix: just take the first two columns of scores.

I'd not that I get surprisingly different results between robust and non-robust PCA with hdr on a quick test I did and visually the robust results make more sense. Also your paper seems to suggest better performance when not using robust PCA but the default in the R code is robust=TRUE.