Model run by stephane.hess using Apollo 0.2.9 on R 4.0.5 for Darwin. www.ApolloChoiceModelling.com Model name : DM Model description : Simple DM model on Swiss route choice data Model run at : 2023-05-10 23:00:07 Estimation method : bfgs Model diagnosis : successful convergence Optimisation diagnosis : Maximum found hessian properties : Negative definitive maximum eigenvalue : -1.912311 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) : -2814.23 LL(0,Combination_2) : -2420.47 LL(final,Combination_2) : -2966.91 LL(0,Combination_3) : -2420.47 LL(final,Combination_3) : -3310.11 LL(0,Combination_4) : -2420.47 LL(final,Combination_4) : -2847.88 LL(0,Combination_5) : -2420.47 LL(final,Combination_5) : -3328.87 LL(0,Combination_6) : -2420.47 LL(final,Combination_6) : -3084.4 LL(0,Combination_7) : -2420.47 LL(final,Combination_7) : -3617.22 LL(0,Combination_8) : -2420.47 LL(final,Combination_8) : -2961.89 LL(0,Combination_9) : -2420.47 LL(final,Combination_9) : -3978.74 LL(0,Combination_10) : -2420.47 LL(final,Combination_10) : -4211.42 LL(0,Combination_11) : -2420.47 LL(final,Combination_11) : -4483.11 LL(0,Combination_12) : -2420.47 LL(final,Combination_12) : -4004.39 LL(0,Combination_13) : -2420.47 LL(final,Combination_13) : -1791.1 LL(0,Combination_14) : -2420.47 LL(final,Combination_14) : -2366.42 LL(0,Combination_15) : -2420.47 LL(final,Combination_15) : -2665.97 LL(0,Combination_16) : -2420.47 LL(final,Combination_16) : -2433.85 Estimated parameters : 13 Time taken (hh:mm:ss) : 00:00:19.03 pre-estimation : 00:00:7.05 estimation : 00:00:5.32 initial estimation : 00:00:5.03 estimation after rescaling : 00:00:0.29 post-estimation : 00:00:6.65 Iterations : 42 initial estimation : 41 estimation after rescaling : 1 Unconstrained optimisation. Estimates: Estimate s.e. t.rat.(0) Rob.s.e. Rob.t.rat.(0) asc_1 -0.03435 0.060605 -0.5667 0.07196 -0.4773 asc_2 0.00000 NA NA NA NA beta_tt_a -0.24802 0.023259 -10.6634 0.03152 -7.8682 beta_tt_b -0.09498 0.008966 -10.5930 0.01087 -8.7358 beta_tc_a -0.94369 0.090977 -10.3729 0.14369 -6.5678 beta_tc_b -0.20792 0.026698 -7.7877 0.03261 -6.3749 beta_hw_a -0.03003 0.008161 -3.6792 0.01910 -1.5716 beta_hw_b -0.11953 0.031564 -3.7870 0.07817 -1.5291 beta_ch_a -0.71744 0.140383 -5.1106 0.21548 -3.3296 beta_ch_b -3.13207 0.330839 -9.4671 0.53103 -5.8981 delta_tt_a -0.61292 0.299249 -2.0482 0.34877 -1.7574 delta_tc_a -0.51031 0.242224 -2.1068 0.30053 -1.6980 delta_hw_a 0.47159 0.688058 0.6854 1.67154 0.2821 delta_ch_a -0.29024 0.281698 -1.0303 0.42028 -0.6906 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.03473 Combination_2 0.04643 Combination_3 0.02167 Combination_4 0.02897 Combination_5 0.05786 Combination_6 0.07735 Combination_7 0.03611 Combination_8 0.04826 Combination_9 0.06411 Combination_10 0.08570 Combination_11 0.04001 Combination_12 0.05348 Combination_13 0.10680 Combination_14 0.14277 Combination_15 0.06665 Combination_16 0.08909 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.003673 -8.912e-05 5.327e-06 -3.0837e-04 -1.3457e-04 6.526e-05 2.8286e-04 8.9624e-04 beta_tt_a -8.912e-05 5.4097e-04 1.3954e-04 0.001508 4.1729e-04 -2.220e-05 -4.888e-05 2.9781e-04 beta_tt_b 5.327e-06 1.3954e-04 8.039e-05 5.3210e-04 1.6463e-04 -1.046e-06 1.918e-05 1.6650e-04 beta_tc_a -3.0837e-04 0.001508 5.3210e-04 0.008277 0.001628 -1.2157e-04 -4.3128e-04 -5.2964e-04 beta_tc_b -1.3457e-04 4.1729e-04 1.6463e-04 0.001628 7.1279e-04 -3.818e-05 -1.2235e-04 -3.3997e-04 beta_hw_a 6.526e-05 -2.220e-05 -1.046e-06 -1.2157e-04 -3.818e-05 6.660e-05 2.1864e-04 4.5886e-04 beta_hw_b 2.8286e-04 -4.888e-05 1.918e-05 -4.3128e-04 -1.2235e-04 2.1864e-04 9.9627e-04 0.001966 beta_ch_a 8.9624e-04 2.9781e-04 1.6650e-04 -5.2964e-04 -3.3997e-04 4.5886e-04 0.001966 0.019707 beta_ch_b 0.002514 0.001278 6.3649e-04 1.0425e-04 -3.2296e-04 0.001084 0.005933 0.031310 delta_tt_a -4.0040e-04 0.003889 0.001208 0.010941 0.002894 -1.8535e-04 -6.6869e-04 0.004838 delta_tc_a -9.5697e-04 0.001550 4.0703e-04 0.009877 0.002502 -2.7229e-04 -0.001233 -0.002976 delta_hw_a -0.005901 0.002629 1.9429e-04 0.013689 0.003822 -0.005166 -0.019916 -0.039787 delta_ch_a -0.001878 -2.0528e-04 -2.0807e-04 0.002714 9.7168e-04 -7.7081e-04 -0.003455 -0.031036 beta_ch_b delta_tt_a delta_tc_a delta_hw_a delta_ch_a asc_1 0.002514 -4.0040e-04 -9.5697e-04 -0.005901 -0.001878 beta_tt_a 0.001278 0.003889 0.001550 0.002629 -2.0528e-04 beta_tt_b 6.3649e-04 0.001208 4.0703e-04 1.9429e-04 -2.0807e-04 beta_tc_a 1.0425e-04 0.010941 0.009877 0.013689 0.002714 beta_tc_b -3.2296e-04 0.002894 0.002502 0.003822 9.7168e-04 beta_hw_a 0.001084 -1.8535e-04 -2.7229e-04 -0.005166 -7.7081e-04 beta_hw_b 0.005933 -6.6869e-04 -0.001233 -0.019916 -0.003455 beta_ch_a 0.031310 0.004838 -0.002976 -0.039787 -0.031036 beta_ch_b 0.109454 -0.001978 -0.016202 -0.097072 -0.067786 delta_tt_a -0.001978 0.089550 0.035791 0.012085 -0.009499 delta_tc_a -0.016202 0.035791 0.058673 0.021783 0.007217 delta_hw_a -0.097072 0.012085 0.021783 0.473424 0.070046 delta_ch_a -0.067786 -0.009499 0.007217 0.070046 0.079354 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.005179 -4.5606e-04 -1.606e-05 -0.002534 -6.6861e-04 5.2442e-04 0.002178 0.004663 beta_tt_a -4.5606e-04 9.9358e-04 2.2859e-04 0.003768 8.2697e-04 -2.0750e-04 -8.2216e-04 -0.001154 beta_tt_b -1.606e-05 2.2859e-04 1.1821e-04 7.5409e-04 2.2401e-04 -1.361e-06 3.664e-05 2.8937e-04 beta_tc_a -0.002534 0.003768 7.5409e-04 0.020645 0.003679 -0.001022 -0.004506 -0.010897 beta_tc_b -6.6861e-04 8.2697e-04 2.2401e-04 0.003679 0.001064 -3.0075e-04 -0.001212 -0.002893 beta_hw_a 5.2442e-04 -2.0750e-04 -1.361e-06 -0.001022 -3.0075e-04 3.6500e-04 0.001439 0.002982 beta_hw_b 0.002178 -8.2216e-04 3.664e-05 -0.004506 -0.001212 0.001439 0.006111 0.012503 beta_ch_a 0.004663 -0.001154 2.8937e-04 -0.010897 -0.002893 0.002982 0.012503 0.046430 beta_ch_b 0.013263 -0.002113 0.001002 -0.026627 -0.006413 0.006974 0.031528 0.097174 delta_tt_a -3.5613e-04 0.006659 0.001705 0.024422 0.004797 -0.001308 -0.004648 0.001869 delta_tc_a -0.003281 0.003589 -1.0462e-04 0.024995 0.003998 -0.002018 -0.009033 -0.023750 delta_hw_a -0.048413 0.019674 2.1582e-04 0.099522 0.027887 -0.031370 -0.128534 -0.265316 delta_ch_a -0.010289 0.002473 -4.0081e-04 0.023602 0.005988 -0.004955 -0.021718 -0.080980 beta_ch_b delta_tt_a delta_tc_a delta_hw_a delta_ch_a asc_1 0.013263 -3.5613e-04 -0.003281 -0.04841 -0.010289 beta_tt_a -0.002113 0.006659 0.003589 0.01967 0.002473 beta_tt_b 0.001002 0.001705 -1.0462e-04 2.1582e-04 -4.0081e-04 beta_tc_a -0.026627 0.024422 0.024995 0.09952 0.023602 beta_tc_b -0.006413 0.004797 0.003998 0.02789 0.005988 beta_hw_a 0.006974 -0.001308 -0.002018 -0.03137 -0.004955 beta_hw_b 0.031528 -0.004648 -0.009033 -0.12853 -0.021718 beta_ch_a 0.097174 0.001869 -0.023750 -0.26532 -0.080980 beta_ch_b 0.281992 -0.014702 -0.075244 -0.63208 -0.192434 delta_tt_a -0.014702 0.121637 0.056204 0.10232 -0.012709 delta_tc_a -0.075244 0.056204 0.090321 0.18213 0.044934 delta_hw_a -0.632076 0.102320 0.182130 2.79404 0.459471 delta_ch_a -0.192434 -0.012709 0.044934 0.45947 0.176636 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.06322 0.009803 -0.055929 -0.08317 0.13195 0.14787 0.10534 beta_tt_a -0.063222 1.00000 0.669113 0.712695 0.67200 -0.11693 -0.06658 0.09121 beta_tt_b 0.009803 0.66911 1.000000 0.652306 0.68775 -0.01429 0.06778 0.13228 beta_tc_a -0.055929 0.71269 0.652306 1.000000 0.67034 -0.16374 -0.15019 -0.04147 beta_tc_b -0.083172 0.67200 0.687749 0.670344 1.00000 -0.17525 -0.14518 -0.09071 beta_hw_a 0.131951 -0.11693 -0.014294 -0.163742 -0.17525 1.00000 0.84879 0.40052 beta_hw_b 0.147867 -0.06658 0.067778 -0.150189 -0.14518 0.84879 1.00000 0.44375 beta_ch_a 0.105342 0.09121 0.132276 -0.041470 -0.09071 0.40052 0.44375 1.00000 beta_ch_b 0.125385 0.16603 0.214568 0.003464 -0.03656 0.40145 0.56817 0.67413 delta_tt_a -0.022078 0.55876 0.450154 0.401881 0.36227 -0.07590 -0.07080 0.11517 delta_tc_a -0.065189 0.27504 0.187411 0.448217 0.38686 -0.13774 -0.16124 -0.08752 delta_hw_a -0.141502 0.16427 0.031493 0.218689 0.20807 -0.92001 -0.91703 -0.41190 delta_ch_a -0.110000 -0.03133 -0.082379 0.105885 0.12920 -0.33530 -0.38855 -0.78482 beta_ch_b delta_tt_a delta_tc_a delta_hw_a delta_ch_a asc_1 0.125385 -0.02208 -0.06519 -0.14150 -0.11000 beta_tt_a 0.166029 0.55876 0.27504 0.16427 -0.03133 beta_tt_b 0.214568 0.45015 0.18741 0.03149 -0.08238 beta_tc_a 0.003464 0.40188 0.44822 0.21869 0.10589 beta_tc_b -0.036564 0.36227 0.38686 0.20807 0.12920 beta_hw_a 0.401447 -0.07590 -0.13774 -0.92001 -0.33530 beta_hw_b 0.568167 -0.07080 -0.16124 -0.91703 -0.38855 beta_ch_a 0.674135 0.11517 -0.08752 -0.41190 -0.78482 beta_ch_b 1.000000 -0.01998 -0.20218 -0.42644 -0.72734 delta_tt_a -0.019983 1.00000 0.49377 0.05869 -0.11268 delta_tc_a -0.202184 0.49377 1.00000 0.13070 0.10577 delta_hw_a -0.426436 0.05869 0.13070 1.00000 0.36139 delta_ch_a -0.727342 -0.11268 0.10577 0.36139 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.2011 -0.020529 -0.2451 -0.2849 0.381438 0.38711 0.30072 beta_tt_a -0.20105 1.0000 0.666990 0.8318 0.8044 -0.344572 -0.33367 -0.16986 beta_tt_b -0.02053 0.6670 1.000000 0.4827 0.6317 -0.006552 0.04311 0.12352 beta_tc_a -0.24510 0.8318 0.482704 1.0000 0.7851 -0.372349 -0.40115 -0.35196 beta_tc_b -0.28487 0.8044 0.631707 0.7851 1.0000 -0.482664 -0.47539 -0.41172 beta_hw_a 0.38144 -0.3446 -0.006552 -0.3723 -0.4827 1.000000 0.96384 0.72444 beta_hw_b 0.38711 -0.3337 0.043110 -0.4011 -0.4754 0.963838 1.00000 0.74230 beta_ch_a 0.30072 -0.1699 0.123518 -0.3520 -0.4117 0.724445 0.74230 1.00000 beta_ch_b 0.34705 -0.1262 0.173478 -0.3490 -0.3703 0.687447 0.75951 0.84924 delta_tt_a -0.01419 0.6057 0.449665 0.4873 0.4217 -0.196265 -0.17049 0.02487 delta_tc_a -0.15171 0.3788 -0.032018 0.5788 0.4079 -0.351543 -0.38448 -0.36675 delta_hw_a -0.40247 0.3734 0.011875 0.4144 0.5115 -0.982311 -0.98369 -0.73663 delta_ch_a -0.34019 0.1866 -0.087714 0.3908 0.4368 -0.617141 -0.66105 -0.89421 beta_ch_b delta_tt_a delta_tc_a delta_hw_a delta_ch_a asc_1 0.34705 -0.01419 -0.15171 -0.40247 -0.34019 beta_tt_a -0.12622 0.60570 0.37883 0.37339 0.18664 beta_tt_b 0.17348 0.44967 -0.03202 0.01188 -0.08771 beta_tc_a -0.34898 0.48734 0.57882 0.41437 0.39084 beta_tc_b -0.37025 0.42172 0.40788 0.51153 0.43685 beta_hw_a 0.68745 -0.19626 -0.35154 -0.98231 -0.61714 beta_hw_b 0.75951 -0.17049 -0.38448 -0.98369 -0.66105 beta_ch_a 0.84924 0.02487 -0.36675 -0.73663 -0.89421 beta_ch_b 1.00000 -0.07938 -0.47148 -0.71209 -0.86223 delta_tt_a -0.07938 1.00000 0.53621 0.17551 -0.08670 delta_tc_a -0.47148 0.53621 1.00000 0.36255 0.35575 delta_hw_a -0.71209 0.17551 0.36255 1.00000 0.65404 delta_ch_a -0.86223 -0.08670 0.35575 0.65404 1.00000 20 worst outliers in terms of lowest average per choice prediction: ID Avg prob per choice 22580 0.2661741 15174 0.2838071 23205 0.2874235 16178 0.2954426 21922 0.3133910 21623 0.3300289 16617 0.3320456 16489 0.3384681 76862 0.3389086 22961 0.3766864 12534 0.3813517 20100 0.3858061 15312 0.3867277 15056 0.3908178 22820 0.3989095 14754 0.4128145 24627 0.4129373 15489 0.4134629 17645 0.4268355 82613 0.4296158 Changes in parameter estimates from starting values: Initial Estimate Difference asc_1 0.00000 -0.03435 -0.034346 asc_2 0.00000 0.00000 0.000000 beta_tt_a 0.00000 -0.24802 -0.248016 beta_tt_b 0.00000 -0.09498 -0.094979 beta_tc_a 0.00000 -0.94369 -0.943694 beta_tc_b 0.00000 -0.20792 -0.207915 beta_hw_a -0.03960 -0.03003 0.009575 beta_hw_b -0.04790 -0.11953 -0.071633 beta_ch_a -0.76240 -0.71744 0.044958 beta_ch_b -2.17250 -3.13207 -0.959573 delta_tt_a 0.00000 -0.61292 -0.612917 delta_tc_a 0.00000 -0.51031 -0.510312 delta_hw_a 0.00000 0.47159 0.471587 delta_ch_a 0.00000 -0.29024 -0.290241 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" panelData "TRUE" analyticGrad "TRUE" analyticGrad_manualSet "FALSE" overridePanel "FALSE" preventOverridePanel "FALSE" noModification "FALSE" Hessian routines attempted -------------------------- numerical jacobian of LL analytical gradient Scaling in estimation --------------------- Value asc_1 0.03434633 beta_tt_a 0.24800503 beta_tt_b 0.09498110 beta_tc_a 0.94377095 beta_tc_b 0.20791491 beta_hw_a 0.03002504 beta_hw_b 0.11953045 beta_ch_a 0.71743459 beta_ch_b 3.13254960 delta_tt_a 0.61291630 delta_tc_a 0.51031142 delta_hw_a 0.47158602 delta_ch_a 0.29024217 Scaling used in computing Hessian --------------------------------- Value asc_1 0.03434633 beta_tt_a 0.24801609 beta_tt_b 0.09497942 beta_tc_a 0.94369407 beta_tc_b 0.20791542 beta_hw_a 0.03002528 beta_hw_b 0.11953314 beta_ch_a 0.71744200 beta_ch_b 3.13207288 delta_tt_a 0.61291665 delta_tc_a 0.51031162 delta_hw_a 0.47158746 delta_ch_a 0.29024092 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) }