1

I'm trying to multiply some matrices and the following error occurs:

B <- 2*mcov
B <- cbind(B,c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1))
B <- cbind(B,t(mrend))
B <- rbind(B, c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0))
B <- rbind(B, ((1 + c(meanNovartis, meanRDS, meanRoche, meanEJ, meanHSBC, 
           meanBayer, meanUnilever, meanGSK, meanSanofi, meanAnheuser, 
           meanSiemens, meanLoreal, meanInnate, 
           meanBT,meanNestle,0,0)^12)-1))
B
c <- matrix(c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,(((1+mean(meanRDS))^12))-1),
            nrow=17, ncol=1)

And when trying to solve:

 x <- solve(B)%*%c

This error appears:

Error in solve.default(B) : Lapack routine dgesv: system is exactly singular: U[17,17] = 0

1 Answers1

1

You are trying to compute the LU factorization of a matrix which has no inverse. As a result, the LAPACK package (which is what R is actually running when you make your call to solve) is trying to divide by zero.

The solution to your problem is to either clean up your data if that be the cause, or find another way to obtain your eigenvalues.

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360