View source: R/sparsePCA_helpers.R
align_PC | R Documentation |
Aligns loadings per neighborhood for better visualization and comparison. Different options are available.
align_PC(PC, N, p, type = "largest", vec = NULL)
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 |
|
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
.
Returns a matrix of loadings of size Np
times k
.
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.