# Re: [R] computationally singular

From: Weiwei Shi <helprhelp_at_gmail.com>
Date: Thu 11 Aug 2005 - 12:24:24 EST

PCA definately is worth of trying, which was my second thought. But thanks for the help and also on the suggestion.

On 8/10/05, Kjetil Brinchmann Halvorsen <kjetil@acelerate.com> wrote:
> Weiwei Shi wrote:
>
> >I think the problem might be caused two variables are very correlated.
> >Should I check the cov matrix and try to delete some?
> >But i am just not quite sure of your reply. Could you detail it with some steps?
> >
> >thanks,
> >
> >
> Why not do principal component analysis? To identify the zero variance
> linear combination(s) look at the nzero eigenvalues. Also, it *might*
> make sense
> to calculate a " mahalanobis" distance replacing the matrix inverse with a
> pseudoinverse.
>
> Kjetil
>
>
> >weiwei
> >
> >On 8/8/05, Christian Hennig <chrish@stats.ucl.ac.uk> wrote:
> >
> >
> >>Once I had a situation where the reason was that the variables were
> >>scaled to extremely different magnitudes. 1e-25 is a *very* small number
> >>but still there is some probability that it may help to look up standard
> >>deviations and to multiply the
> >>variable with the smallest st.dev. with 1e20 or something.
> >>
> >>Best,
> >>Christian
> >>
> >>On Mon, 8 Aug 2005, Weiwei Shi wrote:
> >>
> >>
> >>
> >>>Hi,
> >>>I have a dataset which has around 138 variables and 30,000 cases. I am
> >>>trying to calculate a mahalanobis distance matrix for them and my
> >>>procedure is like this:
> >>>
> >>>Suppose my data is stored in mymatrix
> >>>
> >>>
> >>>>S<-cov(mymatrix) # this is fine
> >>>>D<-sapply(1:nrow(mymatrix), function(i) mahalanobis(mymatrix, mymatrix[i,], S))
> >>>>
> >>>>
> >>>Error in solve.default(cov, ...) : system is computationally singular:
> >>>reciprocal condition number = 1.09501e-25
> >>>
> >>>I understand the error message but I don't know how to trace down
> >>>which variables caused this so that I can "sacrifice" them if there
> >>>are not a lot. Again, not sure if it is due to some variables and not
> >>>sure if dropping variables is a good idea either.
> >>>
> >>>Thanks for help,
> >>>
> >>>weiwei
> >>>
> >>>
> >>>--
> >>>Weiwei Shi, Ph.D
> >>>
> >>>"Did you always know?"
> >>>"No, I did not. But I believed..."
> >>>---Matrix III
> >>>
> >>>______________________________________________
> >>>R-help@stat.math.ethz.ch mailing list
> >>>https://stat.ethz.ch/mailman/listinfo/r-help
> >>>
> >>>
> >>>
> >>Christian Hennig
> >>University College London, Department of Statistical Science
> >>Gower St., London WC1E 6BT, phone +44 207 679 1698
> >>chrish@stats.ucl.ac.uk, www.homepages.ucl.ac.uk/~ucakche
> >>
> >>
> >>
> >
> >
> >
> >
>
>
> --
>
> Kjetil Halvorsen.
>
> Peace is the most effective weapon of mass construction.
> -- Mahdi Elmandjra
>
>
>
>
>
> --
> Internal Virus Database is out-of-date.
> Checked by AVG Anti-Virus.
> Version: 7.0.338 / Virus Database: 267.9.7/60 - Release Date: 28/07/2005
>
>

```--
Weiwei Shi, Ph.D

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help