## 2 Answers

0

The error `G0048 Matrix singular`

most often occurs when attempting to either invert a matrix or solve a system of linear equations with a coefficient matrix in which not all of the columns are linearly independent.

Here is a simple example which will cause the problem

```
//Create a 100x3 random matrix
x = rndn(100, 3);
//Add a fourth column to 'x' which is
//identical to the second column
x = x ~ x[.,2];
//Create a moment matrix
mm = x'x;
//Attempt to invert the singular matrix
mmi = inv(mm);
```

Sometimes this occurs because some of the variables in the model are very similar. Other times this occurs, because the data was loaded incorrectly. You should add a print statement after the line in which the error occurs to inspect the singular matrix, this may help reveal the problem.

0

Thanks