Singular Value Decomposition of a Matrix

DESCRIPTION:
Returns a list containing the singular value decomposition of the input. The function svd has been made generic. In particular, there is an svd method in the Matrix library that differs (both in argument list, as well as in returned value) from the S-PLUS default. See the svd.Matrix help file for more details on this method.

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 wanted in matrix u. This must be zero, ncol(x) or nrow(x).
nv:
number of columns wanted in matrix v, possibly zero.

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

DETAILS:
Based on the functions dsvdc and zsvdc from LINPACK (Dongarra et al. 1979) (termination criteria are modified to avoid infinite looping on some compilers).

BACKGROUND:
The singular value decomposition takes an n by p matrix 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 theyre 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.

Deciding on the rank of a matrix is one task that has been suggested for the singular value. The "rank" of a matrix is numerically a rather ill-defined concept and really depends on the task at hand. Some hold that the QR decomposition is as good or better in some situations as the singular value decomposition at testing the rank.


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

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

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


SEE ALSO:
chol , eigen , matrix , qr , svd.Matrix .

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