[R] calculationg condition numbers

Martin Maechler maechler at stat.math.ethz.ch
Wed Feb 26 16:35:03 CET 2003


>>>>> "ChrisL" == Christoph Lehmann <lehmann at puk.unibe.ch>
>>>>>     on Wed, 26 Feb 2003 15:37:58 +0100 writes:

    ChrisL> am I right in the assumption, that for calculation
    ChrisL> of the condition numbers I have to use the
    ChrisL> correlation matrix of X, and not t(x) %*% x?

not quite.
R has a kappa() with several variants/methods for computing
condition numbers, as  help.search() shows quickly.
If I do

  > help.search("condition number")
  Help files with alias or title matching 'condition number',
  type 'help(FOO, package = PKG)' to inspect entry 'FOO(PKG) TITLE':

  rcond(Matrix)           Estimate the Reciprocal Condition Number
  kappa(base)             Estimate the Condition Number

I see that the CRAN package Matrix has even more

    >> e <- eigen(t(x) %*% x)

using the SVD directly is better...

    ChrisL> better (x must not have a first column of ones): 
    >> e <- eigen(cor(x))


    >> e$val
    ChrisL> [1] 6.6653e+07 2.0907e+05 1.0536e+05 1.8040e+04 2.4557e+01 2.0151e+00
    >> sqrt(e$val[1]/e$val)
    ChrisL> [1] 1.000 17.855 25.153 60.785 1647.478 5751.216

    ChrisL> thanks

    ChrisL> christoph
    ChrisL> -- 
    ChrisL> Christoph Lehmann                            Phone:  ++41 31 930 93 83 
    ChrisL> Department of Psychiatric Neurophysiology    Mobile: ++41 76 570 28 00
    ChrisL> University Hospital of Clinical Psychiatry   Fax:    ++41 31 930 99 61 
    ChrisL> Waldau                                            lehmann at puk.unibe.ch 
    ChrisL> CH-3000 Bern 60            http://www.puk.unibe.ch/cl/pn_ni_cv_cl.html

    ChrisL> ______________________________________________
    ChrisL> R-help at stat.math.ethz.ch mailing list
    ChrisL> http://www.stat.math.ethz.ch/mailman/listinfo/r-help




More information about the R-help mailing list