--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- name: log: /Users/kleintob/Documents/GitHub/econometricsResearchMaster/notes for lectures in class/stata 3 multinomial choice.log log type: text opened on: 9 May 2026, 10:18:21 . . . . ** multinomial logit . . /* > first: only alternative-invariant characteristics (w's) > https://www.stata.com/manuals/rmlogit.pdf > */ . . use https://www.stata-press.com/data/r17/sysdsn1, clear (Health insurance data) . tabulate insure nonwhite, chi2 col +-------------------+ | Key | |-------------------| | frequency | | column percentage | +-------------------+ Type of | Nonwhite insurance | 0 1 | Total -----------+----------------------+---------- Indemnity | 251 43 | 294 | 50.71 35.54 | 47.73 -----------+----------------------+---------- Prepaid | 208 69 | 277 | 42.02 57.02 | 44.97 -----------+----------------------+---------- Uninsure | 36 9 | 45 | 7.27 7.44 | 7.31 -----------+----------------------+---------- Total | 495 121 | 616 | 100.00 100.00 | 100.00 Pearson chi2(2) = 9.5599 Pr = 0.008 . . tab insure Type of | insurance | Freq. Percent Cum. ------------+----------------------------------- Indemnity | 294 47.73 47.73 Prepaid | 277 44.97 92.69 Uninsure | 45 7.31 100.00 ------------+----------------------------------- Total | 616 100.00 . tab insure, nol Type of | insurance | Freq. Percent Cum. ------------+----------------------------------- 1 | 294 47.73 47.73 2 | 277 44.97 92.69 3 | 45 7.31 100.00 ------------+----------------------------------- Total | 616 100.00 . . mlogit insure i.nonwhite age i.male, base(3) Iteration 0: Log likelihood = -555.85446 Iteration 1: Log likelihood = -545.60089 Iteration 2: Log likelihood = -545.58328 Iteration 3: Log likelihood = -545.58328 Multinomial logistic regression Number of obs = 615 LR chi2(6) = 20.54 Prob > chi2 = 0.0022 Log likelihood = -545.58328 Pseudo R2 = 0.0185 ------------------------------------------------------------------------------ insure | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- Indemnity | 1.nonwhite | -.4333141 .4106255 -1.06 0.291 -1.238125 .371497 age | .0058414 .0114114 0.51 0.609 -.0165245 .0282073 1.male | -.5102237 .3639793 -1.40 0.161 -1.22361 .2031626 _cons | 1.811165 .5348606 3.39 0.001 .7628578 2.859473 -------------+---------------------------------------------------------------- Prepaid | 1.nonwhite | .2979518 .4003668 0.74 0.457 -.4867527 1.082656 age | -.0053501 .0115006 -0.47 0.642 -.0278909 .0171908 1.male | .0637587 .3590572 0.18 0.859 -.6399805 .767498 _cons | 1.967866 .5369543 3.66 0.000 .9154546 3.020277 -------------+---------------------------------------------------------------- Uninsure | (base outcome) ------------------------------------------------------------------------------ . . margins, dydx(*) Average marginal effects Number of obs = 615 Model VCE: OIM dy/dx wrt: 1.nonwhite age 1.male 1._predict: Pr(insure==Indemnity), predict(pr outcome(1)) 2._predict: Pr(insure==Prepaid), predict(pr outcome(2)) 3._predict: Pr(insure==Uninsure), predict(pr outcome(3)) ------------------------------------------------------------------------------ | Delta-method | dy/dx std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- 0.nonwhite | (base outcome) -------------+---------------------------------------------------------------- 1.nonwhite | _predict | 1 | -.1647252 .048175 -3.42 0.001 -.2591464 -.070304 2 | .16232 .0497498 3.26 0.001 .0648121 .2598279 3 | .0024052 .0268169 0.09 0.929 -.050155 .0549653 -------------+---------------------------------------------------------------- age | _predict | 1 | .0025192 .0013985 1.80 0.072 -.0002218 .0052601 2 | -.0024963 .0014032 -1.78 0.075 -.0052466 .0002541 3 | -.0000229 .0007445 -0.03 0.975 -.0014821 .0014363 -------------+---------------------------------------------------------------- 0.male | (base outcome) -------------+---------------------------------------------------------------- 1.male | _predict | 1 | -.135529 .045055 -3.01 0.003 -.2238351 -.0472229 2 | .1206355 .0460828 2.62 0.009 .0303148 .2109562 3 | .0148935 .0255213 0.58 0.560 -.0351272 .0649142 ------------------------------------------------------------------------------ Note: dy/dx for factor levels is the discrete change from the base level. . . /* > next: now also alternative-specific charateristics (z's) > https://www.stata.com/manuals13/rasclogit.pdf > */ . . use http://www.stata-press.com/data/r13/choice, clear . list id car choice dealer sex income in 1/12, sepby(id) +---------------------------------------------------+ | id car choice dealer sex income | |---------------------------------------------------| 1. | 1 American 0 18 male 46.7 | 2. | 1 Japan 0 8 male 46.7 | 3. | 1 Europe 1 5 male 46.7 | |---------------------------------------------------| 4. | 2 American 1 17 male 26.1 | 5. | 2 Japan 0 6 male 26.1 | 6. | 2 Europe 0 2 male 26.1 | |---------------------------------------------------| 7. | 3 American 1 12 male 32.7 | 8. | 3 Japan 0 6 male 32.7 | 9. | 3 Europe 0 2 male 32.7 | |---------------------------------------------------| 10. | 4 American 0 18 female 49.2 | 11. | 4 Japan 1 7 female 49.2 | 12. | 4 Europe 0 4 female 49.2 | +---------------------------------------------------+ . asclogit choice dealer, case(id) alternatives(car) casevars(i.sex income) Iteration 0: Log likelihood = -273.55685 Iteration 1: Log likelihood = -252.75109 Iteration 2: Log likelihood = -250.78555 Iteration 3: Log likelihood = -250.7794 Iteration 4: Log likelihood = -250.7794 Alternative-specific conditional logit Number of obs = 885 Case ID variable: id Number of cases = 295 Alternatives variable: car Alts per case: min = 3 avg = 3.0 max = 3 Wald chi2(5) = 15.86 Log likelihood = -250.7794 Prob > chi2 = 0.0072 ------------------------------------------------------------------------------ choice | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- car | dealer | .0680938 .0344465 1.98 0.048 .00058 .1356076 -------------+---------------------------------------------------------------- American | (base alternative) -------------+---------------------------------------------------------------- Japan | sex | male | -.5346039 .3141564 -1.70 0.089 -1.150339 .0811314 income | .0325318 .012824 2.54 0.011 .0073973 .0576663 _cons | -1.352189 .6911829 -1.96 0.050 -2.706882 .0025049 -------------+---------------------------------------------------------------- Europe | sex | male | .5704109 .4540247 1.26 0.209 -.3194612 1.460283 income | .032042 .0138676 2.31 0.021 .004862 .0592219 _cons | -2.355249 .8526681 -2.76 0.006 -4.026448 -.6840501 ------------------------------------------------------------------------------ . margins, dydx(*) Average marginal effects Number of obs = 885 Model VCE: OIM Expression: Pr(car|1 selected), predict() dy/dx wrt: dealer 1.sex income ------------------------------------------------------------------------------------ | Delta-method | dy/dx std. err. z P>|z| [95% conf. interval] -------------------+---------------------------------------------------------------- dealer | _outcome#car | American#American | .0148741 .0073772 2.02 0.044 .000415 .0293333 American#Japan | -.0092123 .0046385 -1.99 0.047 -.0183037 -.000121 American#Europe | -.0056618 .0028797 -1.97 0.049 -.0113059 -.0000177 Japan#American | -.0092123 .0046385 -1.99 0.047 -.0183037 -.000121 Japan#Japan | .0111952 .0056729 1.97 0.048 .0000766 .0223138 Japan#Europe | -.0019829 .0010843 -1.83 0.067 -.004108 .0001423 Europe#American | -.0056618 .0028797 -1.97 0.049 -.0113059 -.0000177 Europe#Japan | -.0019829 .0010843 -1.83 0.067 -.004108 .0001423 Europe#Europe | .0076447 .0039302 1.95 0.052 -.0000583 .0153476 -------------------+---------------------------------------------------------------- 0.sex | (base outcome) -------------------+---------------------------------------------------------------- 1.sex | _outcome | American | .0388353 .0621534 0.62 0.532 -.0829832 .1606538 Japan | -.1108205 .0572704 -1.94 0.053 -.2230685 .0014274 Europe | .0719853 .0385321 1.87 0.062 -.0035362 .1475067 -------------------+---------------------------------------------------------------- income | _outcome | American | -.0070654 .0022096 -3.20 0.001 -.0113961 -.0027347 Japan | .0044155 .0019792 2.23 0.026 .0005362 .0082947 Europe | .0026499 .0014643 1.81 0.070 -.00022 .0055199 ------------------------------------------------------------------------------------ Note: dy/dx for factor levels is the discrete change from the base level. . . * compare to mlogit results when only alternative-invariant characteristics . asclogit choice, case(id) alternatives(car) casevars(i.sex income) nolog Alternative-specific conditional logit Number of obs = 885 Case ID variable: id Number of cases = 295 Alternatives variable: car Alts per case: min = 3 avg = 3.0 max = 3 Wald chi2(4) = 12.53 Log likelihood = -252.72012 Prob > chi2 = 0.0138 ------------------------------------------------------------------------------ choice | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- American | (base alternative) -------------+---------------------------------------------------------------- Japan | sex | male | -.4694799 .3114939 -1.51 0.132 -1.079997 .141037 income | .0276854 .0123666 2.24 0.025 .0034472 .0519236 _cons | -1.962652 .6216804 -3.16 0.002 -3.181123 -.7441807 -------------+---------------------------------------------------------------- Europe | sex | male | .5388441 .4525279 1.19 0.234 -.3480942 1.425782 income | .0273669 .013787 1.98 0.047 .000345 .0543889 _cons | -3.180029 .7546837 -4.21 0.000 -4.659182 -1.700876 ------------------------------------------------------------------------------ . . preserve . keep if choice == 1 (590 observations deleted) . mlogit car i.sex income Iteration 0: Log likelihood = -259.1712 Iteration 1: Log likelihood = -252.81165 Iteration 2: Log likelihood = -252.72014 Iteration 3: Log likelihood = -252.72012 Multinomial logistic regression Number of obs = 295 LR chi2(4) = 12.90 Prob > chi2 = 0.0118 Log likelihood = -252.72012 Pseudo R2 = 0.0249 ------------------------------------------------------------------------------ car | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- American | (base outcome) -------------+---------------------------------------------------------------- Japan | sex | male | -.4694798 .3114939 -1.51 0.132 -1.079997 .1410371 income | .0276854 .0123666 2.24 0.025 .0034472 .0519236 _cons | -1.962651 .6216803 -3.16 0.002 -3.181122 -.7441801 -------------+---------------------------------------------------------------- Europe | sex | male | .5388443 .4525278 1.19 0.234 -.348094 1.425783 income | .027367 .013787 1.98 0.047 .000345 .0543889 _cons | -3.18003 .7546837 -4.21 0.000 -4.659182 -1.700877 ------------------------------------------------------------------------------ . restore . . . ** nested logit . . /* > https://www.stata.com/manuals/cmnlogit.pdf > see also https://www.stata.com/manuals/cm.pdf > */ . . use https://www.stata-press.com/data/r17/restaurant, clear . describe Contains data from https://www.stata-press.com/data/r17/restaurant.dta Observations: 2,100 Variables: 8 2 Dec 2020 15:07 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Variable Storage Display Value name type format label Variable label --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- family_id int %9.0g family ID restaurant byte %12.0g names choices of restaurants income int %9.0g household income cost float %9.0g average meal cost per person kids byte %9.0g number of kids in the household rating byte %9.0g ratings in local restaurant guide distance float %9.0g distance between home and restaurant chosen byte %9.0g 0 no 1 yes --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Sorted by: family_id . list family_id restaurant chosen kids rating distance in 1/21, sepby(fam) abbrev(10) +--------------------------------------------------------------+ | family_id restaurant chosen kids rating distance | |--------------------------------------------------------------| 1. | 1 Freebirds 1 1 0 1.245553 | 2. | 1 MamasPizza 0 1 1 2.82493 | 3. | 1 CafeEccell 0 1 2 4.21293 | 4. | 1 LosNortenos 0 1 3 4.167634 | 5. | 1 WingsNmore 0 1 2 6.330531 | 6. | 1 Christophers 0 1 4 10.19829 | 7. | 1 MadCows 0 1 5 5.601388 | |--------------------------------------------------------------| 8. | 2 Freebirds 0 3 0 4.162657 | 9. | 2 MamasPizza 0 3 1 2.865081 | 10. | 2 CafeEccell 0 3 2 5.337799 | 11. | 2 LosNortenos 1 3 3 4.282864 | 12. | 2 WingsNmore 0 3 2 8.133914 | 13. | 2 Christophers 0 3 4 8.664631 | 14. | 2 MadCows 0 3 5 9.119597 | |--------------------------------------------------------------| 15. | 3 Freebirds 1 3 0 2.112586 | 16. | 3 MamasPizza 0 3 1 2.215329 | 17. | 3 CafeEccell 0 3 2 6.978715 | 18. | 3 LosNortenos 0 3 3 5.117877 | 19. | 3 WingsNmore 0 3 2 5.312941 | 20. | 3 Christophers 0 3 4 9.551273 | 21. | 3 MadCows 0 3 5 5.539806 | +--------------------------------------------------------------+ . nlogitgen type = restaurant(fast: Freebirds | MamasPizza,family: CafeEccell /// > | LosNortenos| WingsNmore, fancy: Christophers | MadCows) New variable type is generated with 3 groups label list lb_type lb_type: 1 fast 2 family 3 fancy . nlogittree restaurant type Tree structure specified for the nested logit model type N restaurant N -------------------------------- fast 600 --- Freebirds 300 +- MamasPizza 300 family 900 --- CafeEccell 300 |- LosNortenos 300 +- WingsNmore 300 fancy 600 --- Christophers 300 +- MadCows 300 -------------------------------- Total 2100 N = number of observations at each level . gen dummyFast = type==1 . gen dummyFancy = type==3 . nlogit chosen cost rating distance dummyFast dummyFancy || type: income kids, base(family) || /// > restaurant:, noconstant case(family_id) Tree structure specified for the nested logit model type N restaurant N k ------------------------------------ fast 600 --- Freebirds 300 12 +- MamasPizza 300 15 family 900 --- CafeEccell 300 78 |- LosNortenos 300 75 +- WingsNmore 300 69 fancy 600 --- Christophers 300 27 +- MadCows 300 24 ------------------------------------ Total 2100 300 k = number of times alternative is chosen N = number of observations at each level Iteration 0: Log likelihood = -547.19906 Iteration 1: Log likelihood = -514.47771 (backed up) Iteration 2: Log likelihood = -499.77665 (backed up) Iteration 3: Log likelihood = -497.70839 (backed up) Iteration 4: Log likelihood = -495.37869 (backed up) Iteration 5: Log likelihood = -494.66588 (backed up) Iteration 6: Log likelihood = -494.64673 Iteration 7: Log likelihood = -491.61467 Iteration 8: Log likelihood = -488.76263 Iteration 9: Log likelihood = -487.52822 Iteration 10: Log likelihood = -486.39732 Iteration 11: Log likelihood = -485.53108 Iteration 12: Log likelihood = -485.41621 Iteration 13: Log likelihood = -485.30751 Iteration 14: Log likelihood = -485.20252 Iteration 15: Log likelihood = -485.18707 Iteration 16: Log likelihood = -485.18294 Iteration 17: Log likelihood = -485.17736 Iteration 18: Log likelihood = -485.17414 Iteration 19: Log likelihood = -485.17186 Iteration 20: Log likelihood = -485.16947 Iteration 21: Log likelihood = -485.16538 Iteration 22: Log likelihood = -485.16239 Iteration 23: Log likelihood = -485.16204 Iteration 24: Log likelihood = -485.16201 Iteration 25: Log likelihood = -485.16201 RUM-consistent nested logit regression Number of obs = 2,100 Case variable: family_id Number of cases = 300 Alternative variable: restaurant Alts per case: min = 7 avg = 7.0 max = 7 Wald chi2(9) = 44.37 Log likelihood = -485.16201 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ chosen | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- restaurant | cost | -.2011625 .0924974 -2.17 0.030 -.3824542 -.0198709 rating | .3885818 .3355819 1.16 0.247 -.2691466 1.04631 distance | -.3751178 .0999658 -3.75 0.000 -.5710471 -.1791884 dummyFast | -2.48672 11.94546 -0.21 0.835 -25.89938 20.92594 dummyFancy | 1.170185 2.150705 0.54 0.586 -3.045119 5.38549 ------------------------------------------------------------------------------ type equations ------------------------------------------------------------------------------ fast | income | -.0252061 .0119434 -2.11 0.035 -.0486147 -.0017975 kids | -.0694201 .1427072 -0.49 0.627 -.3491211 .2102809 -------------+---------------------------------------------------------------- family | income | 0 (base) kids | 0 (base) -------------+---------------------------------------------------------------- fancy | income | .0458315 .0090799 5.05 0.000 .0280353 .0636277 kids | -.3996378 .122181 -3.27 0.001 -.6391082 -.1601675 ------------------------------------------------------------------------------ dissimilarity parameters ------------------------------------------------------------------------------ /type | fast_tau | 4.584704 17.20423 -29.13496 38.30437 family_tau | 2.296758 1.046972 .2447316 4.348785 fancy_tau | 2.728947 2.102949 -1.392757 6.850652 ------------------------------------------------------------------------------ LR test for IIA (tau=1): chi2(3) = 4.13 Prob > chi2 = 0.2478 . . . ** multinomial probit . . /* > https://www.stata.com/manuals/cmcmmprobit.pdf > */ . . use https://www.stata-press.com/data/r17/travel, clear (Modes of travel) . list id mode choice travelcost termtime income in 1/12, sepby(id) +----------------------------------------------------+ | id mode choice travel~t termtime income | |----------------------------------------------------| 1. | 1 Air 0 70 69 35 | 2. | 1 Train 0 71 34 35 | 3. | 1 Bus 0 70 35 35 | 4. | 1 Car 1 30 0 35 | |----------------------------------------------------| 5. | 2 Air 0 68 64 30 | 6. | 2 Train 0 84 44 30 | 7. | 2 Bus 0 85 53 30 | 8. | 2 Car 1 50 0 30 | |----------------------------------------------------| 9. | 3 Air 0 129 69 40 | 10. | 3 Train 0 195 34 40 | 11. | 3 Bus 0 149 35 40 | 12. | 3 Car 1 101 0 40 | +----------------------------------------------------+ . cmset id mode Case ID variable: id Alternatives variable: mode . cmtab, choice(choice) Tabulation of chosen alternatives (choice = 1) Travel mode | alternative | s | Freq. Percent Cum. ------------+----------------------------------- Air | 58 27.62 27.62 Train | 63 30.00 57.62 Bus | 30 14.29 71.90 Car | 59 28.10 100.00 ------------+----------------------------------- Total | 210 100.00 . cmmprobit choice travelcost termtime, casevars(income) Iteration 0: Log simulated-likelihood = -201.33776 Iteration 1: Log simulated-likelihood = -201.00395 (backed up) Iteration 2: Log simulated-likelihood = -200.80016 (backed up) Iteration 3: Log simulated-likelihood = -200.79329 (backed up) Iteration 4: Log simulated-likelihood = -200.54677 (backed up) Iteration 5: Log simulated-likelihood = -200.52959 (backed up) Iteration 6: Log simulated-likelihood = -197.81655 Iteration 7: Log simulated-likelihood = -196.60511 Iteration 8: Log simulated-likelihood = -195.23981 Iteration 9: Log simulated-likelihood = -194.97557 Iteration 10: Log simulated-likelihood = -193.8367 Iteration 11: Log simulated-likelihood = -192.71514 Iteration 12: Log simulated-likelihood = -192.62109 Iteration 13: Log simulated-likelihood = -192.29533 Iteration 14: Log simulated-likelihood = -191.79816 Iteration 15: Log simulated-likelihood = -190.6148 Iteration 16: Log simulated-likelihood = -190.47993 Iteration 17: Log simulated-likelihood = -190.22168 Iteration 18: Log simulated-likelihood = -190.17784 Iteration 19: Log simulated-likelihood = -190.11022 Iteration 20: Log simulated-likelihood = -190.10726 Iteration 21: Log simulated-likelihood = -190.0955 Iteration 22: Log simulated-likelihood = -190.09542 Iteration 23: Log simulated-likelihood = -190.09343 Iteration 24: Log simulated-likelihood = -190.0933 Iteration 25: Log simulated-likelihood = -190.09323 Iteration 26: Log simulated-likelihood = -190.09322 Multinomial probit choice model Number of obs = 840 Case ID variable: id Number of cases = 210 Alternatives variable: mode Alts per case: min = 4 avg = 4.0 max = 4 Integration sequence: Hammersley Integration points: 600 Wald chi2(5) = 32.16 Log simulated-likelihood = -190.09322 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ choice | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- mode | travelcost | -.0097691 .0027817 -3.51 0.000 -.0152211 -.0043171 termtime | -.0377086 .0093869 -4.02 0.000 -.0561066 -.0193107 -------------+---------------------------------------------------------------- Air | (base alternative) -------------+---------------------------------------------------------------- Train | income | -.0292031 .0089218 -3.27 0.001 -.0466894 -.0117168 _cons | .561912 .3945781 1.42 0.154 -.2114469 1.335271 -------------+---------------------------------------------------------------- Bus | income | -.0127548 .00793 -1.61 0.108 -.0282973 .0027876 _cons | -.0572901 .4789444 -0.12 0.905 -.9960038 .8814236 -------------+---------------------------------------------------------------- Car | income | -.0049142 .0077449 -0.63 0.526 -.0200939 .0102656 _cons | -1.832941 .8171904 -2.24 0.025 -3.434605 -.2312773 -------------+---------------------------------------------------------------- /lnl2_2 | -.5490422 .3889427 -1.41 0.158 -1.311356 .2132714 /lnl3_3 | -.6018061 .3355375 -1.79 0.073 -1.259447 .0558352 -------------+---------------------------------------------------------------- /l2_1 | 1.132598 .2125209 5.33 0.000 .7160651 1.549132 /l3_1 | .971829 .2350542 4.13 0.000 .5111312 1.432527 /l3_2 | .5201047 .2851798 1.82 0.068 -.0388374 1.079047 ------------------------------------------------------------------------------ (mode=Air is the alternative normalizing location) (mode=Train is the alternative normalizing scale) . estat covariance +------------------------------------------------+ | | Train Bus Car | |--------------+---------------------------------| | Train | 2 | | Bus | 1.601736 1.616288 | | Car | 1.374374 1.401054 1.515069 | +------------------------------------------------+ Note: Covariances are for alternatives differenced with Air. . . . ** mixed logit with panel data . . /* > https://www.stata.com/manuals/cmcmxtmixlogit.pdf > > see also https://www.stata.com/features/overview/mixed-logit-regression/ > and https://www.stata.com/manuals/cmcmmixlogit.pdf for cross section versions > */ . . use https://www.stata-press.com/data/r17/transport, clear (Transportation choice data) . describe Contains data from https://www.stata-press.com/data/r17/transport.dta Observations: 6,000 Transportation choice data Variables: 9 23 Jul 2020 09:18 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Variable Storage Display Value name type format label Variable label --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- id int %9.0g Panel identifier t byte %9.0g Time variable alt byte %9.0g alt Alternatives choice byte %8.0g Chosen alternative trcost double %3.2f Cost of travel (in $) trtime double %3.2f Travel time (in hours) age double %2.1f Age (in decades) income byte %10.0g Annual income (in $10,000) parttime byte %10.0g pt Part-time job --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Sorted by: id t alt . list in 1/12, sepby(t) +------------------------------------------------------------------------+ | id t alt choice trcost trtime age income parttime | |------------------------------------------------------------------------| 1. | 1 1 Car 1 4.14 0.13 3.0 3 Full-time | 2. | 1 1 Public 0 4.74 0.42 3.0 3 Full-time | 3. | 1 1 Bicycle 0 2.76 0.36 3.0 3 Full-time | 4. | 1 1 Walk 0 0.92 0.13 3.0 3 Full-time | |------------------------------------------------------------------------| 5. | 1 2 Car 1 8.00 0.14 3.2 5 Full-time | 6. | 1 2 Public 0 3.14 0.12 3.2 5 Full-time | 7. | 1 2 Bicycle 0 2.56 0.18 3.2 5 Full-time | 8. | 1 2 Walk 0 0.64 0.39 3.2 5 Full-time | |------------------------------------------------------------------------| 9. | 1 3 Car 1 1.76 0.18 3.4 5 Part-time | 10. | 1 3 Public 0 2.25 0.50 3.4 5 Part-time | 11. | 1 3 Bicycle 0 0.92 1.05 3.4 5 Part-time | 12. | 1 3 Walk 0 0.58 0.59 3.4 5 Part-time | +------------------------------------------------------------------------+ . cmset id t alt note: case identifier _caseid generated from id and t. note: panel by alternatives identifier _panelaltid generated from id and alt. Panel data: Panels id and time t Case ID variable: _caseid Alternatives variable: alt Panel by alternatives variable: _panelaltid (strongly balanced) Time variable: t, 1 to 3 Delta: 1 unit Note: Data have been xtset. . cmxtmixlogit choice trcost, random(trtime) casevars(age income) Fitting fixed parameter model: Fitting full model: Iteration 0: Log simulated-likelihood = -1025.707 (not concave) Iteration 1: Log simulated-likelihood = -1014.2513 Iteration 2: Log simulated-likelihood = -1006.2212 Iteration 3: Log simulated-likelihood = -1005.9904 Iteration 4: Log simulated-likelihood = -1005.9899 Iteration 5: Log simulated-likelihood = -1005.9899 Mixed logit choice model Number of obs = 6,000 Number of cases = 1,500 Panel variable: id Number of panels = 500 Time variable: t Cases per panel: min = 3 avg = 3.0 max = 3 Alternatives variable: alt Alts per case: min = 4 avg = 4.0 max = 4 Integration sequence: Hammersley Integration points: 594 Wald chi2(8) = 432.68 Log simulated-likelihood = -1005.9899 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ choice | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- alt | trcost | -.8388216 .0438587 -19.13 0.000 -.9247829 -.7528602 trtime | -1.508756 .2641554 -5.71 0.000 -2.026492 -.9910212 -------------+---------------------------------------------------------------- /Normal | sd(trtime)| 1.945596 .2594145 1.498161 2.526661 -------------+---------------------------------------------------------------- Car | (base alternative) -------------+---------------------------------------------------------------- Public | age | .1538915 .0672638 2.29 0.022 .0220569 .2857261 income | -.3815444 .0347459 -10.98 0.000 -.4496451 -.3134437 _cons | -.5756547 .3515763 -1.64 0.102 -1.264732 .1134222 -------------+---------------------------------------------------------------- Bicycle | age | .20638 .0847655 2.43 0.015 .0402426 .3725174 income | -.5225054 .0463235 -11.28 0.000 -.6132978 -.4317131 _cons | -1.137393 .4461318 -2.55 0.011 -2.011795 -.2629909 -------------+---------------------------------------------------------------- Walk | age | .3097417 .1069941 2.89 0.004 .1000372 .5194463 income | -.9016697 .0686042 -13.14 0.000 -1.036132 -.7672078 _cons | -.4183279 .5607112 -0.75 0.456 -1.517302 .6806458 ------------------------------------------------------------------------------ . margins, dydx(*) Average marginal effects Number of obs = 6,000 Model VCE: OIM Expression: Pr(alt), predict() dy/dx wrt: trcost trtime age income ---------------------------------------------------------------------------------- | Delta-method | dy/dx std. err. z P>|z| [95% conf. interval] -----------------+---------------------------------------------------------------- trcost | _outcome#alt | Car#Car | -.0955607 .0027779 -34.40 0.000 -.1010054 -.0901161 Car#Public | .0532301 .0023612 22.54 0.000 .0486022 .057858 Car#Bicycle | .0268475 .002015 13.32 0.000 .0228982 .0307968 Car#Walk | .0154831 .0014453 10.71 0.000 .0126503 .0183159 Public#Car | .0532301 .0023612 22.54 0.000 .0486022 .057858 Public#Public | -.0828226 .0034527 -23.99 0.000 -.0895898 -.0760555 Public#Bicycle | .0171728 .0013221 12.99 0.000 .0145816 .0197641 Public#Walk | .0124197 .0011058 11.23 0.000 .0102525 .014587 Bicycle#Car | .0268475 .002015 13.32 0.000 .0228982 .0307968 Bicycle#Public | .0171728 .0013221 12.99 0.000 .0145816 .0197641 Bicycle#Bicycle | -.0563701 .0038178 -14.76 0.000 -.063853 -.0488873 Bicycle#Walk | .0123498 .0012385 9.97 0.000 .0099223 .0147773 Walk#Car | .0154831 .0014453 10.71 0.000 .0126503 .0183159 Walk#Public | .0124197 .0011058 11.23 0.000 .0102525 .014587 Walk#Bicycle | .0123498 .0012385 9.97 0.000 .0099223 .0147773 Walk#Walk | -.0402527 .0031398 -12.82 0.000 -.0464066 -.0340987 -----------------+---------------------------------------------------------------- trtime | _outcome#alt | Car#Car | -.1581844 .0269102 -5.88 0.000 -.2109275 -.1054414 Car#Public | .1055447 .0171745 6.15 0.000 .0718834 .139206 Car#Bicycle | .0374872 .0073318 5.11 0.000 .0231171 .0518573 Car#Walk | .0151526 .0043034 3.52 0.000 .006718 .0235871 Public#Car | .1055447 .0171745 6.15 0.000 .0718834 .139206 Public#Public | -.1378524 .02287 -6.03 0.000 -.1826767 -.0930281 Public#Bicycle | .0222505 .0042746 5.21 0.000 .0138724 .0306286 Public#Walk | .0100572 .0029658 3.39 0.001 .0042444 .01587 Bicycle#Car | .0374872 .0073318 5.11 0.000 .0231171 .0518573 Bicycle#Public | .0222505 .0042746 5.21 0.000 .0138724 .0306286 Bicycle#Bicycle | -.062946 .0137475 -4.58 0.000 -.0898905 -.0360015 Bicycle#Walk | .0032083 .0031223 1.03 0.304 -.0029113 .009328 Walk#Car | .0151526 .0043034 3.52 0.000 .006718 .0235871 Walk#Public | .0100572 .0029658 3.39 0.001 .0042444 .01587 Walk#Bicycle | .0032083 .0031223 1.03 0.304 -.0029113 .009328 Walk#Walk | -.0284181 .0100035 -2.84 0.004 -.0480246 -.0088116 -----------------+---------------------------------------------------------------- age | _outcome | Car | -.0220884 .006809 -3.24 0.001 -.0354337 -.0087431 Public | .0063836 .0060125 1.06 0.288 -.0054008 .0181679 Bicycle | .0061582 .0050179 1.23 0.220 -.0036767 .0159932 Walk | .0095466 .0046006 2.08 0.038 .0005295 .0185637 -----------------+---------------------------------------------------------------- income | _outcome | Car | .0575787 .0025214 22.84 0.000 .0526368 .0625206 Public | -.0136252 .0024361 -5.59 0.000 -.0183999 -.0088505 Bicycle | -.0140269 .0021579 -6.50 0.000 -.0182563 -.0097975 Walk | -.0299266 .0026442 -11.32 0.000 -.0351091 -.0247441 ---------------------------------------------------------------------------------- . . . log close name: log: /Users/kleintob/Documents/GitHub/econometricsResearchMaster/notes for lectures in class/stata 3 multinomial choice.log log type: text closed on: 9 May 2026, 10:24:08 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------