Model run using Apollo for R, version 0.2.3 on Darwin by stephane.hess www.ApolloChoiceModelling.com Model name : Apollo_example_19 Model description : Simple DM model on Swiss route choice data Model run at : 2021-02-04 18:39:39 Estimation method : bfgs Model diagnosis : successful convergence 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.242 LL(0, whole model) : -2420.47 LL(final, whole model) : -1455.643 Rho-square (0) : 0.3986 Adj.Rho-square (0) : 0.3932 AIC : 2937.29 BIC : 3017.34 LL(0,Combination_1) : -2420.47 LL(final,Combination_1) : -2814.332 LL(0,Combination_2) : -2420.47 LL(final,Combination_2) : -2966.676 LL(0,Combination_3) : -2420.47 LL(final,Combination_3) : -3311.217 LL(0,Combination_4) : -2420.47 LL(final,Combination_4) : -2848.312 LL(0,Combination_5) : -2420.47 LL(final,Combination_5) : -3329.45 LL(0,Combination_6) : -2420.47 LL(final,Combination_6) : -3084.742 LL(0,Combination_7) : -2420.47 LL(final,Combination_7) : -3618.62 LL(0,Combination_8) : -2420.47 LL(final,Combination_8) : -2962.735 LL(0,Combination_9) : -2420.47 LL(final,Combination_9) : -3979.331 LL(0,Combination_10) : -2420.47 LL(final,Combination_10) : -4211.641 LL(0,Combination_11) : -2420.47 LL(final,Combination_11) : -4484.713 LL(0,Combination_12) : -2420.47 LL(final,Combination_12) : -4005.371 LL(0,Combination_13) : -2420.47 LL(final,Combination_13) : -1790.897 LL(0,Combination_14) : -2420.47 LL(final,Combination_14) : -2365.902 LL(0,Combination_15) : -2420.47 LL(final,Combination_15) : -2667.158 LL(0,Combination_16) : -2420.47 LL(final,Combination_16) : -2434.104 Estimated parameters : 13 Time taken (hh:mm:ss) : 00:01:11.54 pre-estimation : 00:00:0.46 estimation : 00:00:51.31 post-estimation : 00:00:19.77 Iterations : 55 Min abs eigenvalue of Hessian : 1.905455 Estimates: Estimate s.e. t.rat.(0) Rob.s.e. Rob.t.rat.(0) asc_1 -0.03428 0.060599 -0.5657 0.07199 -0.4762 asc_2 0.00000 NA NA NA NA beta_tt_a -0.24811 0.023288 -10.6540 0.03158 -7.8556 beta_tt_b -0.09500 0.008967 -10.5939 0.01087 -8.7355 beta_tc_a -0.94396 0.091101 -10.3617 0.14404 -6.5536 beta_tc_b -0.20797 0.026713 -7.7854 0.03269 -6.3614 beta_hw_a -0.03006 0.008163 -3.6828 0.01915 -1.5701 beta_hw_b -0.11962 0.031672 -3.7769 0.07858 -1.5224 beta_ch_a -0.71796 0.140425 -5.1127 0.21572 -3.3281 beta_ch_b -3.13149 0.330880 -9.4641 0.53056 -5.9023 delta_tt_a -0.61740 0.299680 -2.0602 0.34939 -1.7670 delta_tc_a -0.51316 0.242475 -2.1164 0.30098 -1.7050 delta_hw_a 0.47498 0.689625 0.6888 1.67845 0.2830 delta_ch_a -0.28924 0.281928 -1.0259 0.42054 -0.6878 Summary of class allocation for LC model component : Mean prob. Combination_1 0.03464 Combination_2 0.04625 Combination_3 0.02154 Combination_4 0.02877 Combination_5 0.05786 Combination_6 0.07727 Combination_7 0.03599 Combination_8 0.04806 Combination_9 0.06422 Combination_10 0.08576 Combination_11 0.03994 Combination_12 0.05333 Combination_13 0.10728 Combination_14 0.14327 Combination_15 0.06672 Combination_16 0.08910 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.962e-05 5.184e-06 -3.1031e-04 -1.3528e-04 6.550e-05 2.8480e-04 8.9808e-04 beta_tt_a -8.962e-05 5.4233e-04 1.3975e-04 0.001511 4.1812e-04 -2.242e-05 -5.032e-05 2.9706e-04 beta_tt_b 5.184e-06 1.3975e-04 8.041e-05 5.3304e-04 1.6479e-04 -1.102e-06 1.886e-05 1.6610e-04 beta_tc_a -3.1031e-04 0.001511 5.3304e-04 0.008299 0.001632 -1.2196e-04 -4.3590e-04 -5.3644e-04 beta_tc_b -1.3528e-04 4.1812e-04 1.6479e-04 0.001632 7.1357e-04 -3.837e-05 -1.2387e-04 -3.4201e-04 beta_hw_a 6.550e-05 -2.242e-05 -1.102e-06 -1.2196e-04 -3.837e-05 6.663e-05 2.1955e-04 4.5882e-04 beta_hw_b 2.8480e-04 -5.032e-05 1.886e-05 -4.3590e-04 -1.2387e-04 2.1955e-04 0.001003 0.001973 beta_ch_a 8.9808e-04 2.9706e-04 1.6610e-04 -5.3644e-04 -3.4201e-04 4.5882e-04 0.001973 0.019719 beta_ch_b 0.002514 0.001271 6.3327e-04 6.655e-05 -3.3131e-04 0.001080 0.005936 0.031323 delta_tt_a -3.9963e-04 0.003902 0.001211 0.010983 0.002901 -1.8489e-04 -6.6976e-04 0.004865 delta_tc_a -9.5959e-04 0.001558 4.0915e-04 0.009918 0.002510 -2.7189e-04 -0.001236 -0.002973 delta_hw_a -0.005935 0.002655 2.0022e-04 0.013757 0.003848 -0.005180 -0.020036 -0.039868 delta_ch_a -0.001880 -2.0410e-04 -2.0710e-04 0.002731 9.7628e-04 -7.6957e-04 -0.003463 -0.031079 beta_ch_b delta_tt_a delta_tc_a delta_hw_a delta_ch_a asc_1 0.002514 -3.9963e-04 -9.5959e-04 -0.005935 -0.001880 beta_tt_a 0.001271 0.003902 0.001558 0.002655 -2.0410e-04 beta_tt_b 6.3327e-04 0.001211 4.0915e-04 2.0022e-04 -2.0710e-04 beta_tc_a 6.655e-05 0.010983 0.009918 0.013757 0.002731 beta_tc_b -3.3131e-04 0.002901 0.002510 0.003848 9.7628e-04 beta_hw_a 0.001080 -1.8489e-04 -2.7189e-04 -0.005180 -7.6957e-04 beta_hw_b 0.005936 -6.6976e-04 -0.001236 -0.020036 -0.003463 beta_ch_a 0.031323 0.004865 -0.002973 -0.039868 -0.031079 beta_ch_b 0.109481 -0.002003 -0.016241 -0.096924 -0.067862 delta_tt_a -0.002003 0.089808 0.035914 0.012040 -0.009558 delta_tc_a -0.016241 0.035914 0.058794 0.021782 0.007216 delta_hw_a -0.096924 0.012040 0.021782 0.475582 0.070092 delta_ch_a -0.067862 -0.009558 0.007216 0.070092 0.079483 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.6018e-04 -1.678e-05 -0.002550 -6.7402e-04 5.2757e-04 0.002198 0.004688 beta_tt_a -4.6018e-04 9.9753e-04 2.2920e-04 0.003785 8.3107e-04 -2.0985e-04 -8.3489e-04 -0.001171 beta_tt_b -1.678e-05 2.2920e-04 1.1826e-04 7.5730e-04 2.2455e-04 -1.822e-06 3.462e-05 2.8595e-04 beta_tc_a -0.002550 0.003785 7.5730e-04 0.020746 0.003698 -0.001028 -0.004549 -0.010966 beta_tc_b -6.7402e-04 8.3107e-04 2.2455e-04 0.003698 0.001069 -3.0321e-04 -0.001227 -0.002916 beta_hw_a 5.2757e-04 -2.0985e-04 -1.822e-06 -0.001028 -3.0321e-04 3.6659e-04 0.001450 0.002993 beta_hw_b 0.002198 -8.3489e-04 3.462e-05 -0.004549 -0.001227 0.001450 0.006174 0.012587 beta_ch_a 0.004688 -0.001171 2.8595e-04 -0.010966 -0.002916 0.002993 0.012587 0.046536 beta_ch_b 0.013276 -0.002153 9.8848e-04 -0.026786 -0.006454 0.006969 0.031607 0.097189 delta_tt_a -3.5377e-04 0.006685 0.001713 0.024528 0.004814 -0.001308 -0.004661 0.001926 delta_tc_a -0.003296 0.003617 -9.880e-05 0.025147 0.004027 -0.002021 -0.009072 -0.023790 delta_hw_a -0.048788 0.019921 2.5822e-04 0.100283 0.028163 -0.031571 -0.129750 -0.266768 delta_ch_a -0.010319 0.002500 -3.9414e-04 0.023732 0.006025 -0.004962 -0.021823 -0.081122 beta_ch_b delta_tt_a delta_tc_a delta_hw_a delta_ch_a asc_1 0.013276 -3.5377e-04 -0.003296 -0.04879 -0.010319 beta_tt_a -0.002153 0.006685 0.003617 0.01992 0.002500 beta_tt_b 9.8848e-04 0.001713 -9.880e-05 2.5822e-04 -3.9414e-04 beta_tc_a -0.026786 0.024528 0.025147 0.10028 0.023732 beta_tc_b -0.006454 0.004814 0.004027 0.02816 0.006025 beta_hw_a 0.006969 -0.001308 -0.002021 -0.03157 -0.004962 beta_hw_b 0.031607 -0.004661 -0.009072 -0.12975 -0.021823 beta_ch_a 0.097189 0.001926 -0.023790 -0.26677 -0.081122 beta_ch_b 0.281491 -0.014654 -0.075290 -0.63288 -0.192375 delta_tt_a -0.014654 0.122077 0.056401 0.10247 -0.012843 delta_tc_a -0.075290 0.056401 0.090590 0.18271 0.045008 delta_hw_a -0.632883 0.102466 0.182711 2.81719 0.461067 delta_ch_a -0.192375 -0.012843 0.045008 0.46107 0.176851 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.06350 0.009539 -0.056209 -0.08357 0.13242 0.14839 0.10554 beta_tt_a -0.063504 1.00000 0.669208 0.712445 0.67212 -0.11795 -0.06823 0.09084 beta_tt_b 0.009539 0.66921 1.000000 0.652501 0.68795 -0.01505 0.06642 0.13191 beta_tc_a -0.056209 0.71245 0.652501 1.000000 0.67059 -0.16400 -0.15107 -0.04193 beta_tc_b -0.083573 0.67212 0.687951 0.670590 1.00000 -0.17598 -0.14641 -0.09118 beta_hw_a 0.132422 -0.11795 -0.015055 -0.163996 -0.17598 1.00000 0.84919 0.40026 beta_hw_b 0.148387 -0.06823 0.066422 -0.151074 -0.14641 0.84919 1.00000 0.44366 beta_ch_a 0.105537 0.09084 0.131907 -0.041933 -0.09118 0.40026 0.44366 1.00000 beta_ch_b 0.125372 0.16493 0.213434 0.002208 -0.03748 0.39991 0.56645 0.67414 delta_tt_a -0.022006 0.55910 0.450765 0.402300 0.36240 -0.07558 -0.07056 0.11562 delta_tc_a -0.065306 0.27586 0.188176 0.448980 0.38746 -0.13737 -0.16094 -0.08731 delta_hw_a -0.142009 0.16534 0.032377 0.218973 0.20890 -0.92016 -0.91734 -0.41169 delta_ch_a -0.110058 -0.03109 -0.081921 0.106341 0.12963 -0.33440 -0.38782 -0.78502 beta_ch_b delta_tt_a delta_tc_a delta_hw_a delta_ch_a asc_1 0.125372 -0.02201 -0.06531 -0.14201 -0.11006 beta_tt_a 0.164928 0.55910 0.27586 0.16534 -0.03109 beta_tt_b 0.213434 0.45077 0.18818 0.03238 -0.08192 beta_tc_a 0.002208 0.40230 0.44898 0.21897 0.10634 beta_tc_b -0.037485 0.36240 0.38746 0.20890 0.12963 beta_hw_a 0.399909 -0.07558 -0.13737 -0.92016 -0.33440 beta_hw_b 0.566454 -0.07056 -0.16094 -0.91734 -0.38782 beta_ch_a 0.674142 0.11562 -0.08731 -0.41169 -0.78502 beta_ch_b 1.000000 -0.02020 -0.20243 -0.42477 -0.72747 delta_tt_a -0.020199 1.00000 0.49424 0.05826 -0.11313 delta_tc_a -0.202428 0.49424 1.00000 0.13026 0.10556 delta_hw_a -0.424766 0.05826 0.13026 1.00000 0.36051 delta_ch_a -0.727473 -0.11313 0.10556 0.36051 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.2024 -0.021437 -0.2459 -0.2864 0.382752 0.38851 0.30187 beta_tt_a -0.20239 1.0000 0.667302 0.8319 0.8049 -0.347019 -0.33641 -0.17193 beta_tt_b -0.02144 0.6673 1.000000 0.4835 0.6316 -0.008749 0.04052 0.12189 beta_tc_a -0.24590 0.8319 0.483473 1.0000 0.7854 -0.372858 -0.40189 -0.35294 beta_tc_b -0.28639 0.8049 0.631602 0.7854 1.0000 -0.484405 -0.47749 -0.41345 beta_hw_a 0.38275 -0.3470 -0.008749 -0.3729 -0.4844 1.000000 0.96405 0.72453 beta_hw_b 0.38851 -0.3364 0.040516 -0.4019 -0.4775 0.964047 1.00000 0.74259 beta_ch_a 0.30187 -0.1719 0.121891 -0.3529 -0.4135 0.724533 0.74259 1.00000 beta_ch_b 0.34759 -0.1285 0.171322 -0.3505 -0.3721 0.686075 0.75815 0.84916 delta_tt_a -0.01406 0.6058 0.450841 0.4874 0.4215 -0.195480 -0.16976 0.02555 delta_tc_a -0.15212 0.3805 -0.030186 0.5801 0.4093 -0.350690 -0.38360 -0.36640 delta_hw_a -0.40377 0.3758 0.014147 0.4148 0.5132 -0.982402 -0.98381 -0.73677 delta_ch_a -0.34084 0.1882 -0.086182 0.3918 0.4383 -0.616321 -0.66042 -0.89421 beta_ch_b delta_tt_a delta_tc_a delta_hw_a delta_ch_a asc_1 0.34759 -0.01406 -0.15212 -0.40377 -0.34084 beta_tt_a -0.12847 0.60581 0.38045 0.37579 0.18824 beta_tt_b 0.17132 0.45084 -0.03019 0.01415 -0.08618 beta_tc_a -0.35051 0.48739 0.58005 0.41481 0.39180 beta_tc_b -0.37211 0.42146 0.40928 0.51325 0.43827 beta_hw_a 0.68607 -0.19548 -0.35069 -0.98240 -0.61632 beta_hw_b 0.75815 -0.16976 -0.38360 -0.98381 -0.66042 beta_ch_a 0.84916 0.02555 -0.36640 -0.73677 -0.89421 beta_ch_b 1.00000 -0.07905 -0.47148 -0.71069 -0.86221 delta_tt_a -0.07905 1.00000 0.53633 0.17472 -0.08741 delta_tc_a -0.47148 0.53633 1.00000 0.36167 0.35559 delta_hw_a -0.71069 0.17472 0.36167 1.00000 0.65321 delta_ch_a -0.86221 -0.08741 0.35559 0.65321 1.00000 20 worst outliers in terms of lowest average per choice prediction: ID Avg prob per choice 22580 0.2661867 15174 0.2838638 23205 0.2873712 16178 0.2955330 21922 0.3134330 21623 0.3301274 16617 0.3319657 16489 0.3383847 76862 0.3389514 22961 0.3766085 12534 0.3814814 20100 0.3857322 15312 0.3868415 15056 0.3908281 22820 0.3988720 14754 0.4129419 24627 0.4130453 15489 0.4136059 17645 0.4268887 82613 0.4295141 Changes in parameter estimates from starting values: Initial Estimate Difference asc_1 0.00000 -0.03428 -0.034283 asc_2 0.00000 0.00000 0.000000 beta_tt_a 0.00000 -0.24811 -0.248110 beta_tt_b 0.00000 -0.09500 -0.094997 beta_tc_a 0.00000 -0.94396 -0.943958 beta_tc_b 0.00000 -0.20797 -0.207968 beta_hw_a -0.03960 -0.03006 0.009537 beta_hw_b -0.04790 -0.11962 -0.071724 beta_ch_a -0.76240 -0.71796 0.044444 beta_ch_b -2.17250 -3.13149 -0.958991 delta_tt_a 0.00000 -0.61740 -0.617398 delta_tc_a 0.00000 -0.51316 -0.513164 delta_hw_a 0.00000 0.47498 0.474980 delta_ch_a 0.00000 -0.28924 -0.289242 Settings and functions used in model definition: apollo_control -------------- Value modelName "Apollo_example_19" modelDescr "Simple DM model on Swiss route choice data" indivID "ID" nCores "1" noDiagnostics "TRUE" noValidation "TRUE" debug "FALSE" workInLogs "FALSE" seed "13" mixing "FALSE" HB "FALSE" panelData "TRUE" analyticGrad "TRUE" Hessian routines attempted -------------- numerical second derivative of LL (using numDeriv) Scaling used in computing Hessian -------------- Value asc_1 0.03428344 beta_tt_a 0.24810994 beta_tt_b 0.09499684 beta_tc_a 0.94395760 beta_tc_b 0.20796790 beta_hw_a 0.03006254 beta_hw_b 0.11962407 beta_ch_a 0.71795600 beta_ch_b 3.13149120 delta_tt_a 0.61739771 delta_tc_a 0.51316361 delta_hw_a 0.47497999 delta_ch_a 0.28924177 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() lcpars[["pi_values"]] = list() ### Generic settings for class allocation models mnl_settings = list( alternatives = c(class_a=1, class_b=2), avail = 1, choiceVar = NA, V = list() ) ### Create class allocation probabilities at level of individual attributes mnl_settings$V[["class_a"]] = delta_tt_a mnl_settings$V[["class_b"]] = 0 ttProbs=apollo_mnl(mnl_settings, functionality="raw") mnl_settings$V[["class_a"]] = delta_tc_a tcProbs=apollo_mnl(mnl_settings, functionality="raw") mnl_settings$V[["class_a"]] = delta_hw_a hwProbs=apollo_mnl(mnl_settings, functionality="raw") mnl_settings$V[["class_a"]] = delta_ch_a chProbs=apollo_mnl(mnl_settings, functionality="raw") ### Loop over combinations, determining parameter values and class allocation probabilities (multiplicatively) s=1 while(s<=16){ if(s<=8){ lcpars[["beta_tt"]][[s]]=beta_tt_a lcpars[["pi_values"]][[s]]=ttProbs[[1]] } else { lcpars[["beta_tt"]][[s]]=beta_tt_b lcpars[["pi_values"]][[s]]=ttProbs[[2]] } if((s-(s>8)*8)<=4){ lcpars[["beta_tc"]][[s]]=beta_tc_a lcpars[["pi_values"]][[s]]=lcpars[["pi_values"]][[s]]*tcProbs[[1]] } else { lcpars[["beta_tc"]][[s]]=beta_tc_b lcpars[["pi_values"]][[s]]=lcpars[["pi_values"]][[s]]*tcProbs[[2]] } if((ceiling(s/2)%%2)!=0){ lcpars[["beta_hw"]][[s]]=beta_hw_a lcpars[["pi_values"]][[s]]=lcpars[["pi_values"]][[s]]*hwProbs[[1]] } else { lcpars[["beta_hw"]][[s]]=beta_hw_b lcpars[["pi_values"]][[s]]=lcpars[["pi_values"]][[s]]*hwProbs[[2]] } if(s%%2!=0){ lcpars[["beta_ch"]][[s]]=beta_ch_a lcpars[["pi_values"]][[s]]=lcpars[["pi_values"]][[s]]*chProbs[[1]] } else { lcpars[["beta_ch"]][[s]]=beta_ch_b lcpars[["pi_values"]][[s]]=lcpars[["pi_values"]][[s]]*chProbs[[2]] } s=s+1 } lcpars[["pi_values"]] = apollo_firstRow(lcpars[["pi_values"]], apollo_inputs) 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 s=1 while(s<=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$V = V mnl_settings$componentName = paste0("Combination_",s) ### 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) s=s+1} ### 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)