* SHAZAM PROGRAM FOR MULTINOMIAL LOGIT ESTIMATION * * There are 3 alternatives and the binary variables Y1 and Y2 indicate * the choices for alternatives 1 and 2. * There are 3 explanatory variables: X1, X2 and X3. * Modification of the commands is needed to accomodate other model * specifications. * SET COMLEN=255 SAMPLE 1 85 READ Y1 Y2 X1 X2 X3 1 0 .040576 .026637 .059450 1 0 .031328 .042308 .007495 1 0 -.132694 .002831 -.008426 1 0 .112759 .001313 .007285 1 0 .016381 .000078 -.008251 1 0 .048232 .024150 .031077 1 0 .031328 .078661 .010231 1 0 .016381 .068245 .064304 1 0 -.009790 .085885 .073829 1 0 -.039635 .018264 .084080 1 0 .030582 .053974 .030640 1 0 .096475 .049134 .002686 1 0 -.018161 .041406 .009185 1 0 .043700 .035877 .003075 1 0 .051007 .033104 .025373 1 0 -.074098 .034971 .036375 1 0 .065584 .008808 -.002255 1 0 -.008976 .006865 .005583 1 0 -.018161 .004845 .007501 1 0 .043700 .000776 .001496 0 1 .057049 .022421 .095327 0 1 .008340 .029276 .074090 0 1 -.039635 .030029 .064375 0 1 .092435 .023777 .069742 0 1 -.009790 .024784 .062458 0 1 .030582 .024518 .017542 0 1 .096475 .031988 -.010663 0 1 -.000031 .037785 .022252 0 1 .014763 .040105 .040976 0 1 .033920 .044484 .061093 0 1 .074532 .004112 .058380 0 1 .008340 .003728 .074911 0 1 .043700 .002485 .000394 0 1 .092435 .010061 .070258 0 1 -.009790 .010605 .054638 0 1 .014740 .018310 .016581 0 1 .051007 .018851 .021591 0 1 .064915 .018922 .044295 0 1 -.074098 .022807 .003585 0 1 .048232 .050716 -.023117 0 1 .001283 .073988 .000910 0 1 .040576 .076415 .055494 0 1 -.009790 .073835 .057837 0 1 .030582 .077613 .020857 0 1 .074532 .102522 .059258 0 0 .074532 .023190 .059214 0 0 .064151 .029942 .011914 0 0 .048232 .029214 .006083 0 0 .006089 .029304 .035481 0 0 .002621 .028963 .025289 0 0 .001283 .028184 .005258 0 0 .077739 .027517 .019666 0 0 -.018161 .041307 .001865 0 0 .043700 .042771 .001202 0 0 .014740 .039834 .018614 0 0 -.132694 .038598 -.012283 0 0 .112759 .040879 .007214 0 0 .016381 .039686 -.008879 0 0 .051007 .040218 .022601 0 0 .064915 .049002 .051454 0 0 -.074098 .046275 .008803 0 0 .038713 .046764 -.003229 0 0 .065584 .046408 -.005377 0 0 -.008976 .047528 .001594 0 0 .034790 .047519 .006228 0 0 .056790 .004237 .044953 0 0 .057049 .004112 .103488 0 0 -.039635 .003739 .064521 0 0 .064151 .003513 .011152 0 0 .048232 .003517 .006129 0 0 .006089 .003564 .035170 0 0 .002621 .003513 .024554 0 0 .001283 .003429 .004515 0 0 .077739 .003482 .018849 0 0 .040576 .003379 .056538 0 0 .092435 .003199 .071084 0 0 -.009790 .002978 .062296 0 0 .030582 .002858 .025559 0 0 .096475 .002697 -.004615 0 0 -.000031 .002609 .026128 0 0 -.018161 .002493 .003406 0 0 .031328 .002808 .004930 0 0 .014740 .002777 .017249 0 0 .030582 .017620 .025898 0 0 .096475 .017137 -.004409 GENR Y0=1-Y1-Y2 ?STAT Y1 Y2 Y0 / SUMS=STOT GEN1 NTOT=STOT:1+STOT:2+STOT:3 GEN1 A1=LOG(STOT:1/STOT:3) GEN1 A2=LOG(STOT:2/STOT:3) * Value of log-likelihood function for "null" model GEN1 LL0=STOT:1*A1+STOT:2*A2-NTOT*LOG(1+EXP(A1)+EXP(A2)) PRINT STOT NTOT A1 A2 LL0 * Set starting values DIM BETA 8 GEN1 BETA:1=A1 GEN1 BETA:5=A2 * Specify the parameterization of the model. EQ1: (B10+B11*X1+B12*X2+B13*X3) EQ2: (B20+B21*X1+B22*X2+B23*X3) * Multinomial logit estimation by maximum likelihood NL 1 / LOGDEN NCOEF=8 START=BETA PITER=100 GENRVAR EQ Y1*[EQ1] + Y2*[EQ2] -LOG(1+EXP([EQ1])+EXP([EQ2])) END * A goodness-of-fit measure is the likelihood ratio test. * The test can be compared with a Chi-square distribution with 6 d.f. GEN1 LR=2*($LLF-LL0) PRINT LR * Calculate the predicted choice probabilities GENR P1=EXP([EQ1]) / (1+EXP([EQ1])+EXP([EQ2])) GENR P2=EXP([EQ2]) / (1+EXP([EQ1])+EXP([EQ2])) * Calculate derivatives and elasticities SET NODOECHO DO #=1,3 DERIV X# VP1=EXP([EQ1]) / (1+EXP([EQ1])+EXP([EQ2])) DERIV X# VP2=EXP([EQ2]) / (1+EXP([EQ1])+EXP([EQ2])) DO %=1,2 GENR VE=VP%*X# ?STAT VE P% / SUMS=TOT GEN1 VE#%=TOT:1/TOT:2 ENDO ENDO * Weighted Aggregate Elasticities PRINT VE11 VE21 VE31 VE12 VE22 VE32 STOP