G0121 matrix not positive definite with my data

Dear Sir/Madam,

I am trying to run some code from here with my data:http://qed.econ.queensu.ca/jae/datasets/banerjee003/

However, when I use my data, I get the error G0121: Matrix not positive definite. My data is in a series of text files, similar to this:

variable_name_1 variable_name_2
2.0435825 0.080341846 
0.80535276 2.4098247 
1.5886127  1.4082013

I only show 3 observations here, but each file has 307 observations. I am loading my data with the load command like this:

load x[307,2] = mydatafile.txt;

Am I doing something wrong?

1 Answer



0



If you have GAUSS version 16 or newer, you should not use the load command to load data into GAUSS. You will be much better off reading delimited text data with the GAUSS function csvReadM. For space delimited data like yours which contains a header row, you would use this line:

x = csvReadM("mydatafile.txt", 2, 1, " ");

to load your data instead. The inputs to csvReadM are:

  • The filename.
  • The first row of data to read (2 so we skip the header row).

  • The first column to read.
  • The character that separates the data, a space in this case.

The load command is less intuitive in it's usage and requires you to know how many observations are in the file, or it will not read it in correctly. That is why you should use csvReadM instead. With the line that you posted:

load x[307,2] = mydatafile.txt;

The first row of x will contain the variable names stuffed into a matrix element. This may be the cause of your problem.

aptech

1,393

Your Answer


You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.

Try GAUSS for 30 days for FREE

See what GAUSS can do for your data

© Aptech Systems, Inc. All rights reserved.

Privacy Policy