View source: R/sparsePCA_helpers.R
scores.SD | R Documentation |
Score Distances for PCAloc
scores.SD(X, PC, groups, ssMRCD)
X |
data matrix of observations. |
PC |
loadings of sparse local PCA. |
groups |
grouping vector for locality. |
ssMRCD |
ssMRCD object used for PCA calculation. |
Returns vector of score distances of observations.
scores
, scores.OD
, sparsePCAloc
, 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.SD(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.