[R] Singular matrix

Dimitris Rizopoulos dimitris.rizopoulos at med.kuleuven.be
Thu Oct 6 15:45:49 CEST 2005


'x' is a rank 5 matrix from which you want to create a rank 10 
crossproduct! Try the following instead:

x <- array(rnorm(100 * nitems, 3, 3), c(100, nitems))
sigma <- crossprod(x)

I hope it helps.

Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://www.med.kuleuven.be/biostat/
     http://www.student.kuleuven.be/~m0390867/dimitris.htm


----- Original Message ----- 
From: "Marc Bernard" <bernarduse1 at yahoo.fr>
To: <r-help at stat.math.ethz.ch>
Sent: Thursday, October 06, 2005 3:11 PM
Subject: [R] Singular matrix


> Dear All,
>
> I have written the  following programs  to find a non-singular 
> (10*10) covariance matrix.
> Here  is the program:
>
> nitems <- 10
>
> x <- array(rnorm(5*nitems,3,3), c(5,nitems))
>
> sigma <- t(x)%*%x
>
> inverse <- try(solve(sigma), TRUE)
>
>
>
> while(inherits(inverse, "try-error"))
>
> {
>
> x <- array(rnorm(5*nitems,3,3), c(5,nitems))
>
> sigma <- t(x)%*%x
>
> inverse <- try(solve(sigma), TRUE)
>
> }
>
>
>
> The loop doesn't stop ...  This means that  no "non-singular" matrix 
> was found!!!
>
> some thing wrong !!
>
>
>
> Thanks a lot for any reply
>
>
>
> Bernard
>
>
>
>
>
>
>
>
>
> ---------------------------------
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm




More information about the R-help mailing list