Learn R Programming

mogsa (version 1.6.4)

wsvd: Weighted singular value decomposition (SVD)

Description

The weighted version of singular value decomposition.

Usage

wsvd(X, D1 = diag(1, nrow(X)), D2 = diag(1, ncol(X)))

Arguments

X
A numeric matrix whose wSVD decomposition is to be computed.
D1
A square matrix or vector. The left constraint/weight matrix (symmetric and positive in diagonal). The dimension of D1 should be the same with the number of rows in X. A vector input will be converted to a diagnal matrix.
D2
A square matrix or vector. The right constraint/weight matrix (symmetric, positive in diagonal). The dimension of D1 should be the same with the number of columns in X. A vector input will be converted to a diagnal matrix.

Value

d - singular valuesu - left singular vectorsv - right singular vectorsD1 - the left weight matrix (directly from input)D2 - the right weight matrix (directly from input)

Details

The weighted version of generalized singular value decomposition (SVD) of matrix A = UDV' with the constraints U'D1U = I and V'D2V = I D1 and D2 are two matrices express constraints imposed on the rows and the columns of matrix A.

References

Herve Abdi. Singular Value Decomposition (SVD) and Generalized Singular Value Decomposition (GSVD) http://www.utdallas.edu/~herve/Abdi-SVD2007-pretty.pdf

See Also

svd

Examples

Run this code
    set.seed(56)
    m <- matrix(rnorm(15), 5, 3)
    wl <- rnorm(5)
    wr <- runif(3)
    s <- wsvd(X=m, D1=wl, D2=wr)
    # t(s$u) %*% diag(wl) %*% s$u
    # t(s$v) %*% diag(wr) %*% s$v
    # all.equal(m, as.matrix(s$u) %*% diag(s$d) %*% t(s$v))

Run the code above in your browser using DataLab