DataSlingers / MoMA

MoMA: Modern Multivariate Analysis in R
https://DataSlingers.github.io/MoMA
GNU General Public License v2.0
22 stars 4 forks source link

Setting signs for returned singular vectors #6

Open Banana1530 opened 6 years ago

michaelweylandt commented 6 years ago

Thanks for opening this issue @Banana1530

Can you look into the convention used by R's eigen and svd functions here? (My guess is that they follow whatever the LAPACK standard is)

We should probably copy that for consistency.

Banana1530 commented 6 years ago

@michaelweylandt points out a paper that deals with the issue Resolving the Sign Ambiguity in the Singular Value Decomposition, Rasmus Bro, Evrim Acar and Tamara Kolda.

The paper proposes that the left singular vector should be in the same direction as most of the data vectors (i.e., the columns of matrix X). Concretely, for the i-th left singular vector, they choose the sign that maximizes

S = Σⱼ sign(uᵢᵀ xⱼ) (uᵢᵀ xⱼ)²

Banana1530 commented 6 years ago

The built-in function princomp provides an argument fix_sign to indicate whether the signs of the loadings and scores should be chosen so that the first element of each loading is non-negative.

michaelweylandt commented 6 years ago

That seems like a good default and a bit easier to implement than the method mentioned above.

I think the only tweak we need is to say the first non-zero element is positive since we allow sparse principal components.

On Wed, Jul 18, 2018 at 22:34 Luofeng Liao notifications@github.com wrote:

The built-in function princomp provides an argument fix_sign to indicate whether the signs of the loadings and scores should be chosen so that the first element of each loading is non-negative.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/michaelweylandt/MoMA/issues/6#issuecomment-406135558, or mute the thread https://github.com/notifications/unsubscribe-auth/ABau6a0IkNOyXlQEkyYqfGXSl8masAgdks5uH_BPgaJpZM4U5uHn .