SVD: Singular Value Decomposition of a Matrix

Description Usage Arguments Value Author(s) See Also Examples

View source: R/Eigen.R

Description

Compute the singular-value decomposition of a matrix X from the eigenstructure of X'X. The result consists of two orthonormal matrices, U, and V and the vector d of singular values, such that X = U diag(d) V'. Singular values of zero are not retained in the solution.

Usage

1
SVD(X, tol = sqrt(.Machine$double.eps))

Arguments

X

a square symmetric matrix

tol

tolerance passed to QR

Value

a list of three elements: d– singular values, U– left singular vectors, V– right singular vectors

Author(s)

John Fox and Georges Monette

See Also

svd, the standard svd function

Eigen

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
C <- matrix(c(1,2,3,2,5,6,3,6,10), 3, 3) # nonsingular, symmetric
C
SVD(C)

# least squares by the SVD
data("workers")
X <- cbind(1, as.matrix(workers[, c("Experience", "Skill")]))
head(X)
y <- workers$Income
head(y)
(svd <- SVD(X))
VdU <- svd$V %*% diag(1/svd$d) %*%t(svd$U)
(b <- VdU %*% y)
coef(lm(Income ~ Experience + Skill, data=workers))

matlib documentation built on April 4, 2018, 5:03 p.m.