align_PC {ssMRCD} | R Documentation |
Align Loadings of Principal Components
Description
Aligns loadings per neighborhood for better visualization and comparison. Different options are available.
Usage
align_PC(PC, N, p, type = "largest", vec = NULL)
Arguments
PC |
matrix of loadings of size Np x k |
N |
integer, number of groups/neighborhoods |
p |
integer, number of variables |
type |
character indicating how loadings are aligned (see details),
options are |
vec |
|
Details
For input type
possible values are "largest", "maxvar","nonzero","mean","scalar"
.
For option "maxvar"
the variable with the highest absolute value in the loading
is scaled to be positive (per neighborhood, per loading).
For option "nonzero"
the variable with largest distance to zero in the entries is
scaled to be positive (per neighborhood, per loading).
For option "scalar"
the variable is scaled in a way, that the scalar product
between the loading and the respective part of vec
is positive (per neighborhood, per loading).
If vec
is of size p
times k
, the same vector is used for all neighborhoods.
Option "mean"
is option "scalar"
with vec
being the mean of the loadings per variable across neighborhoods.
Option "largest"
scales the largest absolute value to be positive per neighborhood and per PC.
Option "none"
does nothing and returns PC
.
Value
Returns a matrix of loadings of size Np
times k
.
Examples
x = matrix(c(1, 0, 0, 0, sqrt(0.5), -sqrt(0.5), 0, 0,
0, sqrt(1/3), -sqrt(1/3), sqrt(1/3), sqrt(0.5), sqrt(0.5), 0, 0),
ncol = 2)
align_PC(PC = x, N = 2, p = 4, type = "largest")
align_PC(PC = x, N = 2, p = 4, type = "mean")