On Thu, 29 Jul 1999, Lorraine Scudieri wrote:
>
> Hi everyone. I am having a problem and would like your help if
> possible. I have a 101 X 101 and a 201X201 matrix which I want to
> invert and am using solve to do it. I get a message which says the
> matrix is apparently singular, but I know that it is not. Could it be
> that the first matrix is 97% zeros and the second is 98.5% zeros?
It is not apparent to you but it is apparent to the S code! It is almost
certainly to do with the condition number being large, so try computing
that (by kappa, but you need to apply it to a qr decomposition), or compute
it via the singular values (svd). From some code I happen to have around:
my.kappa <- function (z, exact = FALSE, ...)
{
z <- as.matrix(z)
if (exact) {
s <- svd(z, nu = 0, nv = 0)$d
max(s)/min(s[s > 0])
}
else if (is.qr(z))
kappa.default(z)
else if (nrow(z) < ncol(z))
kappa.default(qr(t(z)))
else kappa.default(qr(z))
}
Condition numbers of 10^6 or more are likely to cause problems.
--
Brian D. Ripley, ripley@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news
|