Model run by stephane.hess using Apollo 0.3.5 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 : 2025-03-10 17:40:59.288303 Estimation method : bgw Model diagnosis : Relative function convergence Optimisation diagnosis : Maximum found hessian properties : Negative definite maximum eigenvalue : -3.686105 reciprocal of condition number : 6.09791e-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) : -1821.73 LL (whole model) at equal shares, LL(0) : -2420.47 LL (whole model) at observed shares, LL(C) : -2420.39 LL(final, whole model) : -1447.3 Rho-squared vs equal shares : 0.4021 Adj.Rho-squared vs equal shares : 0.3967 Rho-squared vs observed shares : 0.402 Adj.Rho-squared vs observed shares : 0.4033 AIC : 2920.6 BIC : 3000.66 LL(0,Combination_1) : -2420.47 LL(final,Combination_1) : -4858.32 LL(0,Combination_2) : -2420.47 LL(final,Combination_2) : -5447.15 LL(0,Combination_3) : -2420.47 LL(final,Combination_3) : -5255.17 LL(0,Combination_4) : -2420.47 LL(final,Combination_4) : -5373.88 LL(0,Combination_5) : -2420.47 LL(final,Combination_5) : -2828.34 LL(0,Combination_6) : -2420.47 LL(final,Combination_6) : -3407.12 LL(0,Combination_7) : -2420.47 LL(final,Combination_7) : -3059.9 LL(0,Combination_8) : -2420.47 LL(final,Combination_8) : -3398.05 LL(0,Combination_9) : -2420.47 LL(final,Combination_9) : -7365.27 LL(0,Combination_10) : -2420.47 LL(final,Combination_10) : -8039.34 LL(0,Combination_11) : -2420.47 LL(final,Combination_11) : -7923.26 LL(0,Combination_12) : -2420.47 LL(final,Combination_12) : -8266.62 LL(0,Combination_13) : -2420.47 LL(final,Combination_13) : -2256.6 LL(0,Combination_14) : -2420.47 LL(final,Combination_14) : -2318.1 LL(0,Combination_15) : -2420.47 LL(final,Combination_15) : -2337.18 LL(0,Combination_16) : -2420.47 LL(final,Combination_16) : -1832.57 Estimated parameters : 13 Time taken (hh:mm:ss) : 00:00:6.95 pre-estimation : 00:00:1.5 estimation : 00:00:1.54 post-estimation : 00:00:3.9 Iterations : 25 Unconstrained optimisation. Estimates: Estimate s.e. t.rat.(0) Rob.s.e. Rob.t.rat.(0) asc_1 -0.01354 0.061239 -0.2211 0.07075 -0.1913 asc_2 0.00000 NA NA NA NA beta_tt_a -0.24473 0.020331 -12.0373 0.02744 -8.9177 beta_tt_b -0.08091 0.007788 -10.3898 0.01031 -7.8458 beta_tc_a -1.66174 0.153072 -10.8559 0.18656 -8.9073 beta_tc_b -0.21500 0.021838 -9.8451 0.02601 -8.2667 beta_hw_a -0.09253 0.012767 -7.2481 0.01765 -5.2438 beta_hw_b -0.02047 0.008514 -2.4045 0.01176 -1.7407 beta_ch_a -2.89884 0.224207 -12.9293 0.26499 -10.9393 beta_ch_b -0.59860 0.130905 -4.5728 0.14277 -4.1927 delta_tt_a -0.47942 0.225334 -2.1276 0.26785 -1.7899 delta_tc_a -1.21836 0.199476 -6.1078 0.21684 -5.6187 delta_hw_a 0.42271 0.505967 0.8355 0.70672 0.5981 delta_ch_a 0.56284 0.232211 2.4238 0.26259 2.1434 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.03359 Combination_2 0.01913 Combination_3 0.02201 Combination_4 0.01254 Combination_5 0.11359 Combination_6 0.06470 Combination_7 0.07443 Combination_8 0.04240 Combination_9 0.05425 Combination_10 0.03090 Combination_11 0.03555 Combination_12 0.02025 Combination_13 0.18346 Combination_14 0.10450 Combination_15 0.12022 Combination_16 0.06848 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 beta_ch_b delta_tt_a delta_tc_a asc_1 0.003750 -8.103e-05 -1.293e-06 -3.5423e-04 -1.721e-05 4.432e-05 2.901e-05 7.4697e-04 6.0451e-04 -4.7557e-04 -2.4265e-04 beta_tt_a -8.103e-05 4.1337e-04 9.388e-05 0.002480 2.6741e-04 7.248e-05 7.160e-06 0.001881 3.9740e-04 0.001966 6.5899e-04 beta_tt_b -1.293e-06 9.388e-05 6.065e-05 5.8882e-04 1.2420e-04 3.031e-05 8.300e-06 5.4833e-04 9.566e-05 5.1532e-04 7.937e-05 beta_tc_a -3.5423e-04 0.002480 5.8882e-04 0.023431 0.001833 5.7192e-04 1.061e-05 0.014266 0.003377 0.011490 0.008967 beta_tc_b -1.721e-05 2.6741e-04 1.2420e-04 0.001833 4.7690e-04 8.033e-05 2.046e-05 0.001584 2.3892e-04 9.1033e-04 7.3760e-04 beta_hw_a 4.432e-05 7.248e-05 3.031e-05 5.7192e-04 8.033e-05 1.6298e-04 7.609e-05 0.001529 4.1600e-04 1.0555e-04 1.3932e-04 beta_hw_b 2.901e-05 7.160e-06 8.300e-06 1.061e-05 2.046e-05 7.609e-05 7.249e-05 5.6360e-04 2.5029e-04 -1.008e-05 1.439e-05 beta_ch_a 7.4697e-04 0.001881 5.4833e-04 0.014266 0.001584 0.001529 5.6360e-04 0.050269 0.015882 0.001972 8.0444e-04 beta_ch_b 6.0451e-04 3.9740e-04 9.566e-05 0.003377 2.3892e-04 4.1600e-04 2.5029e-04 0.015882 0.017136 0.002756 0.001754 delta_tt_a -4.7557e-04 0.001966 5.1532e-04 0.011490 9.1033e-04 1.0555e-04 -1.008e-05 0.001972 0.002756 0.050776 0.015913 delta_tc_a -2.4265e-04 6.5899e-04 7.937e-05 0.008967 7.3760e-04 1.3932e-04 1.439e-05 8.0444e-04 0.001754 0.015913 0.039791 delta_hw_a 0.002204 3.0326e-04 5.4014e-04 0.002222 0.001285 0.005304 0.003768 0.039871 0.015699 -1.2515e-04 0.003631 delta_ch_a 0.001084 4.6190e-04 1.2063e-04 0.003568 3.1566e-04 6.8497e-04 4.4961e-04 0.030977 0.021242 0.005199 0.002339 delta_hw_a delta_ch_a asc_1 0.002204 0.001084 beta_tt_a 3.0326e-04 4.6190e-04 beta_tt_b 5.4014e-04 1.2063e-04 beta_tc_a 0.002222 0.003568 beta_tc_b 0.001285 3.1566e-04 beta_hw_a 0.005304 6.8497e-04 beta_hw_b 0.003768 4.4961e-04 beta_ch_a 0.039871 0.030977 beta_ch_b 0.015699 0.021242 delta_tt_a -1.2515e-04 0.005199 delta_tc_a 0.003631 0.002339 delta_hw_a 0.256003 0.028972 delta_ch_a 0.028972 0.053922 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 beta_ch_b delta_tt_a delta_tc_a asc_1 0.005005 -2.0910e-04 2.601e-05 -8.4910e-04 -4.598e-05 2.6106e-04 1.9436e-04 0.003124 0.001383 -1.9644e-04 3.6112e-04 beta_tt_a -2.0910e-04 7.5316e-04 1.8584e-04 0.004722 4.8278e-04 1.2859e-04 8.334e-06 0.003401 7.3971e-04 0.003915 8.2304e-04 beta_tt_b 2.601e-05 1.8584e-04 1.0635e-04 0.001164 2.1797e-04 8.386e-05 3.305e-05 0.001027 1.5998e-04 9.5706e-04 4.505e-05 beta_tc_a -8.4910e-04 0.004722 0.001164 0.034804 0.003166 0.001016 2.654e-05 0.025258 0.006064 0.026931 0.009450 beta_tc_b -4.598e-05 4.8278e-04 2.1797e-04 0.003166 6.7640e-04 1.9695e-04 6.441e-05 0.002856 4.7807e-04 0.001800 4.6938e-04 beta_hw_a 2.6106e-04 1.2859e-04 8.386e-05 0.001016 1.9695e-04 3.1139e-04 1.6722e-04 0.002603 6.9371e-04 5.0773e-04 2.9485e-04 beta_hw_b 1.9436e-04 8.334e-06 3.305e-05 2.654e-05 6.441e-05 1.6722e-04 1.3831e-04 0.001194 5.5765e-04 -1.4356e-04 -5.093e-05 beta_ch_a 0.003124 0.003401 0.001027 0.025258 0.002856 0.002603 0.001194 0.070222 0.022251 0.011375 0.002510 beta_ch_b 0.001383 7.3971e-04 1.5998e-04 0.006064 4.7807e-04 6.9371e-04 5.5765e-04 0.022251 0.020384 0.006603 0.003791 delta_tt_a -1.9644e-04 0.003915 9.5706e-04 0.026931 0.001800 5.0773e-04 -1.4356e-04 0.011375 0.006603 0.071744 0.031763 delta_tc_a 3.6112e-04 8.2304e-04 4.505e-05 0.009450 4.6938e-04 2.9485e-04 -5.093e-05 0.002510 0.003791 0.031763 0.047020 delta_hw_a 0.014149 4.1192e-04 0.002107 0.005086 0.004193 0.011058 0.007709 0.081166 0.031546 -2.3932e-04 0.006009 delta_ch_a 0.004084 9.7782e-04 1.7029e-04 0.009114 2.9632e-04 0.001476 0.001011 0.045338 0.028247 0.014506 0.007723 delta_hw_a delta_ch_a asc_1 0.014149 0.004084 beta_tt_a 4.1192e-04 9.7782e-04 beta_tt_b 0.002107 1.7029e-04 beta_tc_a 0.005086 0.009114 beta_tc_b 0.004193 2.9632e-04 beta_hw_a 0.011058 0.001476 beta_hw_b 0.007709 0.001011 beta_ch_a 0.081166 0.045338 beta_ch_b 0.031546 0.028247 delta_tt_a -2.3932e-04 0.014506 delta_tc_a 0.006009 0.007723 delta_hw_a 0.499446 0.070146 delta_ch_a 0.070146 0.068954 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 beta_ch_b delta_tt_a delta_tc_a asc_1 1.000000 -0.06508 -0.002711 -0.037788 -0.01287 0.05669 0.055636 0.05440 0.07541 -0.034464 -0.019864 beta_tt_a -0.065083 1.00000 0.592906 0.796846 0.60228 0.27925 0.041362 0.41256 0.14932 0.429187 0.162488 beta_tt_b -0.002711 0.59291 1.000000 0.493942 0.73033 0.30491 0.125181 0.31404 0.09384 0.293660 0.051095 beta_tc_a -0.037788 0.79685 0.493942 1.000000 0.54838 0.29266 0.008142 0.41567 0.16854 0.333122 0.293657 beta_tc_b -0.012870 0.60228 0.730326 0.548381 1.00000 0.28813 0.110033 0.32345 0.08358 0.184995 0.169324 beta_hw_a 0.056687 0.27925 0.304905 0.292660 0.28813 1.00000 0.700066 0.53413 0.24893 0.036690 0.054708 beta_hw_b 0.055636 0.04136 0.125181 0.008142 0.11003 0.70007 1.000000 0.29525 0.22457 -0.005252 0.008473 beta_ch_a 0.054403 0.41256 0.314038 0.415667 0.32345 0.53413 0.295251 1.00000 0.54113 0.039027 0.017987 beta_ch_b 0.075409 0.14932 0.093838 0.168541 0.08358 0.24893 0.224571 0.54113 1.00000 0.093429 0.067156 delta_tt_a -0.034464 0.42919 0.293660 0.333122 0.18499 0.03669 -0.005252 0.03903 0.09343 1.000000 0.354024 delta_tc_a -0.019864 0.16249 0.051095 0.293657 0.16932 0.05471 0.008473 0.01799 0.06716 0.354024 1.000000 delta_hw_a 0.071117 0.02948 0.137080 0.028696 0.11626 0.82119 0.874766 0.35146 0.23703 -0.001098 0.035980 delta_ch_a 0.076248 0.09784 0.066706 0.100370 0.06225 0.23106 0.227416 0.59498 0.69879 0.099351 0.050499 delta_hw_a delta_ch_a asc_1 0.071117 0.07625 beta_tt_a 0.029479 0.09784 beta_tt_b 0.137080 0.06671 beta_tc_a 0.028696 0.10037 beta_tc_b 0.116255 0.06225 beta_hw_a 0.821191 0.23106 beta_hw_b 0.874766 0.22742 beta_ch_a 0.351463 0.59498 beta_ch_b 0.237032 0.69879 delta_tt_a -0.001098 0.09935 delta_tc_a 0.035980 0.05050 delta_hw_a 1.000000 0.24659 delta_ch_a 0.246590 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 beta_ch_b delta_tt_a delta_tc_a asc_1 1.00000 -0.10769 0.03565 -0.06433 -0.02499 0.20911 0.23359 0.16660 0.1369 -0.010366 0.02354 beta_tt_a -0.10769 1.00000 0.65664 0.92236 0.67641 0.26553 0.02582 0.46760 0.1888 0.532626 0.13830 beta_tt_b 0.03565 0.65664 1.00000 0.60494 0.81266 0.46082 0.27250 0.37597 0.1087 0.346472 0.02014 beta_tc_a -0.06433 0.92236 0.60494 1.00000 0.65257 0.30870 0.01209 0.51091 0.2277 0.538935 0.23361 beta_tc_b -0.02499 0.67641 0.81266 0.65257 1.00000 0.42915 0.21058 0.41444 0.1287 0.258430 0.08323 beta_hw_a 0.20911 0.26553 0.46082 0.30870 0.42915 1.00000 0.80578 0.55676 0.2754 0.107420 0.07706 beta_hw_b 0.23359 0.02582 0.27250 0.01209 0.21058 0.80578 1.00000 0.38327 0.3321 -0.045574 -0.01997 beta_ch_a 0.16660 0.46760 0.37597 0.51091 0.41444 0.55676 0.38327 1.00000 0.5881 0.160262 0.04368 beta_ch_b 0.13692 0.18879 0.10865 0.22766 0.12875 0.27535 0.33212 0.58812 1.0000 0.172672 0.12245 delta_tt_a -0.01037 0.53263 0.34647 0.53893 0.25843 0.10742 -0.04557 0.16026 0.1727 1.000000 0.54688 delta_tc_a 0.02354 0.13830 0.02014 0.23361 0.08323 0.07706 -0.01997 0.04368 0.1224 0.546878 1.00000 delta_hw_a 0.28299 0.02124 0.28905 0.03857 0.22812 0.88672 0.92758 0.43341 0.3127 -0.001264 0.03921 delta_ch_a 0.21983 0.13569 0.06288 0.18603 0.04339 0.31847 0.32740 0.65156 0.7534 0.206238 0.13564 delta_hw_a delta_ch_a asc_1 0.282987 0.21983 beta_tt_a 0.021238 0.13569 beta_tt_b 0.289055 0.06288 beta_tc_a 0.038575 0.18603 beta_tc_b 0.228123 0.04339 beta_hw_a 0.886719 0.31847 beta_hw_b 0.927575 0.32740 beta_ch_a 0.433406 0.65156 beta_ch_b 0.312650 0.75343 delta_tt_a -0.001264 0.20624 delta_tc_a 0.039210 0.13564 delta_hw_a 1.000000 0.37799 delta_ch_a 0.377988 1.00000 20 most extreme outliers in terms of lowest average per choice prediction: ID Avg prob per choice 15174 0.2926930 23205 0.2935753 22580 0.2962537 16178 0.3060831 17187 0.3361188 76862 0.3370854 21623 0.3387180 16489 0.3407676 16617 0.3660118 21922 0.3676685 15056 0.3739744 20100 0.3740195 12534 0.3804059 15312 0.3831464 22820 0.3865928 22961 0.3920510 17645 0.4008826 24627 0.4057198 82613 0.4070665 15489 0.4126431 Changes in parameter estimates from starting values: Initial Estimate Difference asc_1 0.00000 -0.01354 -0.013537 asc_2 0.00000 0.00000 0.000000 beta_tt_a -0.10000 -0.24473 -0.144735 beta_tt_b -0.05000 -0.08091 -0.030912 beta_tc_a -0.50000 -1.66174 -1.161739 beta_tc_b -0.25000 -0.21500 0.035003 beta_hw_a -0.10000 -0.09253 0.007467 beta_hw_b -0.05000 -0.02047 0.029528 beta_ch_a -1.00000 -2.89884 -1.898837 beta_ch_b -0.50000 -0.59860 -0.098597 delta_tt_a 0.00000 -0.47942 -0.479423 delta_tc_a 0.00000 -1.21836 -1.218362 delta_hw_a 0.00000 0.42271 0.422711 delta_ch_a 0.00000 0.56284 0.562840 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 modelDescr "Simple DM model on Swiss route choice data" indivID "ID" noDiagnostics "TRUE" noValidation "TRUE" outputDirectory "output/" debug "FALSE" modelName "DM" 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.01353719 beta_tt_a 0.24473490 beta_tt_b 0.08091240 beta_tc_a 1.66173864 beta_tc_b 0.21499749 beta_hw_a 0.09253258 beta_hw_b 0.02047180 beta_ch_a 2.89883722 beta_ch_b 0.59859696 delta_tt_a 0.47942285 delta_tc_a 1.21836174 delta_hw_a 0.42271068 delta_ch_a 0.56284005 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(s1 in 1:16){ lcpars[["beta_tt"]][[s1]] = get(paste0("beta_tt_", ifelse( s1<=8, "a", "b"))) lcpars[["beta_tc"]][[s1]] = get(paste0("beta_tc_", ifelse( (s1-(s1>8)*8)<=4, "a", "b"))) lcpars[["beta_hw"]][[s1]] = get(paste0("beta_hw_", ifelse((ceiling(s1/2)%%2)!=0, "a", "b"))) lcpars[["beta_ch"]][[s1]] = get(paste0("beta_ch_", ifelse( s1%%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(s2 in 1:16){ V[[s2]] = get(paste0("delta_tt_", ifelse( s2<=8, "a", "b"))) + get(paste0("delta_tc_", ifelse( (s2-(s2>8)*8)<=4, "a", "b"))) + get(paste0("delta_hw_", ifelse((ceiling(s2/2)%%2)!=0, "a", "b"))) + get(paste0("delta_ch_", ifelse( s2%%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) }