kappa
Compute the Exact or Estimated Condition Number

Description

Computes the exact or estimated condition number of a matrix, based on various norms.
This function is an S Version 3 generic. One can write methods that handle new classes of data. Classes that already have methods include matrix, lm, and qr.

Usage

#Generic function 
kappa(z,...) 

## Default S3 method: kappa(z, exact = FALSE, norm = NULL, method = c("qr", "direct"), ...) ## S3 method for class 'lm': kappa(z, ...) ## S3 method for class 'qr': kappa(z, ...)

.kappa_tri(z, exact = FALSE, LINPACK = TRUE, norm = NULL, ...)

Arguments

z a matrix or an object, like a fitted model, that contains information from a decomposition of some matrix.
exact a logical value.
  • If TRUE, returns the exact 2-norm condition number, based on the extrema of the singular values.
  • If FALSE (the default), returns a more quickly computed approximate condition number.
norm a character string. Specifies the norm type of the matrix. It is one of"2", "1", "O" or "I". See the help file norm for details. The default NULL is interpreted as 2-norm type in kappa.default, or 1-norm type in .kappa_tri.
method Either "qr" or "direct".
  • If "direct", the matrix z is assumed to be upper triangular: the values in its lower triangle are taken to be 0.
  • If "qr" (the default), then the condition number is computed from the the (upper triangula) R matrix of the QR decompostion of z. This argument is ignored when exact is TRUE: only the approximate methods require an upper triangular matrix.
LINPACK This argument is ignored and is here only for compatibility with R 2.15.1.
... other arguments are ignored by the methods described above. Methods defined in other packages can use more arguments.

Details

The condition number of a matrix is the product of the matrix and the norm of its inverse (or pseudo-inverse if the matrix is not square). Because it can take on values between 1 and infinity, inclusive, it can be viewed as a measure of how close a matrix is to being rank deficient. It can also be viewed as a factor by which errors in solving linear systems with this matrix as coefficient matrix could be magnified.
Condition numbers are usually approximate, because exact computation is costly, in terms of floating-point operations. The exact condition number of 2-norm type matrix is the ratio of the largest to the smallest non-zero singular value decomposition of the matrix (call function svd).
Methods for kappa usually use a cheap approximation to this. They call the "internal" function .kappa_tri directly or indirectly to do the linear algebra. .kappa_tri computes the approximate condition number of a triangular square matrix by using the LINPACK subroutine "dtrco" ("ztrco" for complex matrices) for the 2-norm and the LAPACK subroutine "dtrcon" ("ztrcon" for complex matrices) for the 1- and Infinity-norms. (When exact is TRUE, it uses svd to compute the 2-norm condition number.)
Value
SNextSpec
[xipan,2011-04-18]: Review and update the most of content to be compatible with R.
References
Anderson. E., et al. 1999. http://www.netlib.org/lapack/lug/lapack_lug.html. LAPACK Users' Guide. Third Edition. Philadelphia, PA: SIAM Publications.
Chambers, J. M. and Hastie, T .J. (Eds.) 1992. Chapter 4: Linear models. Statistical Models in S. Pacific Grove, CA.: Wadsworth & Brooks/Cole.
See Also
norm,rcond, qr
Examples
kappa(var(Sdatasets::fuel.frame[,1:4]))
kappa(var(Sdatasets::fuel.frame[,1:4]), norm = "I")

fitMpg <- lm(Fuel ~ Weight + Type, data=Sdatasets::fuel.frame) kappa(fitMpg) kappa(fitMpg, exact=TRUE)

Package base version 6.1.1-7
Package Index