Model run by stephane.hess using Apollo 0.2.9 on R 4.0.5 for Darwin. www.ApolloChoiceModelling.com Model name : EM_MMNL Model description : Mixed logit model on Swiss route choice data, correlated Lognormals in utility space, EM algorithm Model run at : 2023-05-11 22:30:46 Estimation method : EM algorithm (bfgs) -> Maximum likelihood (bfgs) Model diagnosis : successful convergence Optimisation diagnosis : Maximum found hessian properties : Negative definitive maximum eigenvalue : -6.91868 Number of individuals : 388 Number of rows in database : 3492 Number of modelled outcomes : 3492 Number of cores used : 2 Number of inter-individual draws : 500 (halton) LL(start) : -2026.72 LL at equal shares, LL(0) : -2420.47 LL at observed shares, LL(C) : -2420.39 LL(final) : -1406.82 Rho-squared vs equal shares : 0.4188 Adj.Rho-squared vs equal shares : 0.413 Rho-squared vs observed shares : 0.4188 Adj.Rho-squared vs observed shares : 0.4134 AIC : 2841.65 BIC : 2927.86 Estimated parameters : 14 Time taken (hh:mm:ss) : 00:09:43.09 pre-estimation : 00:02:3.43 estimation : 00:04:36.24 initial estimation : 00:02:5.61 estimation after rescaling : 00:00:8.12 post-estimation : 00:03:3.41 Iterations : 92 (EM) & 44 (bfgs) initial estimation : 43 estimation after rescaling : 1 Unconstrained optimisation. Estimates: Estimate s.e. t.rat.(0) Rob.s.e. Rob.t.rat.(0) mu_log_b_tt -1.48208 0.13429 -11.0364 0.12384 -11.967 mu_log_b_tc -0.59278 0.14674 -4.0397 0.13263 -4.469 mu_log_b_hw -2.45064 0.14143 -17.3279 0.15631 -15.678 mu_log_b_ch 1.10963 0.13574 8.1746 0.14016 7.917 sigma_log_b_tt 1.38752 0.17359 7.9930 0.17737 7.823 sigma_log_b_tt_tc 1.64144 0.17416 9.4250 0.17485 9.388 sigma_log_b_tc 0.87695 0.03451 25.4122 0.02390 36.692 sigma_log_b_tt_hw 0.55635 0.16014 3.4741 0.16111 3.453 sigma_log_b_tc_hw 0.26791 0.11584 2.3128 0.12271 2.183 sigma_log_b_hw 0.92271 0.05776 15.9737 0.04896 18.845 sigma_log_b_tt_ch 1.15439 0.16747 6.8933 0.16987 6.796 sigma_log_b_tc_ch 0.03924 0.05053 0.7765 0.03851 1.019 sigma_log_b_hw_ch 0.49509 0.05902 8.3879 0.05131 9.650 sigma_log_b_ch 0.63761 0.05481 11.6323 0.04446 14.342 Overview of choices for MNL model component : 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: mu_log_b_tt mu_log_b_tc mu_log_b_hw mu_log_b_ch sigma_log_b_tt mu_log_b_tt 0.01803 0.018173 0.012460 0.014881 0.01058 mu_log_b_tc 0.01817 0.021533 0.013228 0.015674 0.01093 mu_log_b_hw 0.01246 0.013228 0.020002 0.015343 0.01623 mu_log_b_ch 0.01488 0.015674 0.015343 0.018426 0.01484 sigma_log_b_tt 0.01058 0.010929 0.016229 0.014841 0.03013 sigma_log_b_tt_tc 0.01056 0.009771 0.016015 0.014565 0.03000 sigma_log_b_tc -3.9080e-04 -7.4310e-04 -1.0752e-04 -2.7161e-04 -4.9501e-04 sigma_log_b_tt_hw 0.01173 0.011941 0.014304 0.013823 0.02591 sigma_log_b_tc_hw 5.7202e-04 4.6505e-04 -0.004655 -0.001128 -8.1396e-04 sigma_log_b_hw 9.8206e-04 0.001365 0.001051 0.001313 5.1316e-04 sigma_log_b_tt_ch 0.01139 0.011520 0.016052 0.013584 0.02811 sigma_log_b_tc_ch 1.355e-05 -1.3771e-04 -9.0024e-04 -1.6874e-04 2.3599e-04 sigma_log_b_hw_ch -6.7668e-04 -7.3761e-04 0.001431 -2.5964e-04 -9.3977e-04 sigma_log_b_ch 5.0334e-04 3.3651e-04 -8.1752e-04 -1.0336e-04 2.4593e-04 sigma_log_b_tt_tc sigma_log_b_tc sigma_log_b_tt_hw sigma_log_b_tc_hw sigma_log_b_hw mu_log_b_tt 0.010560 -3.9080e-04 0.011734 5.7202e-04 9.8206e-04 mu_log_b_tc 0.009771 -7.4310e-04 0.011941 4.6505e-04 0.001365 mu_log_b_hw 0.016015 -1.0752e-04 0.014304 -0.004655 0.001051 mu_log_b_ch 0.014565 -2.7161e-04 0.013823 -0.001128 0.001313 sigma_log_b_tt 0.029996 -4.9501e-04 0.025913 -8.1396e-04 5.1316e-04 sigma_log_b_tt_tc 0.030331 -5.4129e-04 0.025914 -0.001067 4.2271e-04 sigma_log_b_tc -5.4129e-04 0.001191 -6.5198e-04 0.001090 4.728e-07 sigma_log_b_tt_hw 0.025914 -6.5198e-04 0.025645 -0.002295 2.4234e-04 sigma_log_b_tc_hw -0.001067 0.001090 -0.002295 0.013418 -0.004311 sigma_log_b_hw 4.2271e-04 4.728e-07 2.4234e-04 -0.004311 0.003337 sigma_log_b_tt_ch 0.028095 -4.0868e-04 0.024993 -0.002627 0.001370 sigma_log_b_tc_ch 1.6006e-04 6.9903e-04 -2.5491e-04 0.003588 -0.001204 sigma_log_b_hw_ch -8.9695e-04 7.4196e-04 -8.1442e-04 -0.003536 0.001860 sigma_log_b_ch 2.0962e-04 5.9914e-04 -7.664e-05 0.002549 -6.0979e-04 sigma_log_b_tt_ch sigma_log_b_tc_ch sigma_log_b_hw_ch sigma_log_b_ch mu_log_b_tt 0.011388 1.355e-05 -6.7668e-04 5.0334e-04 mu_log_b_tc 0.011520 -1.3771e-04 -7.3761e-04 3.3651e-04 mu_log_b_hw 0.016052 -9.0024e-04 0.001431 -8.1752e-04 mu_log_b_ch 0.013584 -1.6874e-04 -2.5964e-04 -1.0336e-04 sigma_log_b_tt 0.028107 2.3599e-04 -9.3977e-04 2.4593e-04 sigma_log_b_tt_tc 0.028095 1.6006e-04 -8.9695e-04 2.0962e-04 sigma_log_b_tc -4.0868e-04 6.9903e-04 7.4196e-04 5.9914e-04 sigma_log_b_tt_hw 0.024993 -2.5491e-04 -8.1442e-04 -7.664e-05 sigma_log_b_tc_hw -0.002627 0.003588 -0.003536 0.002549 sigma_log_b_hw 0.001370 -0.001204 0.001860 -6.0979e-04 sigma_log_b_tt_ch 0.028045 -7.2436e-04 3.3487e-04 -7.7237e-04 sigma_log_b_tc_ch -7.2436e-04 0.002554 -0.001428 4.7774e-04 sigma_log_b_hw_ch 3.3487e-04 -0.001428 0.003484 -6.9875e-04 sigma_log_b_ch -7.7237e-04 4.7774e-04 -6.9875e-04 0.003005 Robust covariance matrix: mu_log_b_tt mu_log_b_tc mu_log_b_hw mu_log_b_ch sigma_log_b_tt mu_log_b_tt 0.015337 0.015509 0.011634 0.013743 0.009975 mu_log_b_tc 0.015509 0.017590 0.013684 0.015521 0.011682 mu_log_b_hw 0.011634 0.013684 0.024433 0.017973 0.019039 mu_log_b_ch 0.013743 0.015521 0.017973 0.019645 0.016977 sigma_log_b_tt 0.009975 0.011682 0.019039 0.016977 0.031460 sigma_log_b_tt_tc 0.009863 0.010945 0.018450 0.016402 0.030907 sigma_log_b_tc -4.219e-05 -4.1565e-04 -3.2593e-04 -5.1718e-04 -6.1984e-04 sigma_log_b_tt_hw 0.010194 0.011574 0.015955 0.015342 0.027802 sigma_log_b_tc_hw 0.001739 -3.4977e-04 -0.009661 -0.003969 -0.005046 sigma_log_b_hw 2.9334e-04 0.001287 0.003016 0.001946 0.001739 sigma_log_b_tt_ch 0.010014 0.011627 0.018960 0.015530 0.029580 sigma_log_b_tc_ch 6.0117e-04 -1.5172e-04 -0.002318 -8.9322e-04 -9.9282e-04 sigma_log_b_hw_ch -8.0809e-04 -2.1259e-04 0.003295 5.7050e-04 5.7819e-04 sigma_log_b_ch 5.6423e-04 -6.442e-05 -0.002302 -0.001038 -9.3448e-04 sigma_log_b_tt_tc sigma_log_b_tc sigma_log_b_tt_hw sigma_log_b_tc_hw sigma_log_b_hw mu_log_b_tt 0.009863 -4.219e-05 0.010194 0.001739 2.9334e-04 mu_log_b_tc 0.010945 -4.1565e-04 0.011574 -3.4977e-04 0.001287 mu_log_b_hw 0.018450 -3.2593e-04 0.015955 -0.009661 0.003016 mu_log_b_ch 0.016402 -5.1718e-04 0.015342 -0.003969 0.001946 sigma_log_b_tt 0.030907 -6.1984e-04 0.027802 -0.005046 0.001739 sigma_log_b_tt_tc 0.030571 -5.5908e-04 0.027382 -0.004642 0.001477 sigma_log_b_tc -5.5908e-04 5.7123e-04 -6.3700e-04 9.9757e-04 -2.1484e-04 sigma_log_b_tt_hw 0.027382 -6.3700e-04 0.025956 -0.004380 0.001432 sigma_log_b_tc_hw -0.004642 9.9757e-04 -0.004380 0.015057 -0.005042 sigma_log_b_hw 0.001477 -2.1484e-04 0.001432 -0.005042 0.002397 sigma_log_b_tt_ch 0.029089 -4.9862e-04 0.026532 -0.006467 0.002350 sigma_log_b_tc_ch -8.3571e-04 3.8989e-04 -8.8429e-04 0.003967 -0.001316 sigma_log_b_hw_ch 4.2812e-04 2.8653e-04 4.3937e-04 -0.004888 0.001829 sigma_log_b_ch -8.2584e-04 4.6331e-04 -0.001011 0.004109 -0.001227 sigma_log_b_tt_ch sigma_log_b_tc_ch sigma_log_b_hw_ch sigma_log_b_ch mu_log_b_tt 0.010014 6.0117e-04 -8.0809e-04 5.6423e-04 mu_log_b_tc 0.011627 -1.5172e-04 -2.1259e-04 -6.442e-05 mu_log_b_hw 0.018960 -0.002318 0.003295 -0.002302 mu_log_b_ch 0.015530 -8.9322e-04 5.7050e-04 -0.001038 sigma_log_b_tt 0.029580 -9.9282e-04 5.7819e-04 -9.3448e-04 sigma_log_b_tt_tc 0.029089 -8.3571e-04 4.2812e-04 -8.2584e-04 sigma_log_b_tc -4.9862e-04 3.8989e-04 2.8653e-04 4.6331e-04 sigma_log_b_tt_hw 0.026532 -8.8429e-04 4.3937e-04 -0.001011 sigma_log_b_tc_hw -0.006467 0.003967 -0.004888 0.004109 sigma_log_b_hw 0.002350 -0.001316 0.001829 -0.001227 sigma_log_b_tt_ch 0.028854 -0.001417 0.001562 -0.001504 sigma_log_b_tc_ch -0.001417 0.001483 -0.001396 9.0792e-04 sigma_log_b_hw_ch 0.001562 -0.001396 0.002632 -0.001127 sigma_log_b_ch -0.001504 9.0792e-04 -0.001127 0.001977 Classical correlation matrix: mu_log_b_tt mu_log_b_tc mu_log_b_hw mu_log_b_ch sigma_log_b_tt mu_log_b_tt 1.000000 0.92221 0.65606 0.81636 0.45393 mu_log_b_tc 0.922212 1.00000 0.63738 0.78692 0.42903 mu_log_b_hw 0.656060 0.63738 1.00000 0.79919 0.66105 mu_log_b_ch 0.816362 0.78692 0.79919 1.00000 0.62982 sigma_log_b_tt 0.453929 0.42903 0.66105 0.62982 1.00000 sigma_log_b_tt_tc 0.451528 0.38235 0.65019 0.61610 0.99219 sigma_log_b_tc -0.084329 -0.14675 -0.02203 -0.05798 -0.08263 sigma_log_b_tt_hw 0.545619 0.50816 0.63158 0.63587 0.93215 sigma_log_b_tc_hw 0.036772 0.02736 -0.28412 -0.07176 -0.04048 sigma_log_b_hw 0.126600 0.16101 0.12870 0.16744 0.05118 sigma_log_b_tt_ch 0.506365 0.46878 0.67777 0.59755 0.96686 sigma_log_b_tc_ch 0.001996 -0.01857 -0.12597 -0.02460 0.02690 sigma_log_b_hw_ch -0.085370 -0.08516 0.17143 -0.03241 -0.09172 sigma_log_b_ch 0.068380 0.04184 -0.10546 -0.01389 0.02585 sigma_log_b_tt_tc sigma_log_b_tc sigma_log_b_tt_hw sigma_log_b_tc_hw sigma_log_b_hw mu_log_b_tt 0.45153 -0.08433 0.545619 0.03677 0.12660 mu_log_b_tc 0.38235 -0.14675 0.508160 0.02736 0.16101 mu_log_b_hw 0.65019 -0.02203 0.631576 -0.28412 0.12870 mu_log_b_ch 0.61610 -0.05798 0.635873 -0.07176 0.16744 sigma_log_b_tt 0.99219 -0.08263 0.932148 -0.04048 0.05118 sigma_log_b_tt_tc 1.00000 -0.09006 0.929150 -0.05287 0.04202 sigma_log_b_tc -0.09006 1.00000 -0.117977 0.27258 2.3719e-04 sigma_log_b_tt_hw 0.92915 -0.11798 1.000000 -0.12372 0.02620 sigma_log_b_tc_hw -0.05287 0.27258 -0.123718 1.00000 -0.64431 sigma_log_b_hw 0.04202 2.3719e-04 0.026198 -0.64431 1.00000 sigma_log_b_tt_ch 0.96331 -0.07072 0.931939 -0.13542 0.14161 sigma_log_b_tc_ch 0.01819 0.40086 -0.031500 0.61292 -0.41257 sigma_log_b_hw_ch -0.08726 0.36426 -0.086162 -0.51724 0.54542 sigma_log_b_ch 0.02196 0.31674 -0.008731 0.40149 -0.19259 sigma_log_b_tt_ch sigma_log_b_tc_ch sigma_log_b_hw_ch sigma_log_b_ch mu_log_b_tt 0.50637 0.001996 -0.08537 0.068380 mu_log_b_tc 0.46878 -0.018572 -0.08516 0.041836 mu_log_b_hw 0.67777 -0.125967 0.17143 -0.105457 mu_log_b_ch 0.59755 -0.024600 -0.03241 -0.013891 sigma_log_b_tt 0.96686 0.026902 -0.09172 0.025846 sigma_log_b_tt_tc 0.96331 0.018188 -0.08726 0.021958 sigma_log_b_tc -0.07072 0.400859 0.36426 0.316743 sigma_log_b_tt_hw 0.93194 -0.031500 -0.08616 -0.008731 sigma_log_b_tc_hw -0.13542 0.612922 -0.51724 0.401493 sigma_log_b_hw 0.14161 -0.412572 0.54542 -0.192589 sigma_log_b_tt_ch 1.00000 -0.085596 0.03388 -0.084141 sigma_log_b_tc_ch -0.08560 1.000000 -0.47869 0.172479 sigma_log_b_hw_ch 0.03388 -0.478690 1.00000 -0.215974 sigma_log_b_ch -0.08414 0.172479 -0.21597 1.000000 Robust correlation matrix: mu_log_b_tt mu_log_b_tc mu_log_b_hw mu_log_b_ch sigma_log_b_tt mu_log_b_tt 1.00000 0.94420 0.60097 0.79172 0.45413 mu_log_b_tc 0.94420 1.00000 0.66006 0.83494 0.49657 mu_log_b_hw 0.60097 0.66006 1.00000 0.82037 0.68670 mu_log_b_ch 0.79172 0.83494 0.82037 1.00000 0.68291 sigma_log_b_tt 0.45413 0.49657 0.68670 0.68291 1.00000 sigma_log_b_tt_tc 0.45548 0.47196 0.67506 0.66931 0.99659 sigma_log_b_tc -0.01425 -0.13113 -0.08724 -0.15439 -0.14621 sigma_log_b_tt_hw 0.51090 0.54166 0.63356 0.67942 0.97293 sigma_log_b_tc_hw 0.11443 -0.02149 -0.50370 -0.23076 -0.23183 sigma_log_b_hw 0.04838 0.19821 0.39411 0.28352 0.20027 sigma_log_b_tt_ch 0.47604 0.51609 0.71409 0.65229 0.98178 sigma_log_b_tc_ch 0.12607 -0.02971 -0.38512 -0.16550 -0.14537 sigma_log_b_hw_ch -0.12718 -0.03124 0.41082 0.07934 0.06354 sigma_log_b_ch 0.10248 -0.01093 -0.33119 -0.16662 -0.11851 sigma_log_b_tt_tc sigma_log_b_tc sigma_log_b_tt_hw sigma_log_b_tc_hw sigma_log_b_hw mu_log_b_tt 0.45548 -0.01425 0.51090 0.11443 0.04838 mu_log_b_tc 0.47196 -0.13113 0.54166 -0.02149 0.19821 mu_log_b_hw 0.67506 -0.08724 0.63356 -0.50370 0.39411 mu_log_b_ch 0.66931 -0.15439 0.67942 -0.23076 0.28352 sigma_log_b_tt 0.99659 -0.14621 0.97293 -0.23183 0.20027 sigma_log_b_tt_tc 1.00000 -0.13379 0.97206 -0.21635 0.17247 sigma_log_b_tc -0.13379 1.00000 -0.16543 0.34014 -0.18359 sigma_log_b_tt_hw 0.97206 -0.16543 1.00000 -0.22155 0.18159 sigma_log_b_tc_hw -0.21635 0.34014 -0.22155 1.00000 -0.83914 sigma_log_b_hw 0.17247 -0.18359 0.18159 -0.83914 1.00000 sigma_log_b_tt_ch 0.97940 -0.12282 0.96947 -0.31028 0.28253 sigma_log_b_tc_ch -0.12413 0.42366 -0.14254 0.83954 -0.69802 sigma_log_b_hw_ch 0.04772 0.23367 0.05316 -0.77646 0.72826 sigma_log_b_ch -0.10624 0.43603 -0.14116 0.75318 -0.56388 sigma_log_b_tt_ch sigma_log_b_tc_ch sigma_log_b_hw_ch sigma_log_b_ch mu_log_b_tt 0.4760 0.12607 -0.12718 0.10248 mu_log_b_tc 0.5161 -0.02971 -0.03124 -0.01093 mu_log_b_hw 0.7141 -0.38512 0.41082 -0.33119 mu_log_b_ch 0.6523 -0.16550 0.07934 -0.16662 sigma_log_b_tt 0.9818 -0.14537 0.06354 -0.11851 sigma_log_b_tt_tc 0.9794 -0.12413 0.04772 -0.10624 sigma_log_b_tc -0.1228 0.42366 0.23367 0.43603 sigma_log_b_tt_hw 0.9695 -0.14254 0.05316 -0.14116 sigma_log_b_tc_hw -0.3103 0.83954 -0.77646 0.75318 sigma_log_b_hw 0.2825 -0.69802 0.72826 -0.56388 sigma_log_b_tt_ch 1.0000 -0.21664 0.17923 -0.19917 sigma_log_b_tc_ch -0.2166 1.00000 -0.70666 0.53036 sigma_log_b_hw_ch 0.1792 -0.70666 1.00000 -0.49388 sigma_log_b_ch -0.1992 0.53036 -0.49388 1.00000 20 worst outliers in terms of lowest average per choice prediction: ID Avg prob per choice 22580 0.3303293 23205 0.3342357 15174 0.3427434 16178 0.3510794 76862 0.3656540 16489 0.3672311 21623 0.3748924 16617 0.3796262 22961 0.3810581 15056 0.3868847 22820 0.3938684 20100 0.3943499 17187 0.4016506 15312 0.4058504 12534 0.4078769 21922 0.4098616 17645 0.4135960 24627 0.4175399 16184 0.4201263 13214 0.4208330 Changes in parameter estimates from starting values: Initial Estimate Difference mu_log_b_tt -1.61530 -1.48208 0.13322 mu_log_b_tc -0.70214 -0.59278 0.10936 mu_log_b_hw -2.62598 -2.45064 0.17534 mu_log_b_ch 0.91590 1.10963 0.19373 sigma_log_b_tt 1.05987 1.38752 0.32765 sigma_log_b_tt_tc 1.43539 1.64144 0.20605 sigma_log_b_tc 0.82377 0.87695 0.05318 sigma_log_b_tt_hw 0.37341 0.55635 0.18294 sigma_log_b_tc_hw 0.22103 0.26791 0.04688 sigma_log_b_hw 0.87099 0.92271 0.05172 sigma_log_b_tt_ch 0.89195 1.15439 0.26245 sigma_log_b_tc_ch 0.05961 0.03924 -0.02037 sigma_log_b_hw_ch 0.44925 0.49509 0.04584 sigma_log_b_ch 0.66430 0.63761 -0.02669 Settings and functions used in model definition: apollo_control -------------- Value modelName "EM_MMNL" modelDescr "Mixed logit model on Swiss route choice data, correlated Lognormals in utility space, EM algorithm" indivID "ID" nCores "2" outputDirectory "output/" mixing "TRUE" debug "FALSE" workInLogs "FALSE" seed "13" HB "FALSE" noValidation "TRUE" noDiagnostics "TRUE" 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 mu_log_b_tt 1.48207573 mu_log_b_tc 0.59278039 mu_log_b_hw 2.45064188 mu_log_b_ch 1.10963339 sigma_log_b_tt 1.38751782 sigma_log_b_tt_tc 1.64144114 sigma_log_b_tc 0.87695354 sigma_log_b_tt_hw 0.55635067 sigma_log_b_tc_hw 0.26791049 sigma_log_b_hw 0.92271317 sigma_log_b_tt_ch 1.15439299 sigma_log_b_tc_ch 0.03923771 sigma_log_b_hw_ch 0.49508960 sigma_log_b_ch 0.63761012 Scaling used in computing Hessian --------------------------------- Value mu_log_b_tt 1.48207541 mu_log_b_tc 0.59278040 mu_log_b_hw 2.45064337 mu_log_b_ch 1.10963355 sigma_log_b_tt 1.38751896 sigma_log_b_tt_tc 1.64144004 sigma_log_b_tc 0.87695375 sigma_log_b_tt_hw 0.55635059 sigma_log_b_tc_hw 0.26791047 sigma_log_b_hw 0.92271278 sigma_log_b_tt_ch 1.15439309 sigma_log_b_tc_ch 0.03923771 sigma_log_b_hw_ch 0.49508958 sigma_log_b_ch 0.63761014 apollo_randCoeff ------------------ function(apollo_beta, apollo_inputs){ randcoeff = list() randcoeff[["b_tt"]] = -exp( mu_log_b_tt + sigma_log_b_tt * draws_tt ) randcoeff[["b_tc"]] = -exp( mu_log_b_tc + sigma_log_b_tt_tc * draws_tt + sigma_log_b_tc * draws_tc ) randcoeff[["b_hw"]] = -exp( mu_log_b_hw + sigma_log_b_tt_hw * draws_tt + sigma_log_b_tc_hw * draws_tc + sigma_log_b_hw * draws_hw ) randcoeff[["b_ch"]] = -exp( mu_log_b_ch + sigma_log_b_tt_ch * draws_tt + sigma_log_b_tc_ch * draws_tc + sigma_log_b_hw_ch * draws_hw + sigma_log_b_ch * draws_ch ) return(randcoeff) } apollo_probabilities ---------------------- function(apollo_beta, apollo_inputs, functionality="estimate"){ ### Function initialisation: do not change the following three commands ### 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() ### List of utilities: these must use the same names as in mnl_settings, order is irrelevant V = list() V[["alt1"]] = b_tt * tt1 + b_tc * tc1 + b_hw * hw1 + b_ch * ch1 V[["alt2"]] = b_tt * tt2 + b_tc * tc2 + b_hw * hw2 + b_ch * ch2 ### Define settings for MNL model component mnl_settings = list( alternatives = c(alt1=1, alt2=2), avail = list(alt1=1, alt2=1), choiceVar = choice, utilities = V ) ### Compute probabilities using MNL model P[["model"]] = apollo_mnl(mnl_settings, functionality) ### Take product across observation for same individual P = apollo_panelProd(P, apollo_inputs, functionality) ### Average across inter-individual draws P = apollo_avgInterDraws(P, apollo_inputs, functionality) ### Prepare and return outputs of function P = apollo_prepareProb(P, apollo_inputs, functionality) return(P) }