Singular Value Decomposition of a Matrix

DESCRIPTION:

Returns a list containing the singular value decomposition of the input. The function svd is generic.

USAGE:

svd(x, ...)
svd.default(x, nu=min(nrow(x), ncol(x)), nv=min(nrow(x), ncol(x)))

REQUIRED ARGUMENTS:

x
matrix of numeric or complex data. Missing values are not accepted.

OPTIONAL ARGUMENTS:

nu
number of columns desired in the matrix u. This must be zero, ncol(x), or nrow(x). See below for details.
nv
number of columns desired in the matrix v. This must be zero, ncol(x), or nrow(x). See below for details.

VALUE:

list containing the components of the singular value decomposition x = u %*% diag(d) %*% t(v) , or more efficiently, x = u %*% (d * t(v)) . In the complex case, x = u %*% diag(d) %*% Conj(t(v)) . The names of the components are:
u
if nu > 0, a matrix with dimensions nrow(x) by nu of unit orthogonal columns. This is not present if nu=0.
d
vector of singular values, in non-increasing order, representing the diagonal elements of the matrix d.
v
if nv > 0, a matrix with dimensions ncol(x) by nv of unit orthogonal columns. This is not present if nv=0.

DETAILS:

The svd functions are based on dsvdc and zsvdc from LINPACK (Dongarra et al. 1979). Termination criteria are modified to avoid infinite looping on some compilers.

For any n x p matrix X , the definition of the singular value decomposition implies that u is an n x n matrix and v is a p x p matrix. The nu and nv options can be used to make either matrix smaller than expected, but not larger.

BACKGROUND:

The singular value decomposition takes an n by p matrix x and decomposes it into two orthogonal matrices and a diagonal matrix. The squares of the singular values of x are the eigenvalues of t(x) %*% x. In the complex case, they are the eigenvalues of Conj(t(x)) %*% x.

The singular value decomposition can be used as a numerically stable way to perform many operations that are used in multivariate statistics. For example, deciding the rank of a matrix is one task that has been suggested for the decomposition. The "rank" of a matrix is an ill-defined numerical concept and tends to depends on the task at hand. Some hold that the QR decomposition is as good or better than the singular value decomposition at deciding the rank in some situations.

REFERENCES:

Dongarra, J.J., Bunch, J.R., Moler, C.B., and Stewart, G.W. (1979). LINPACK Users' Guide. Philadelphia: SIAM.

Golub, G.H. and Van Loan, C.F. (1983). Matrix Computations. Baltimore: Johns Hopkins University Press.

Thisted, R.A. (1988). Elements of Statistical Computing: Numerical Computation. New York: Chapman and Hall.

SEE ALSO:

, , , ,

EXAMPLES:

amat <- matrix(1:9, 3, 3) # create a 3 by 3 matrix
sva <- svd(amat)
asqrt <- t(sva$v %*% (t(sva$u) * sqrt(sva$d))) #  a squareroot of amat