[R] prcomp - arbitrary direction of the returned principal components
@@h|mk@poor @end|ng |rom gm@||@com
Wed Oct 12 13:48:26 CEST 2022
Dear R experts,
---- snip -----
The signs of the columns of the rotation matrix are arbitrary, and
so may differ between different programs for PCA, and even between
different builds of R.
---- snip ------
My problem is that I am building an index based on Principal
When the index is high it should indicate stress in the market. Due to
the arbitrary sign sometimes I get an index which is HIGH when there
is stress and sometimes I get the OPPOSITE - an index which is LOW
when there is stress.
This program is shared with other people who may have a different build of R.
I can forcefully use a NEGATIVE sign to FLIP the index when it is LOW.
Now my query is : Just like we do set.seed(1234) and force the pattern
of generation of random number and make it REPRODUCIBLE, can I do
something like :
Now each time I do prcomp it should choose the SAME ( high or low )
direction of the principle component on ANY computer having ANY
version of R installed.
That's what I want. I don't want the the returned principal component
to be HIGH(LOW) on my computer and LOW(HIGH) on someone else's
That would confuse the people the code is shared with.
Is this possible ? How do people deal with this ?
More information about the R-help