"MNLEST.GPR: program to compute maximum likelihood estimates of binomial logit model as a hint for Econ 551 midterm exam By John Rust, Yale University, March, 1997. "; /* STEP 1: Load in ASCII datasets and convert to GAUSS data sets with alternative-specific covariates for use in general form of multinomial logit model coded in EVAL.G. Note the 3 coefficients (const, slope_a and slope_b) are normalized to 0 for alternative 1. So estimate 3 coefficients for alternative 2.*/ load dat[]=data2.asc; dat=reshape(dat,2000,3); /* incorrect code: y=(dat[.,1] .== 2); y=1 if choose alt 2, y =0 otherwise */ /* corrected code: y=(dat[.,1] .== 1); /* y=1 if choose alt 1, y =0 otherwise */ x=ones(2000,1)~dat[.,2:3]; dat=y~x; let vnames=const slope_a slope_b; dat=saved(dat,"data3","vnames"); /* Step 2: set up input variables to estimate MNL model in DATA2.ASC, performing a derivative check first to make sure likelihood and derivatives are correctly coded in EVAL.G */ iloc=seqa(2,1,3); cloc=0; dloc=1; q=zeros(3,1); infile="data3"; outfile="data3.est"; qsav="q_data3"; dvar="y"; let ivar=const slope_a slope_b; /* Uncomment this line if you would like to run a derivative check, i.e. a comparison of numerical and analytical derivatives of the log-likelihood function call drvchk(dloc,iloc,cloc,q,infile,2000,outfile,qsav,&eval); */ /* Below is the main procedure that maximizes the likelihood function */ call max(dvar,dloc,ivar,iloc,cloc,q,infile,500,outfile,qsav,&eval);