Model run by stephane.hess using Apollo 0.3.4 on R 4.4.0 for Darwin. Please acknowledge the use of Apollo by citing Hess & Palma (2019) DOI 10.1016/j.jocm.2019.100170 www.ApolloChoiceModelling.com Model name : DM Model description : Simple DM model on Swiss route choice data Model run at : 2024-09-27 17:29:12.355433 Estimation method : bgw Model diagnosis : Relative function convergence Optimisation diagnosis : Maximum found hessian properties : Negative definite maximum eigenvalue : -1.902826 reciprocal of condition number : 1.86651e-05 Number of individuals : 388 Number of rows in database : 3492 Number of modelled outcomes : 3492 Number of cores used : 1 Model without mixing LL(start) : -1759.24 LL (whole model) at equal shares, LL(0) : -2420.47 LL (whole model) at observed shares, LL(C) : -2420.39 LL(final, whole model) : -1455.64 Rho-squared vs equal shares : 0.3986 Adj.Rho-squared vs equal shares : 0.3932 Rho-squared vs observed shares : 0.3986 Adj.Rho-squared vs observed shares : 0.3998 AIC : 2937.29 BIC : 3017.34 LL(0,Combination_1) : -2420.47 LL(final,Combination_1) : -3327.63 LL(0,Combination_2) : -2420.47 LL(final,Combination_2) : -3083.32 LL(0,Combination_3) : -2420.47 LL(final,Combination_3) : -3617.67 LL(0,Combination_4) : -2420.47 LL(final,Combination_4) : -2961.65 LL(0,Combination_5) : -2420.47 LL(final,Combination_5) : -2813.27 LL(0,Combination_6) : -2420.47 LL(final,Combination_6) : -2965.86 LL(0,Combination_7) : -2420.47 LL(final,Combination_7) : -3310.99 LL(0,Combination_8) : -2420.47 LL(final,Combination_8) : -2847.77 LL(0,Combination_9) : -2420.47 LL(final,Combination_9) : -1790.93 LL(0,Combination_10) : -2420.47 LL(final,Combination_10) : -2365.91 LL(0,Combination_11) : -2420.47 LL(final,Combination_11) : -2667.9 LL(0,Combination_12) : -2420.47 LL(final,Combination_12) : -2434.3 LL(0,Combination_13) : -2420.47 LL(final,Combination_13) : -3977.17 LL(0,Combination_14) : -2420.47 LL(final,Combination_14) : -4209.65 LL(0,Combination_15) : -2420.47 LL(final,Combination_15) : -4483.34 LL(0,Combination_16) : -2420.47 LL(final,Combination_16) : -4003.72 Estimated parameters : 13 Time taken (hh:mm:ss) : 00:00:6.9 pre-estimation : 00:00:2.07 estimation : 00:00:1.53 post-estimation : 00:00:3.3 Iterations : 29 Unconstrained optimisation. Estimates: Estimate s.e. t.rat.(0) Rob.s.e. Rob.t.rat.(0) asc_1 -0.03437 0.060600 -0.5671 0.07199 -0.4774 asc_2 0.00000 NA NA NA NA beta_tt_a -0.24792 0.023252 -10.6623 0.03154 -7.8608 beta_tt_b -0.09495 0.008966 -10.5898 0.01087 -8.7333 beta_tc_a -0.20782 0.026693 -7.7857 0.03265 -6.3643 beta_tc_b -0.94330 0.090962 -10.3702 0.14376 -6.5617 beta_hw_a -0.03007 0.008172 -3.6791 0.01920 -1.5663 beta_hw_b -0.11965 0.031715 -3.7726 0.07879 -1.5187 beta_ch_a -0.71746 0.140362 -5.1115 0.21552 -3.3290 beta_ch_b -3.13147 0.330562 -9.4732 0.52984 -5.9102 delta_tt_a -0.61274 0.299333 -2.0470 0.34903 -1.7556 delta_tc_a 0.51009 0.242235 2.1058 0.30058 1.6970 delta_hw_a 0.47523 0.690377 0.6884 1.68258 0.2824 delta_ch_a -0.29032 0.281638 -1.0308 0.41967 -0.6918 delta_tt_b 0.00000 NA NA NA NA delta_tc_b 0.00000 NA NA NA NA delta_hw_b 0.00000 NA NA NA NA delta_ch_b 0.00000 NA NA NA NA Summary of class allocation for model component : Mean prob. Combination_1 0.05794 Combination_2 0.07746 Combination_3 0.03602 Combination_4 0.04816 Combination_5 0.03479 Combination_6 0.04651 Combination_7 0.02163 Combination_8 0.02892 Combination_9 0.10693 Combination_10 0.14295 Combination_11 0.06648 Combination_12 0.08888 Combination_13 0.06421 Combination_14 0.08583 Combination_15 0.03992 Combination_16 0.05337 Overview of choices for MNL model component Combination_1: alt1 alt2 Times available 3492.00 3492.00 Times chosen 1734.00 1758.00 Percentage chosen overall 49.66 50.34 Percentage chosen when available 49.66 50.34 Overview of choices for MNL model component Combination_2: alt1 alt2 Times available 3492.00 3492.00 Times chosen 1734.00 1758.00 Percentage chosen overall 49.66 50.34 Percentage chosen when available 49.66 50.34 Overview of choices for MNL model component Combination_3: alt1 alt2 Times available 3492.00 3492.00 Times chosen 1734.00 1758.00 Percentage chosen overall 49.66 50.34 Percentage chosen when available 49.66 50.34 Overview of choices for MNL model component Combination_4: alt1 alt2 Times available 3492.00 3492.00 Times chosen 1734.00 1758.00 Percentage chosen overall 49.66 50.34 Percentage chosen when available 49.66 50.34 Overview of choices for MNL model component Combination_5: alt1 alt2 Times available 3492.00 3492.00 Times chosen 1734.00 1758.00 Percentage chosen overall 49.66 50.34 Percentage chosen when available 49.66 50.34 Overview of choices for MNL model component Combination_6: alt1 alt2 Times available 3492.00 3492.00 Times chosen 1734.00 1758.00 Percentage chosen overall 49.66 50.34 Percentage chosen when available 49.66 50.34 Overview of choices for MNL model component Combination_7: alt1 alt2 Times available 3492.00 3492.00 Times chosen 1734.00 1758.00 Percentage chosen overall 49.66 50.34 Percentage chosen when available 49.66 50.34 Overview of choices for MNL model component Combination_8: alt1 alt2 Times available 3492.00 3492.00 Times chosen 1734.00 1758.00 Percentage chosen overall 49.66 50.34 Percentage chosen when available 49.66 50.34 Overview of choices for MNL model component Combination_9: alt1 alt2 Times available 3492.00 3492.00 Times chosen 1734.00 1758.00 Percentage chosen overall 49.66 50.34 Percentage chosen when available 49.66 50.34 Overview of choices for MNL model component Combination_10: alt1 alt2 Times available 3492.00 3492.00 Times chosen 1734.00 1758.00 Percentage chosen overall 49.66 50.34 Percentage chosen when available 49.66 50.34 Overview of choices for MNL model component Combination_11: alt1 alt2 Times available 3492.00 3492.00 Times chosen 1734.00 1758.00 Percentage chosen overall 49.66 50.34 Percentage chosen when available 49.66 50.34 Overview of choices for MNL model component Combination_12: alt1 alt2 Times available 3492.00 3492.00 Times chosen 1734.00 1758.00 Percentage chosen overall 49.66 50.34 Percentage chosen when available 49.66 50.34 Overview of choices for MNL model component Combination_13: alt1 alt2 Times available 3492.00 3492.00 Times chosen 1734.00 1758.00 Percentage chosen overall 49.66 50.34 Percentage chosen when available 49.66 50.34 Overview of choices for MNL model component Combination_14: alt1 alt2 Times available 3492.00 3492.00 Times chosen 1734.00 1758.00 Percentage chosen overall 49.66 50.34 Percentage chosen when available 49.66 50.34 Overview of choices for MNL model component Combination_15: alt1 alt2 Times available 3492.00 3492.00 Times chosen 1734.00 1758.00 Percentage chosen overall 49.66 50.34 Percentage chosen when available 49.66 50.34 Overview of choices for MNL model component Combination_16: alt1 alt2 Times available 3492.00 3492.00 Times chosen 1734.00 1758.00 Percentage chosen overall 49.66 50.34 Percentage chosen when available 49.66 50.34 Classical covariance matrix: asc_1 beta_tt_a beta_tt_b beta_tc_a beta_tc_b beta_hw_a beta_hw_b beta_ch_a asc_1 0.003672 -8.923e-05 5.196e-06 -1.3491e-04 -3.0924e-04 6.552e-05 2.8495e-04 8.9651e-04 beta_tt_a -8.923e-05 5.4065e-04 1.3952e-04 4.1716e-04 0.001507 -2.249e-05 -5.047e-05 2.9678e-04 beta_tt_b 5.196e-06 1.3952e-04 8.039e-05 1.6462e-04 5.3210e-04 -1.171e-06 1.863e-05 1.6581e-04 beta_tc_a -1.3491e-04 4.1716e-04 1.6462e-04 7.1252e-04 0.001628 -3.848e-05 -1.2421e-04 -3.4061e-04 beta_tc_b -3.0924e-04 0.001507 5.3210e-04 0.001628 0.008274 -1.2245e-04 -4.3747e-04 -5.3290e-04 beta_hw_a 6.552e-05 -2.249e-05 -1.171e-06 -3.848e-05 -1.2245e-04 6.678e-05 2.2018e-04 4.5844e-04 beta_hw_b 2.8495e-04 -5.047e-05 1.863e-05 -1.2421e-04 -4.3747e-04 2.2018e-04 0.001006 0.001972 beta_ch_a 8.9651e-04 2.9678e-04 1.6581e-04 -3.4061e-04 -5.3290e-04 4.5844e-04 0.001972 0.019702 beta_ch_b 0.002508 0.001277 6.3452e-04 -3.2182e-04 1.0478e-04 0.001079 0.005931 0.031266 delta_tt_a -4.0095e-04 0.003889 0.001209 0.002895 0.010945 -1.8782e-04 -6.8061e-04 0.004835 delta_tc_a 9.5735e-04 -0.001549 -4.0763e-04 -0.002502 -0.009878 2.7303e-04 0.001240 0.002972 delta_hw_a -0.005934 0.002661 2.0645e-04 0.003857 0.013799 -0.005192 -0.020089 -0.039827 delta_ch_a -0.001875 -2.0608e-04 -2.0731e-04 9.7008e-04 0.002710 -7.6731e-04 -0.003455 -0.031019 beta_ch_b delta_tt_a delta_tc_a delta_hw_a delta_ch_a asc_1 0.002508 -4.0095e-04 9.5735e-04 -0.005934 -0.001875 beta_tt_a 0.001277 0.003889 -0.001549 0.002661 -2.0608e-04 beta_tt_b 6.3452e-04 0.001209 -4.0763e-04 2.0645e-04 -2.0731e-04 beta_tc_a -3.2182e-04 0.002895 -0.002502 0.003857 9.7008e-04 beta_tc_b 1.0478e-04 0.010945 -0.009878 0.013799 0.002710 beta_hw_a 0.001079 -1.8782e-04 2.7303e-04 -0.005192 -7.6731e-04 beta_hw_b 0.005931 -6.8061e-04 0.001240 -0.020089 -0.003455 beta_ch_a 0.031266 0.004835 0.002972 -0.039827 -0.031019 beta_ch_b 0.109271 -0.001975 0.016172 -0.096758 -0.067691 delta_tt_a -0.001975 0.089600 -0.035806 0.012324 -0.009513 delta_tc_a 0.016172 -0.035806 0.058678 -0.021888 -0.007195 delta_hw_a -0.096758 0.012324 -0.021888 0.476620 0.069870 delta_ch_a -0.067691 -0.009513 -0.007195 0.069870 0.079320 Robust covariance matrix: asc_1 beta_tt_a beta_tt_b beta_tc_a beta_tc_b beta_hw_a beta_hw_b beta_ch_a asc_1 0.005183 -4.5985e-04 -1.733e-05 -6.7332e-04 -0.002548 5.2881e-04 0.002203 0.004681 beta_tt_a -4.5985e-04 9.9469e-04 2.2895e-04 8.2909e-04 0.003773 -2.1081e-04 -8.3864e-04 -0.001172 beta_tt_b -1.733e-05 2.2895e-04 1.1820e-04 2.2459e-04 7.5634e-04 -2.352e-06 3.256e-05 2.8218e-04 beta_tc_a -6.7332e-04 8.2909e-04 2.2459e-04 0.001066 0.003688 -3.0449e-04 -0.001232 -0.002912 beta_tc_b -0.002548 0.003773 7.5634e-04 0.003688 0.020666 -0.001034 -0.004570 -0.010954 beta_hw_a 5.2881e-04 -2.1081e-04 -2.352e-06 -3.0449e-04 -0.001034 3.6845e-04 0.001458 0.002996 beta_hw_b 0.002203 -8.3864e-04 3.256e-05 -0.001232 -0.004570 0.001458 0.006207 0.012604 beta_ch_a 0.004681 -0.001172 2.8218e-04 -0.002912 -0.010954 0.002996 0.012604 0.046449 beta_ch_b 0.013252 -0.002135 9.8351e-04 -0.006429 -0.026665 0.006973 0.031627 0.096942 delta_tt_a -3.8439e-04 0.006672 0.001710 0.004819 0.024487 -0.001334 -0.004768 0.001730 delta_tc_a 0.003296 -0.003599 9.886e-05 -0.004011 -0.025030 0.002032 0.009116 0.023785 delta_hw_a -0.048891 0.020001 3.0445e-04 0.028270 0.100737 -0.031732 -0.130427 -0.267036 delta_ch_a -0.010286 0.002487 -3.8973e-04 0.005998 0.023625 -0.004956 -0.021800 -0.080844 beta_ch_b delta_tt_a delta_tc_a delta_hw_a delta_ch_a asc_1 0.013252 -3.8439e-04 0.003296 -0.04889 -0.010286 beta_tt_a -0.002135 0.006672 -0.003599 0.02000 0.002487 beta_tt_b 9.8351e-04 0.001710 9.886e-05 3.0445e-04 -3.8973e-04 beta_tc_a -0.006429 0.004819 -0.004011 0.02827 0.005998 beta_tc_b -0.026665 0.024487 -0.025030 0.10074 0.023625 beta_hw_a 0.006973 -0.001334 0.002032 -0.03173 -0.004956 beta_hw_b 0.031627 -0.004768 0.009116 -0.13043 -0.021800 beta_ch_a 0.096942 0.001730 0.023785 -0.26704 -0.080844 beta_ch_b 0.280730 -0.014919 0.075131 -0.63309 -0.191625 delta_tt_a -0.014919 0.121823 -0.056319 0.10480 -0.012579 delta_tc_a 0.075131 -0.056319 0.090351 -0.18362 -0.044862 delta_hw_a -0.633088 0.104795 -0.183616 2.83107 0.460395 delta_ch_a -0.191625 -0.012579 -0.044862 0.46039 0.176121 Classical correlation matrix: asc_1 beta_tt_a beta_tt_b beta_tc_a beta_tc_b beta_hw_a beta_hw_b beta_ch_a asc_1 1.000000 -0.06333 0.009564 -0.08340 -0.056101 0.13230 0.14826 0.10540 beta_tt_a -0.063328 1.00000 0.669244 0.67212 0.712690 -0.11834 -0.06845 0.09093 beta_tt_b 0.009564 0.66924 1.000000 0.68784 0.652442 -0.01598 0.06553 0.13175 beta_tc_a -0.083404 0.67212 0.687838 1.00000 0.670421 -0.17639 -0.14672 -0.09091 beta_tc_b -0.056101 0.71269 0.652442 0.67042 1.000000 -0.16474 -0.15164 -0.04174 beta_hw_a 0.132299 -0.11834 -0.015976 -0.17639 -0.164739 1.00000 0.84955 0.39968 beta_hw_b 0.148260 -0.06845 0.065528 -0.14672 -0.151644 0.84955 1.00000 0.44306 beta_ch_a 0.105398 0.09093 0.131754 -0.09091 -0.041739 0.39968 0.44306 1.00000 beta_ch_b 0.125195 0.16620 0.214093 -0.03647 0.003485 0.39929 0.56573 0.67386 delta_tt_a -0.022104 0.55880 0.450449 0.36238 0.401976 -0.07679 -0.07169 0.11508 delta_tc_a 0.065218 -0.27506 -0.187688 -0.38689 -0.448305 0.13793 0.16141 0.08740 delta_hw_a -0.141846 0.16577 0.033353 0.20929 0.219743 -0.92035 -0.91752 -0.41100 delta_ch_a -0.109832 -0.03147 -0.082101 0.12904 0.105785 -0.33340 -0.38678 -0.78467 beta_ch_b delta_tt_a delta_tc_a delta_hw_a delta_ch_a asc_1 0.125195 -0.02210 0.06522 -0.14185 -0.10983 beta_tt_a 0.166200 0.55880 -0.27506 0.16577 -0.03147 beta_tt_b 0.214093 0.45045 -0.18769 0.03335 -0.08210 beta_tc_a -0.036473 0.36238 -0.38689 0.20929 0.12904 beta_tc_b 0.003485 0.40198 -0.44830 0.21974 0.10579 beta_hw_a 0.399285 -0.07679 0.13793 -0.92035 -0.33340 beta_hw_b 0.565726 -0.07169 0.16141 -0.91752 -0.38678 beta_ch_a 0.673856 0.11508 0.08740 -0.41100 -0.78467 beta_ch_b 1.000000 -0.01996 0.20197 -0.42398 -0.72708 delta_tt_a -0.019964 1.00000 -0.49382 0.05963 -0.11284 delta_tc_a 0.201967 -0.49382 1.00000 -0.13088 -0.10546 delta_hw_a -0.423982 0.05963 -0.13088 1.00000 0.35935 delta_ch_a -0.727084 -0.11284 -0.10546 0.35935 1.00000 Robust correlation matrix: asc_1 beta_tt_a beta_tt_b beta_tc_a beta_tc_b beta_hw_a beta_hw_b beta_ch_a asc_1 1.00000 -0.2025 -0.02215 -0.2864 -0.2462 0.38268 0.38846 0.30168 beta_tt_a -0.20254 1.0000 0.66773 0.8050 0.8321 -0.34822 -0.33751 -0.17237 beta_tt_b -0.02215 0.6677 1.00000 0.6326 0.4839 -0.01127 0.03801 0.12043 beta_tc_a -0.28642 0.8050 0.63261 1.0000 0.7856 -0.48577 -0.47879 -0.41372 beta_tc_b -0.24623 0.8321 0.48394 0.7856 1.0000 -0.37466 -0.40348 -0.35356 beta_hw_a 0.38268 -0.3482 -0.01127 -0.4858 -0.3747 1.00000 0.96423 0.72421 beta_hw_b 0.38846 -0.3375 0.03801 -0.4788 -0.4035 0.96423 1.00000 0.74229 beta_ch_a 0.30168 -0.1724 0.12043 -0.4137 -0.3536 0.72421 0.74229 1.00000 beta_ch_b 0.34742 -0.1277 0.17074 -0.3716 -0.3501 0.68564 0.75763 0.84895 delta_tt_a -0.01530 0.6061 0.45065 0.4228 0.4880 -0.19910 -0.17338 0.02300 delta_tc_a 0.15231 -0.3796 0.03025 -0.4087 -0.5792 0.35213 0.38495 0.36715 delta_hw_a -0.40363 0.3769 0.01664 0.5145 0.4165 -0.98250 -0.98388 -0.73639 delta_ch_a -0.34045 0.1879 -0.08542 0.4377 0.3916 -0.61522 -0.65932 -0.89383 beta_ch_b delta_tt_a delta_tc_a delta_hw_a delta_ch_a asc_1 0.34742 -0.01530 0.15231 -0.40363 -0.34045 beta_tt_a -0.12774 0.60612 -0.37959 0.37691 0.18789 beta_tt_b 0.17074 0.45065 0.03025 0.01664 -0.08542 beta_tc_a -0.37156 0.42277 -0.40867 0.51452 0.43765 beta_tc_b -0.35008 0.48802 -0.57925 0.41647 0.39159 beta_hw_a 0.68564 -0.19910 0.35213 -0.98250 -0.61522 beta_hw_b 0.75763 -0.17338 0.38495 -0.98388 -0.65932 beta_ch_a 0.84895 0.02300 0.36715 -0.73639 -0.89383 beta_ch_b 1.00000 -0.08067 0.47175 -0.71014 -0.86179 delta_tt_a -0.08067 1.00000 -0.53682 0.17844 -0.08588 delta_tc_a 0.47175 -0.53682 1.00000 -0.36305 -0.35564 delta_hw_a -0.71014 0.17844 -0.36305 1.00000 0.65200 delta_ch_a -0.86179 -0.08588 -0.35564 0.65200 1.00000 20 most extreme outliers in terms of lowest average per choice prediction: ID Avg prob per choice 22580 0.2660951 15174 0.2838328 23205 0.2873823 16178 0.2955003 21922 0.3133758 21623 0.3300901 16617 0.3321235 16489 0.3383992 76862 0.3389019 22961 0.3765806 12534 0.3813932 20100 0.3857674 15312 0.3867632 15056 0.3908446 22820 0.3989176 14754 0.4128663 24627 0.4129172 15489 0.4135322 17645 0.4269145 82613 0.4296092 Changes in parameter estimates from starting values: Initial Estimate Difference asc_1 0.00000 -0.03437 -0.034367 asc_2 0.00000 0.00000 0.000000 beta_tt_a 0.00000 -0.24792 -0.247920 beta_tt_b 0.00000 -0.09495 -0.094946 beta_tc_a 0.00000 -0.20782 -0.207824 beta_tc_b 0.00000 -0.94330 -0.943296 beta_hw_a -0.03960 -0.03007 0.009535 beta_hw_b -0.04790 -0.11965 -0.071750 beta_ch_a -0.76240 -0.71746 0.044938 beta_ch_b -2.17250 -3.13147 -0.958965 delta_tt_a 0.00000 -0.61274 -0.612743 delta_tc_a 0.00000 0.51009 0.510090 delta_hw_a 0.00000 0.47523 0.475228 delta_ch_a 0.00000 -0.29032 -0.290324 delta_tt_b 0.00000 0.00000 0.000000 delta_tc_b 0.00000 0.00000 0.000000 delta_hw_b 0.00000 0.00000 0.000000 delta_ch_b 0.00000 0.00000 0.000000 Settings and functions used in model definition: apollo_control -------------- Value modelName "DM" modelDescr "Simple DM model on Swiss route choice data" indivID "ID" noDiagnostics "TRUE" noValidation "TRUE" outputDirectory "output/" debug "FALSE" nCores "1" workInLogs "FALSE" seed "13" mixing "FALSE" HB "FALSE" calculateLLC "TRUE" analyticHessian "FALSE" memorySaver "FALSE" panelData "TRUE" analyticGrad "TRUE" analyticGrad_manualSet "FALSE" overridePanel "FALSE" preventOverridePanel "FALSE" noModification "FALSE" Hessian routines attempted -------------------------- numerical jacobian of LL analytical gradient Scaling used in computing Hessian --------------------------------- Value asc_1 0.03436679 beta_tt_a 0.24791999 beta_tt_b 0.09494629 beta_tc_a 0.20782447 beta_tc_b 0.94329568 beta_hw_a 0.03006523 beta_hw_b 0.11964997 beta_ch_a 0.71746184 beta_ch_b 3.13146523 delta_tt_a 0.61274338 delta_tc_a 0.51008959 delta_hw_a 0.47522754 delta_ch_a 0.29032439 apollo_lcPars --------------- function(apollo_beta, apollo_inputs){ lcpars = list() ### Create empty lists for parameters in classes and class allocation probabilities lcpars[["beta_tt"]] = list() lcpars[["beta_tc"]] = list() lcpars[["beta_hw"]] = list() lcpars[["beta_ch"]] = list() ### Loop over combinations, determining parameter values and class allocation probabilities (multiplicatively) for(s in 1:16){ lcpars[["beta_tt"]][[s]] = get(paste0("beta_tt_", ifelse( s<=8, "a", "b"))) lcpars[["beta_tc"]][[s]] = get(paste0("beta_tc_", ifelse( (s-(s>8)*8)<=4, "a", "b"))) lcpars[["beta_hw"]][[s]] = get(paste0("beta_hw_", ifelse((ceiling(s/2)%%2)!=0, "a", "b"))) lcpars[["beta_ch"]][[s]] = get(paste0("beta_ch_", ifelse( s%%2!=0, "a", "b"))) } ### Generic settings for class allocation models classAlloc_settings = list( classes = c(class_a=1, class_b=2), avail = 1 ) V = list() for(s in 1:16){ V[[s]] = get(paste0("delta_tt_", ifelse( s<=8, "a", "b"))) + get(paste0("delta_tc_", ifelse( (s-(s>8)*8)<=4, "a", "b"))) + get(paste0("delta_hw_", ifelse((ceiling(s/2)%%2)!=0, "a", "b"))) + get(paste0("delta_ch_", ifelse( s%%2!=0, "a", "b"))) } classAlloc_settings$utilities = V lcpars[["pi_values"]] = apollo_classAlloc(classAlloc_settings) return(lcpars) } apollo_probabilities ---------------------- function(apollo_beta, apollo_inputs, functionality="estimate"){ ### Attach inputs and detach after function exit apollo_attach(apollo_beta, apollo_inputs) on.exit(apollo_detach(apollo_beta, apollo_inputs)) ### Create list of probabilities P P = list() ### Define settings for MNL model component that are generic across classes mnl_settings = list( alternatives = c(alt1=1, alt2=2), avail = list(alt1=1, alt2=1), choiceVar = choice ) ### Loop over classes for(s in 1:16){ ### Compute class-specific utilities V = list() V[["alt1"]] = asc_1 + beta_tc[[s]]*tc1 + beta_tt[[s]]*tt1 + beta_hw[[s]]*hw1 + beta_ch[[s]]*ch1 V[["alt2"]] = asc_2 + beta_tc[[s]]*tc2 + beta_tt[[s]]*tt2 + beta_hw[[s]]*hw2 + beta_ch[[s]]*ch2 mnl_settings$utilities = V ### Compute within-class choice probabilities using MNL model P[[paste0("Combination_",s)]] = apollo_mnl(mnl_settings, functionality) ### Take product across observation for same individual P[[paste0("Combination_",s)]] = apollo_panelProd(P[[paste0("Combination_",s)]], apollo_inputs ,functionality) } ### Compute latent class model probabilities lc_settings = list(inClassProb = P, classProb=pi_values) P[["model"]] = apollo_lc(lc_settings, apollo_inputs, functionality) ### Prepare and return outputs of function P = apollo_prepareProb(P, apollo_inputs, functionality) return(P) }