Help please! I'm new in Gauss

Hi there,

I'm trying to replicate a GAUSS code but without success so far. I Googled possible solutions and also read the manual, but I think it was not enough.  Here the problem

I am running a .gau code in GAUSS 17, but I got this error:

G0014 : File not found 'c:\research\gauss\healdn\crossgd.dht' [cross7.gau, line 115]

The point here is that I am trying to open a .out file called crossgd.out.

I go to line 115, and it looks like:

open fh=c:\research\gauss\healdn\crossgd.out;

Previously, I ran open fh=C:\research\gauss\healdn\crossvar.out; without error warnings.

Also, I have included all the libraries, right folder paths, etc. Last, I tried

open fh=c:\research\gauss\healdn\crossgd; 

but I got this error warning:

open fh=c:\research\gauss\healdn\crossgd.out
G0122 : Bad file handle [cross7.gau, line 120]

Line 120 says: dat1=readr(fh, 1);

 

Please, could you help guys to discover what I am doing wrong?

Thanks in advance.

3 Answers



0



This is the dtail of my code:

----------------------------------------------------------------------

/*Read in the data*/
if model ==1; @ total of 20 moment conditions @
if kate==0;
open fh=C:\research\gauss\healdn\crossvar;
elseif kate==1;
open fh=o:\user_lib\g1kxg00\eric\healdn\crossvar;
endif;
dat=readr(fh, 1);
fh=close(fh);
nummom=(cols(dat))/3;
"nummom = " nummom;

mdat=dat[.,1:nummom]';
mdat=ln(mdat);
obsdat=dat[.,(1+nummom):(2*nummom)];
pctdat=dat[.,(1+2*nummom):cols(dat)]';
pctdat=ln(pctdat);

obsdat=obsdat~obsdat;
weightmat=obsdat.*eye(cols(obsdat));
"weightmat = " weightmat;

elseif (model==2 or model==3 or model==4 or model==5);
@ total of 40 moment conditions if model==2 or 3, 60 moment conditions if model ==4 or 5 @

if kate==0;
open fh=c:\research\gauss\healdn\crossgd.out;
elseif kate==1;
open fh=o:\user_lib\g1kxg00\eric\healdn\crossgd;
endif;

dat1=readr(fh, 1);
fh=close(fh);

if kate==0;
open fh=c:\research\gauss\healdn\crossbad;
elseif kate==1;
open fh=o:\user_lib\g1kxg00\eric\healdn\crossbad;
endif;

dat2=readr(fh, 1);
fh=close(fh);

if (model ==2 or model ==3);
nummom=20;

mdat=dat1[.,1:10]'|dat2[.,1:10]';

obsdat1=dat1[.,21:30];
obsdat2=dat2[.,21:30];

pctdat=dat1[.,41:50]'|dat2[.,41:50]';

elseif (model ==4 or model==5);
nummom=20;

mdat=dat1[.,1:5]'|dat1[.,11:20]'|dat2[.,1:5]'|dat2[.,11:20]';

obsdat1=dat1[.,21:25]~dat1[.,31:40];
obsdat2=dat2[.,21:25]~dat2[.,31:40];

pctdat=dat1[.,41:45]'|dat1[.,51:60]'|dat2[.,41:45]'|dat2[.,51:60]';

endif;

obsdat=obsdat1~obsdat2~obsdat1~obsdat2;
weightmat=obsdat.*eye(cols(obsdat));
"nummom = " nummom;
"weightmat = " weightmat;
mdat=ln(mdat);
pctdat=ln(pctdat);
" rows = " rows(mdat)~rows(pctdat);

endif;



0



I suspect that your problem is occurring because your file crossgd.out is not a GAUSS dataset. I can't be sure, but based on the file extension, I would guess it is a text data file.

The command

open fh=c:\research\gauss\healdn\crossgd.out;

that ran without error most likely failed. You can check to see if it failed by checking the value of fh after you run that line. If the file open failed, fh will be equal to -1.

Assuming that my guess is correct, you need to save your data to a GAUSS dataset for that code to work. We are happy to help with that, but please ask that as a separate question so that it will be easier for others to find in the future.

aptech

1,773


0



You are correct. I got a -1 for the fh variable. I will open another thread to ask how to save my .out file (text data) to a GAUSS dataset.

Your Answer

3 Answers

0

This is the dtail of my code:

----------------------------------------------------------------------

/*Read in the data*/
if model ==1; @ total of 20 moment conditions @
if kate==0;
open fh=C:\research\gauss\healdn\crossvar;
elseif kate==1;
open fh=o:\user_lib\g1kxg00\eric\healdn\crossvar;
endif;
dat=readr(fh, 1);
fh=close(fh);
nummom=(cols(dat))/3;
"nummom = " nummom;

mdat=dat[.,1:nummom]';
mdat=ln(mdat);
obsdat=dat[.,(1+nummom):(2*nummom)];
pctdat=dat[.,(1+2*nummom):cols(dat)]';
pctdat=ln(pctdat);

obsdat=obsdat~obsdat;
weightmat=obsdat.*eye(cols(obsdat));
"weightmat = " weightmat;

elseif (model==2 or model==3 or model==4 or model==5);
@ total of 40 moment conditions if model==2 or 3, 60 moment conditions if model ==4 or 5 @

if kate==0;
open fh=c:\research\gauss\healdn\crossgd.out;
elseif kate==1;
open fh=o:\user_lib\g1kxg00\eric\healdn\crossgd;
endif;

dat1=readr(fh, 1);
fh=close(fh);

if kate==0;
open fh=c:\research\gauss\healdn\crossbad;
elseif kate==1;
open fh=o:\user_lib\g1kxg00\eric\healdn\crossbad;
endif;

dat2=readr(fh, 1);
fh=close(fh);

if (model ==2 or model ==3);
nummom=20;

mdat=dat1[.,1:10]'|dat2[.,1:10]';

obsdat1=dat1[.,21:30];
obsdat2=dat2[.,21:30];

pctdat=dat1[.,41:50]'|dat2[.,41:50]';

elseif (model ==4 or model==5);
nummom=20;

mdat=dat1[.,1:5]'|dat1[.,11:20]'|dat2[.,1:5]'|dat2[.,11:20]';

obsdat1=dat1[.,21:25]~dat1[.,31:40];
obsdat2=dat2[.,21:25]~dat2[.,31:40];

pctdat=dat1[.,41:45]'|dat1[.,51:60]'|dat2[.,41:45]'|dat2[.,51:60]';

endif;

obsdat=obsdat1~obsdat2~obsdat1~obsdat2;
weightmat=obsdat.*eye(cols(obsdat));
"nummom = " nummom;
"weightmat = " weightmat;
mdat=ln(mdat);
pctdat=ln(pctdat);
" rows = " rows(mdat)~rows(pctdat);

endif;

0

I suspect that your problem is occurring because your file crossgd.out is not a GAUSS dataset. I can't be sure, but based on the file extension, I would guess it is a text data file.

The command

open fh=c:\research\gauss\healdn\crossgd.out;

that ran without error most likely failed. You can check to see if it failed by checking the value of fh after you run that line. If the file open failed, fh will be equal to -1.

Assuming that my guess is correct, you need to save your data to a GAUSS dataset for that code to work. We are happy to help with that, but please ask that as a separate question so that it will be easier for others to find in the future.

0

You are correct. I got a -1 for the fh variable. I will open another thread to ask how to save my .out file (text data) to a GAUSS dataset.


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.