firstpos | R Documentation |
firspos
:
Changes the sign of the values of the columns
in one or two matrices
according to the sign of the elements in the first line
of the first matrix.
After transformation the first element of every column of the
matrix or matrices will be positive.
This is used to get reproducible results when performing singular value decompositions or eigenvalue decompositions.
Note that when provided two matrices the signs of the matrices will match: This is used to ensure that the sign of the singular vectors of a given matrix match.
firstpos(P, Q = NULL)
P |
A matrix of numeric values |
Q |
If not |
If Q
is NULL
,
then the function returns only the modified P
matrix.
Otherwise, the function returns a list with two elements:
P
A matrix with the same values as in P
,
except that the sign of all the values in each column
is flipped if the first value of this column is negative.
Q
A matrix with the same values as in
Q
,
except that the sign of all the values in each column
is flipped the same way that it is flipped forP
.
Vincent Guillemot and Hervé Abdi
firstpos4ExPo
,
renormInertiaExPo
## Not run:
A <- matrix(rnorm(4), 2, 2)
B <- matrix(rnorm(6), 3, 2)
firstpos(A, B)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.