new; "ESTIMATE.GPR: program to compute NLS, FGLS or maximum likelihood estimates"; " of binary choice model for Econ551 1999 Problem Set 5"; ""; " By John Rust, Yale University, March, 1997. ";""; /* STEP 1: Load in ASCII dataset and convert to GAUSS data sets. */ load dat[]=data3.asc; dat=reshape(dat,rows(dat)/2,2); dat=dat[1:500,.]; y=dat[.,1]; x=ones(rows(dat),1)~dat[.,2]~dat[.,2]^2~dat[.,2]^3; dat=y~x; let vnames=const b1 b2 b3 ; dat=saved(dat,"dat3","vnames"); /* STEP 2: Prompt user for type of model and estimation method */ redo1: "Which choice probability model to estimate? (1=probit/2=logit) ";; model=con(1,1); if (model /= 1) and (model /= 2); goto redo1; endif; redo2: "Which estimation method? (1=NLS/2=FGLS/3=MLE) ";; estmethod=con(1,1); if (estmethod/=1)and(estmethod/=2)and(estmethod/=3); goto redo2; endif; redo3: "Which action? (1=check gradient/2=check hessian/3=estimate) ";; action=con(1,1); if (action /= 1) and (action /= 2) and (action /= 3); goto redo3; endif; procvec=&prb_nls~&prb_fgls~&prb_mle~ &log_nls~&log_fgls~&log_mle; let models=prb log; let methods=nls fgls mle cfgls; estobj=procvec[3*(model-1)+estmethod]; qsav=lower(""$+models[model]$+"_"$+methods[estmethod]); outfile=lower(""$+models[model]$+"_"$+methods[estmethod]$+".out"); iloc=seqa(2,1,4); cloc=0; dloc=1; q=zeros(4,1); infile="dat3"; dvar="y"; let ivar=theta0 theta1 theta2 theta3; /* STEP 3: Go do it */ if (action == 1); call drvchk(dloc,iloc,cloc,q,infile,3000,outfile,qsav,estobj); elseif (action == 2); call hesschk(dloc,iloc,cloc,q,infile,3000,outfile,qsav,estobj); else; call max(dvar,dloc,ivar,iloc,cloc,q,infile,3000,outfile,qsav,estobj); endif;