Why do i have different results for irlba$v and prcomp_irlba$rotation for the same matrix?
MrChenFeng opened this issue · 3 comments
MrChenFeng commented
MrChenFeng commented
bwlewis commented
Because they don't compute the same decomposition by default. It's equivalent to the difference between svd
and prcomp
. irlba
computes a singular value decomposition. prcomp_irlba
computes a principal component decomposition with centering.
Try, for instance,
set.seed(1)
x <- matrix(rnorm(200), nrow=20)
p1 <- prcomp_irlba(x, n=3)
p3 <- irlba(A=x, nv=3)
p2 <- irlba(x, nv=3, center=colMeans(x))
Now p2$v
and p1$rotation
agree up to sign.
MrChenFeng commented
Sorry I just forget this question cause I found the error myself later....But still great thanks!!!!