Dear all,
I would be very thankful for help on below error:
Error in solve.default(h, z[[2]]) :
Lapack routine dgesv: system is exactly singular: U[9,9] = 0
This error occurs when I run the following loop below. The strange thing is that this only occurs when I ran it with high numbers (e.g. with i in 2:10 this error does not occur!)
After googling the error it seems to be related to the fact that the matrix is a singular matrix and does not have a matrix inverse. But I dont understand why it runs fine e.g. with 10 loops and what causes this error.
> result<-matrix(0,0,4)
>
> for(i in 2:500){
> expr<-as.vector(predicted_gene[,i] )
>
> resi<-crr(
> ftime = pheno$survalltime,
> fstatus = pheno$event_status,
> cov1 = model.matrix(~ factor(sex) + age + factor(Site_Category) + factor(ajcc) +expr , data = pheno)[, -1],
> failcode =1, cencode = 0)
>
> coef<-matrix(c(summary(resi)$coef[9,c(2,3,4,5)]),1,4)
> rownames(coef)<-colnames(predicted_gene)[i]
> {result<-rbind(result,coef)}
> }
Has anyone an idea what could be the problem with higher numbers?
Thanks so much!!