chol() dimnames
Peter Dalgaard BSA
p.dalgaard@biostat.ku.dk
27 Sep 1999 14:03:52 +0200
Prof Brian Ripley <ripley@stats.ox.ac.uk> writes:
> I believe all one actually knows is that the colnames of R should be the
> colnames of x, if the row and column names of x match. However, the
> prototype does preserve the names. Should we just preserve the colnames?
That would make OK sense to me. By assumption X == t(X) so if it doesn't
have the same row and column names, something is wrong anyway and we
can do whatever we please to fix things up.
However: Somewhere in the back of my mind lies a note to the effect
that chol() should really handle the rank-deficient cases better, via
some sort of pivoting. Will this muck things up (possibly not if it
only removes singularities and plugs in rows/cols of zeroes)? I seem to
recall that the current chol() got lme() in trouble. I got as far as
locating the candidate replacement for chol.f on Netlib and then got
away from it.
Currently, we get
> z<-matrix(rnorm(15),3,5)
> x<-t(z)*z
> chol(x)
Error: singular matrix in chol
The prototype (Splus 3.4) handles this a bit better:
> chol(x)
[,1] [,2] [,3] [,4] [,5]
[1,] 1.703739 1.9199843 -0.94401977 -1.129732e+00 -8.387157e-01
[2,] 0.000000 0.7605888 0.08437014 8.385107e-01 -2.259906e-01
[3,] 0.000000 0.0000000 0.86549993 7.381480e-01 5.811783e-01
[4,] 0.000000 0.0000000 0.00000000 -7.771561e-16 1.110223e-16
[5,] 0.000000 0.0000000 0.00000000 0.000000e+00 0.000000e+00
attr(, "rank"):
[1] 3
Warning messages:
Choleski decomposition not of full rank in: chol(x)
It also allows pivoting, but I don't think we want their algorithm:
> chol(x,piv=T)
[,1] [,2] [,3] [,4] [,5]
[1,] 2.065148 -0.7414994 -0.8465894 1.583980e+00 -8.629924e-01
[2,] 0.000000 1.4051462 0.8172503 -5.339291e-01 3.893657e-01
[3,] 0.000000 0.0000000 0.5126111 3.296278e-01 4.426312e-01
[4,] 0.000000 0.0000000 0.0000000 2.107342e-08 5.268356e-09
[5,] 0.000000 0.0000000 0.0000000 0.000000e+00 7.850462e-17
attr(, "pivot"):
[1] 2 4 3 1 5
attr(, "rank"):
[1] 5
^
!
oops....
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._