MDCEV model G0008 : Syntax error

I modefied the Gauss code for MDCEV model provided by the Prof. Bhat.  http://www.caee.utexas.edu/prof/bhat/CodeRepository/CODES/MDCEV_Files/MDCEV_No_Outside_Good.zip

The original code was for cases of 3 alternatives and one independent variable, while my data contained 4 alternatives and 2 independent variables ("tsaint" and "length"). The modified code worked out when I only use d 4 alternatives and 1 independent variable. Yet, when I applied 4 alternatives and 2 independent variables I only got the message "G0008 : Syntax error " and it didn't show which line went wrong. My csv data and code are here:https://drive.google.com/file/d/1uSabE6FB5ltuiuGd4ZroiR-pyOayb4Uo/view?usp=sharing Thanks.

4 Answers



0



It appears that the syntax error is coming from this code around line 95

let ivm2 = {    uno sero    sero    tsaint  sero    sero    length  sero    sero};
let ivm3 = {    sero    uno sero    sero    tsaint  sero    sero    length  sero};
let ivm4 = {    sero    sero    uno sero    sero    tsaint  sero    sero    length};

It needs a space between the final element and the closing curly brace like below. Also, you do not need to let statement. So I would recommend this

ivm2 = { uno    sero    sero    tsaint  sero    sero    length  sero    sero };
ivm3 = { sero   uno sero    sero    tsaint  sero    sero    length  sero };
ivm4 = { sero   sero    uno sero    sero    tsaint  sero    sero    length };

I would also recommend a bit of simplification for the data loading section which will make the code easier to work with. I would replace this

//load data from CSV file
load tmp[] = before_secure.csv;

//reshape data into 11x2 matrix
//first row is variable names
tmp = reshape(tmp, 309, 9);

//Extract variable names
//from first row of 'tmp'
var_names_2 = tmp[1,.];
dataset_name = "before_secure";

//strip off variable names from data
tmp = tmp[2:rows(tmp), .];

//Create dataset named age_and_height_varnames.dat
//with variable names from CSV file
y = saved(tmp, dataset_name, var_names_2); 

with this code

//Load all variables from CSV file
//No need to reshape data
tmp = loadd("before_secure.csv");

//Load variable names from file
var_names_2 = getHeaders("before_secure.csv");

dataset_name = "before_secure";

//Create dataset named 'before_secure.dat'
//with variable names from CSV file
y = saved(tmp, dataset_name, var_names_2); 

aptech

1,338


0



I have modified the code as you recommended, but it showed other messages.

"vector of parameter labels does not conform to vector of starting values"

"G0105 : Bad expression or missing arguments [maxutil.src, line 2870]"

Revised code is as below : Thanks.

https://drive.google.com/open?id=1uSabE6FB5ltuiuGd4ZroiR-pyOayb4Uo



0



The first error message vector of parameter labels does not conform to vector of starting values is coming because the model has 15 parameters, but only 12 parameter names are assigned. The line of code which sets the parameter names, with a couple surrounding lines for context, is listed below. It is near line 250 or so in the main file.

/* Other Maxlik globals */

_max_ParNames = varnam|varndell|varngam|"sigm";     // Appending all the parameter (or coefficient) names
_max_GradProc=&lgd;  

I'll take a look at the second error.

aptech

1,338


0



The second error message is coming because the number of rows is incorrectly specified. There appear to be only 307 observations in the CSV file. Observation number 129 is missing, I believe. It is better to change the code so that the number of rows is defined by the data loaded rather than being specified ahead of time. So I would change this

__row    = 308;     // Number of rows to be read at a time by the log-likelihood function
nobs     = 308;    // Number of observations in the dataset

// Other global variable assignments would be here, but are skipped to keep this compact

//Load all variables from CSV file
//No need to reshape data
tmp = loadd("before_secure.csv");

to this

//Load all variables from CSV file
//No need to reshape data
tmp = loadd("before_secure.csv");

__row    = rows(tmp);     // Number of rows to be read at a time by the log-likelihood function
nobs     = rows(tmp);    // Number of observations in the dataset
// Other global variable assignments would be here, but are skipped to keep this compact

This way, you do not have to remember to set the number of rows and it is less error-prone.

aptech

1,338

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