Learn R Programming

ssMRCD (version 1.1.0)

align_PC: 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)

Value

Returns a matrix of loadings of size Np times k.

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 "largest", "maxvar","nonzero","mean", "scalar", "none".

vec

NULL or vector containing vectors for type "scalar"

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.

Examples

Run this code
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")

Run the code above in your browser using DataLab