kappa                  package:base                  R Documentation

_C_o_m_p_u_t_e _o_r _E_s_t_i_m_a_t_e _t_h_e _C_o_n_d_i_t_i_o_n _N_u_m_b_e_r _o_f _a _M_a_t_r_i_x

_D_e_s_c_r_i_p_t_i_o_n:

     The condition number of a regular (square) matrix is the product
     of the _norm_ of the matrix and the norm of its inverse (or
     pseudo-inverse), and hence depends on the kind of matrix-norm.

     'kappa()' computes an estimate of the 2-norm condition number of a
       matrix or of the R matrix of a  QR decomposition, perhaps of a
     linear fit.  The 2-norm condition number can be shown to be the
     ratio of the largest to the smallest _non-zero_ singular value of
     the matrix.

_U_s_a_g_e:

     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, ...)

     rcond(x, norm = c("O","I","1"), triangular = FALSE, ...)

_A_r_g_u_m_e_n_t_s:

     z,x: A matrix or a the result of 'qr' or a fit from a class
          inheriting from '"lm"'.

   exact: logical. Should the result be exact?

    norm: character string, specifying the matrix norm wrt to which the
          condition number is to be computed.  '"O"', the default,
          means the *O*ne- or 1-norm.  The (currently only) other
          possible value is '"I"' for the infinity norm.

  method: character string, specifying the method to be used; '"qr"' is
          default for back-compatibility, mainly.

triangular: logical.  If true, the matrix used is just the lower
          triangular part of 'z'.

 LINPACK: logical.  If true and 'z' is not complex, the Linpack routine
          'dtrco()' is called; otherwise the relevant Lapack routine
          is.

     ...: further arguments passed to or from other methods.

_D_e_t_a_i_l_s:

     For 'kappa()', if 'exact = FALSE' (the default) the 2-norm
     condition number is estimated by a cheap approximation. Following
     S, by default, this uses the LINPACK routine 'dtrco()'. However,
     in R (or S) the exact calculation (via 'svd') is also likely to be
     quick enough.

     Note that the 1- and Inf-norm condition numbers are much faster to
     calculate, and 'rcond()' computes these _*r*eciprocal_ condition
     numbers, also for complex matrices, using standard Lapack
     routines.

     'kappa.tri' is an internal function called by 'kappa.qr'.

_V_a_l_u_e:

     The condition number, kappa, or an approximation if 'exact =
     FALSE'.

_A_u_t_h_o_r(_s):

     The design was inspired by (but differs considerably from) the S
     function of the same name described in Chambers (1992).

_R_e_f_e_r_e_n_c_e_s:

     Chambers, J. M. (1992) _Linear models._ Chapter 4 of _Statistical
     Models in S_ eds J. M. Chambers and T. J. Hastie, Wadsworth &
     Brooks/Cole.

_S_e_e _A_l_s_o:

     'svd' for the singular value decomposition and 'qr' for the QR
     one.

_E_x_a_m_p_l_e_s:

     kappa(x1 <- cbind(1,1:10))# 15.71
     kappa(x1, exact = TRUE)        # 13.68
     kappa(x2 <- cbind(x1,2:11))# high! [x2 is singular!]

     hilbert <- function(n) { i <- 1:n; 1 / outer(i - 1, i, "+") }
     sv9 <- svd(h9 <- hilbert(9))$ d
     kappa(h9)# pretty high!
     kappa(h9, exact = TRUE) == max(sv9) / min(sv9)
     kappa(h9, exact = TRUE) / kappa(h9) # .677 (i.e., rel.error = 32%)

