## Near Singular Matrix

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Jason, EViews Steve, EViews Moderator

gs2440
Posts: 3
Joined: Tue Jul 28, 2009 8:14 am

### Near Singular Matrix

Hi,

As a part of some complex calculation I am simply trying to invert a matrix in e views. However everytime i get the error 'Near Singular matrix...'

The determinant agreed is very small, however i dont need the inverted matrix (with large elements), rather its being invereted as a part of some transient calculation the end result of which should finally make sense. The inversion works fine in Excel as well as Stata. I want to automate the whole process and hence want to do it in E Views. Can anyone help me with resolving this error. Thank u so much.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 11902
Joined: Tue Sep 16, 2008 5:38 pm

### Re: Near Singular Matrix

Assuming this is the matrix you emailed into us, the determinant is not just "very small", it is essentially zero. 1.05e-101 is not "very small". it is zero.

Yes other packages may invert the matrix, but the result they give is a matrix full of extremely large numbers. This matrix is unworkable, and will disrupt any further analysis you do using it. The fact that it is only "part of some transient calculation" is irrelevant - were you to use the result from Excel or Stata all of the calculations based upon the inverse would be meaningless.

I think you're approaching this problem in the wrong way. Rather than trying to get EViews to invert a singular matrix for you, you might be better off working out what is making it singular in the first place (which is essentially an econometric/economic problem, not a software problem).

gs2440
Posts: 3
Joined: Tue Jul 28, 2009 8:14 am

### Re: Near Singular Matrix

The equation that i am using to invert the Matrix is Expected Return of a Black Litteman Model (where the matrix being inverted is the Covariance Matrix, Sigma). If you assume 1.55 x 10 ^ (-101) as zero then the final form the equatiom takes is 0/0 (where both numbers are not zero but tending to zero). Therefore the final result which if at all successfully calculated makes a lot sense (i requested my fellow group to test it on Stata).

In general i am a fan of EViews but i know every software has its limitation and there is nothing wrong with that, but to simply term something as not possible , I would hesitate in that!

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 11902
Joined: Tue Sep 16, 2008 5:38 pm

### Re: Near Singular Matrix

If you invert the matrix in Excel, and then invert it in Stata, do you get the same result? If you invert it in Stata, then multiply it by five and invert, do you get the same result (but divided by 5)?

startz
Non-normality and collinearity are NOT problems!
Posts: 3398
Joined: Wed Sep 17, 2008 2:25 pm

### Re: Near Singular Matrix

If you post an EViews workfile with the matrix, I'll try inverting it in Matlab to see what happens.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 11902
Joined: Tue Sep 16, 2008 5:38 pm

### Re: Near Singular Matrix

I believe the matrix in question is the one called "phi" in the attached workfile.
Attachments
phi.WF1
phi matrix

startz
Non-normality and collinearity are NOT problems!
Posts: 3398
Joined: Wed Sep 17, 2008 2:25 pm

### Re: Near Singular Matrix

Matlab gives a warning message before inverting

Warning: Matrix is close to singular or badly scaled.
Results may be inaccurate. RCOND = 9.842126e-018.

When I multiply the inverse in Matlab by the original matrix, I get a matrix that looks like an identity matrix with a lot of roundoff error. Here is the upper 3x3 block

0.974243 0.003296 0.022705
-0.011719 1.054688 0.039063
0.046875 -0.007813 1.031250