View source: R/sparsePCA_helpers.R
scores | R Documentation |
Calculate Scores for local sparse PCA
scores(X, PC, groups, ssMRCD = NULL)
X |
data set as matrix. |
PC |
loading matrix. |
groups |
vector of grouping structure (numeric). |
ssMRCD |
ssMRCD object used for scaling |
Returns a list with scores and univariately and locally centered and scaled observations.
ssMRCD
, scale_ssMRCD
# create data set
x1 = matrix(runif(200), ncol = 2)
x2 = matrix(rnorm(200), ncol = 2)
x = list(x1, x2)
# create weighting matrix
W = matrix(c(0, 1, 1, 0), ncol = 2)
# calculate ssMRCD
loccovs = ssMRCD(x, weights = W, lambda = 0.5)
# calculate PCA
pca = sparsePCAloc(eta = 1, gamma = 0.5, cor = FALSE,
COVS = loccovs$MRCDcov,
increase_rho = list(FALSE, 20, 1))
# calculate scores
scores(X = rbind(x1, x2), PC = pca$PC,
groups = rep(c(1,2), each = 100), ssMRCD = loccovs)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.