Description Usage Arguments Value Author(s) See Also Examples
gsvd
takes in left (LW
) and right (RW
) constraints (usually diagonal matrices, but any positive semi-definite matrix is fine) that are applied to the data (X
).
Left and right constraints are used for the orthogonality conditions.
1 |
X |
a data matrix to decompose |
LW |
Left Weights – the constraints applied to the left side (rows) of the matrix and thus left singular vectors. |
RW |
Right Weights – the constraints applied to the right side (columns) of the matrix and thus right singular vectors. |
k |
total number of components to return though the full variance will still be returned (see |
tol |
default is .Machine$double.eps. A tolerance level for eliminating effectively zero (small variance), negative, imaginary eigen/singular value components. |
A list with eleven elements:
d_full |
A vector containing the singular values of X above the tolerance threshold (based on eigenvalues). |
l_full |
A vector containing the eigen values of X above the tolerance threshold ( |
d |
A vector of length |
l |
A vector of length |
u |
Left (rows) singular vectors. Dimensions are |
p |
Left (rows) generalized singular vectors. Dimensions are |
fi |
Left (rows) component scores. Dimensions are |
v |
Right (columns) singular vectors. Dimensions are |
q |
Right (columns) generalized singular vectors. Dimensions are |
fj |
Right (columns) component scores. Dimensions are |
Derek Beaton
tolerance_svd
, geigen
and gplssvd
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | data(wine, package="GSVD")
wine.objective <- wine$objective
## Principal components analysis: "covariance"
## "covariance" PCA
cov.pca.data <- scale(wine.objective,scale=FALSE)
cov.pca.res <- gsvd(cov.pca.data)
## Principal components analysis: "correlation"
cor.pca.data <- scale(wine.objective,scale=TRUE)
cor.pca.res <- gsvd(cor.pca.data)
## Principal components analysis: "correlation" with the covariance matrix and constraints
cor.pca.res2 <- gsvd(cov.pca.data,RW=1/apply(wine.objective,2,var))
## Correspondence analysis
data(authors, package="GSVD")
Observed <- authors/sum(authors)
row.w <- rowSums(Observed)
col.w <- colSums(Observed)
Expected <- row.w %o% col.w
Deviations <- Observed - Expected
ca.res <- gsvd(Deviations,1/row.w,1/col.w)
## Multiple correspondence analysis
data("snps.druguse", package="GSVD")
X <- model.matrix(~ .,
data=snps.druguse$DATA1,
contrasts.arg = lapply(snps.druguse$DATA1, contrasts, contrasts=FALSE))[,-1]
Observed <- X/sum(X)
row.w <- rowSums(Observed)
col.w <- colSums(Observed)
Expected <- row.w %o% col.w
Deviations <- Observed - Expected
ca.res <- gsvd(Deviations,1/row.w,1/col.w)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.