Model run by stephane.hess using Apollo 0.2.9 on R 4.0.5 for Darwin. www.ApolloChoiceModelling.com Model name : EM_LC_with_covariates Model description : LC model with class allocation model on Swiss route choice data, EM algorithm Model run at : 2023-05-11 23:21:11 Estimation method : EM algorithm (bfgs) -> Maximum likelihood (bfgs) Model diagnosis : successful convergence Optimisation diagnosis : Maximum found hessian properties : Negative definitive maximum eigenvalue : -8.782238 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) : -1755.5 LL (whole model) at equal shares, LL(0) : -2420.47 LL (whole model) at observed shares, LL(C) : -2420.39 LL(final, whole model) : -1558.43 Rho-squared vs equal shares : 0.3561 Adj.Rho-squared vs equal shares : 0.3508 Rho-squared vs observed shares : 0.3561 Adj.Rho-squared vs observed shares : 0.3549 AIC : 3142.85 BIC : 3222.91 LL(0,Class_1) : -2420.47 LL(final,Class_1) : -1777.5 LL(0,Class_2) : -2420.47 LL(final,Class_2) : -2467.61 Estimated parameters : 13 Time taken (hh:mm:ss) : 00:00:36.03 pre-estimation : 00:00:3.19 estimation : 00:00:29.67 initial estimation : 00:00:0.82 estimation after rescaling : 00:00:0.49 post-estimation : 00:00:3.18 Iterations : 36 (EM) & 8 (bfgs) initial estimation : 4 estimation after rescaling : 4 Unconstrained optimisation. Estimates: Estimate s.e. t.rat.(0) Rob.s.e. Rob.t.rat.(0) asc_1_a -0.08345 0.066040 -1.2637 0.078942 -1.0571 asc_1_b 0.06788 0.105602 0.6428 0.126435 0.5369 asc_2_a 0.00000 NA NA NA NA asc_2_b 0.00000 NA NA NA NA beta_tt_a -0.03678 0.005214 -7.0543 0.008760 -4.1990 beta_tt_b -0.21237 0.024084 -8.8179 0.041517 -5.1153 beta_tc_a -0.04914 0.012939 -3.7976 0.012944 -3.7962 beta_tc_b -0.78318 0.082135 -9.5353 0.110025 -7.1182 beta_hw_a -0.03414 0.003097 -11.0247 0.004855 -7.0321 beta_hw_b -0.05480 0.005357 -10.2294 0.008112 -6.7555 beta_ch_a -0.61027 0.075019 -8.1349 0.107081 -5.6991 beta_ch_b -2.64772 0.212684 -12.4490 0.267017 -9.9159 delta_a -0.22010 0.217931 -1.0100 0.247161 -0.8905 gamma_commute_a -0.47158 0.328634 -1.4350 0.371412 -1.2697 gamma_car_av_a 0.61224 0.282647 2.1661 0.307680 1.9899 delta_b 0.00000 NA NA NA NA gamma_commute_b 0.00000 NA NA NA NA gamma_car_av_b 0.00000 NA NA NA NA Summary of class allocation for model component : Mean prob. Class_1 0.4702 Class_2 0.5298 Overview of choices for MNL model component Class_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 Class_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 Classical covariance matrix: asc_1_a asc_1_b beta_tt_a beta_tt_b asc_1_a 0.004361 -0.001959 2.175e-06 -1.913e-05 asc_1_b -0.001959 0.011152 3.785e-05 -4.6079e-04 beta_tt_a 2.175e-06 3.785e-05 2.719e-05 -2.310e-05 beta_tt_b -1.913e-05 -4.6079e-04 -2.310e-05 5.8006e-04 beta_tc_a -1.857e-05 4.476e-05 4.977e-05 -1.569e-06 beta_tc_b 7.350e-06 -0.001356 -1.151e-05 0.001770 beta_hw_a 3.693e-07 1.493e-06 4.691e-06 -4.654e-07 beta_hw_b -5.275e-06 -2.625e-05 -4.552e-06 5.104e-05 beta_ch_a -2.211e-05 -6.8892e-04 9.284e-05 5.4574e-04 beta_ch_b -0.001578 2.6926e-04 -2.661e-05 0.003566 delta_a 9.2172e-04 7.6867e-04 -9.675e-05 -0.001888 gamma_commute_a 0.001503 -0.002761 -1.2178e-04 -2.7866e-04 gamma_car_av_a -0.001226 0.001681 -6.436e-05 6.6310e-04 beta_tc_a beta_tc_b beta_hw_a beta_hw_b asc_1_a -1.857e-05 7.350e-06 3.693e-07 -5.275e-06 asc_1_b 4.476e-05 -0.001356 1.493e-06 -2.625e-05 beta_tt_a 4.977e-05 -1.151e-05 4.691e-06 -4.552e-06 beta_tt_b -1.569e-06 0.001770 -4.654e-07 5.104e-05 beta_tc_a 1.6743e-04 4.671e-05 5.206e-06 -1.427e-06 beta_tc_b 4.671e-05 0.006746 2.617e-05 1.3981e-04 beta_hw_a 5.206e-06 2.617e-05 9.590e-06 -5.787e-06 beta_hw_b -1.427e-06 1.3981e-04 -5.787e-06 2.870e-05 beta_ch_a 1.2917e-04 0.002380 9.600e-05 -3.559e-05 beta_ch_b 2.6458e-04 0.010745 -1.064e-05 4.8311e-04 delta_a -3.5074e-04 -0.006957 -7.190e-05 -1.6433e-04 gamma_commute_a -1.6049e-04 -7.9143e-04 -1.4968e-04 1.8145e-04 gamma_car_av_a 1.968e-05 0.001564 -6.835e-05 2.3317e-04 beta_ch_a beta_ch_b delta_a gamma_commute_a asc_1_a -2.211e-05 -0.001578 9.2172e-04 0.001503 asc_1_b -6.8892e-04 2.6926e-04 7.6867e-04 -0.002761 beta_tt_a 9.284e-05 -2.661e-05 -9.675e-05 -1.2178e-04 beta_tt_b 5.4574e-04 0.003566 -0.001888 -2.7866e-04 beta_tc_a 1.2917e-04 2.6458e-04 -3.5074e-04 -1.6049e-04 beta_tc_b 0.002380 0.010745 -0.006957 -7.9143e-04 beta_hw_a 9.600e-05 -1.064e-05 -7.190e-05 -1.4968e-04 beta_hw_b -3.559e-05 4.8311e-04 -1.6433e-04 1.8145e-04 beta_ch_a 0.005628 0.003580 -0.006456 -0.002415 beta_ch_b 0.003580 0.045235 -0.016839 -0.012386 delta_a -0.006456 -0.016839 0.047494 -0.017806 gamma_commute_a -0.002415 -0.012386 -0.017806 0.108000 gamma_car_av_a -5.7211e-04 0.008649 -0.031395 -0.006182 gamma_car_av_a asc_1_a -0.001226 asc_1_b 0.001681 beta_tt_a -6.436e-05 beta_tt_b 6.6310e-04 beta_tc_a 1.968e-05 beta_tc_b 0.001564 beta_hw_a -6.835e-05 beta_hw_b 2.3317e-04 beta_ch_a -5.7211e-04 beta_ch_b 0.008649 delta_a -0.031395 gamma_commute_a -0.006182 gamma_car_av_a 0.079889 Robust covariance matrix: asc_1_a asc_1_b beta_tt_a beta_tt_b asc_1_a 0.006232 -0.003766 -7.495e-05 1.2108e-04 asc_1_b -0.003766 0.015986 2.8658e-04 -0.001971 beta_tt_a -7.495e-05 2.8658e-04 7.673e-05 -1.9917e-04 beta_tt_b 1.2108e-04 -0.001971 -1.9917e-04 0.001724 beta_tc_a -6.057e-05 2.3959e-04 7.009e-05 -1.1678e-04 beta_tc_b 4.1758e-04 -0.005292 -2.9921e-04 0.004004 beta_hw_a -3.627e-05 3.769e-05 1.936e-05 -2.885e-05 beta_hw_b 7.642e-06 -9.023e-05 -3.129e-05 1.2693e-04 beta_ch_a -5.2082e-04 -0.001969 1.4822e-04 0.001307 beta_ch_b -0.004049 0.002330 -7.9152e-04 0.007328 delta_a 0.003195 0.002239 3.4784e-04 -0.004847 gamma_commute_a 0.006234 -0.012512 -9.0893e-04 0.002460 gamma_car_av_a -0.006153 0.007043 -5.5615e-04 0.002330 beta_tc_a beta_tc_b beta_hw_a beta_hw_b asc_1_a -6.057e-05 4.1758e-04 -3.627e-05 7.642e-06 asc_1_b 2.3959e-04 -0.005292 3.769e-05 -9.023e-05 beta_tt_a 7.009e-05 -2.9921e-04 1.936e-05 -3.129e-05 beta_tt_b -1.1678e-04 0.004004 -2.885e-05 1.2693e-04 beta_tc_a 1.6755e-04 -1.8650e-04 1.469e-05 -1.898e-05 beta_tc_b -1.8650e-04 0.012106 4.342e-05 1.3704e-04 beta_hw_a 1.469e-05 4.342e-05 2.357e-05 -2.345e-05 beta_hw_b -1.898e-05 1.3704e-04 -2.345e-05 6.580e-05 beta_ch_a 1.0020e-04 0.005659 2.6338e-04 -2.2535e-04 beta_ch_b -1.9469e-04 0.013800 -2.0986e-04 9.8240e-04 delta_a 1.2804e-04 -0.013698 -2.042e-05 -3.7990e-04 gamma_commute_a -9.4721e-04 0.005409 -6.7799e-04 9.6919e-04 gamma_car_av_a -3.6920e-04 0.002727 -4.0676e-04 9.1921e-04 beta_ch_a beta_ch_b delta_a gamma_commute_a asc_1_a -5.2082e-04 -0.004049 0.003195 0.006234 asc_1_b -0.001969 0.002330 0.002239 -0.012512 beta_tt_a 1.4822e-04 -7.9152e-04 3.4784e-04 -9.0893e-04 beta_tt_b 0.001307 0.007328 -0.004847 0.002460 beta_tc_a 1.0020e-04 -1.9469e-04 1.2804e-04 -9.4721e-04 beta_tc_b 0.005659 0.013800 -0.013698 0.005409 beta_hw_a 2.6338e-04 -2.0986e-04 -2.042e-05 -6.7799e-04 beta_hw_b -2.2535e-04 9.8240e-04 -3.7990e-04 9.6919e-04 beta_ch_a 0.011466 0.004288 -0.013184 -0.003501 beta_ch_b 0.004288 0.071298 -0.028510 -0.013172 delta_a -0.013184 -0.028510 0.061089 -0.021977 gamma_commute_a -0.003501 -0.013172 -0.021977 0.137947 gamma_car_av_a -0.001832 0.028794 -0.039032 -0.003493 gamma_car_av_a asc_1_a -0.006153 asc_1_b 0.007043 beta_tt_a -5.5615e-04 beta_tt_b 0.002330 beta_tc_a -3.6920e-04 beta_tc_b 0.002727 beta_hw_a -4.0676e-04 beta_hw_b 9.1921e-04 beta_ch_a -0.001832 beta_ch_b 0.028794 delta_a -0.039032 gamma_commute_a -0.003493 gamma_car_av_a 0.094667 Classical correlation matrix: asc_1_a asc_1_b beta_tt_a beta_tt_b asc_1_a 1.000000 -0.280940 0.006315 -0.012026 asc_1_b -0.280940 1.000000 0.068731 -0.181173 beta_tt_a 0.006315 0.068731 1.000000 -0.183948 beta_tt_b -0.012026 -0.181173 -0.183948 1.000000 beta_tc_a -0.021733 0.032757 0.737707 -0.005036 beta_tc_b 0.001355 -0.156355 -0.026869 0.894770 beta_hw_a 0.001806 0.004565 0.290488 -0.006239 beta_hw_b -0.014911 -0.046396 -0.162965 0.395555 beta_ch_a -0.004462 -0.086962 0.237357 0.302050 beta_ch_b -0.112340 0.011989 -0.023992 0.696080 delta_a 0.064043 0.033400 -0.085140 -0.359743 gamma_commute_a 0.069251 -0.079546 -0.071068 -0.035207 gamma_car_av_a -0.065664 0.056321 -0.043673 0.097410 beta_tc_a beta_tc_b beta_hw_a beta_hw_b asc_1_a -0.021733 0.001355 0.001806 -0.01491 asc_1_b 0.032757 -0.156355 0.004565 -0.04640 beta_tt_a 0.737707 -0.026869 0.290488 -0.16297 beta_tt_b -0.005036 0.894770 -0.006239 0.39556 beta_tc_a 1.000000 0.043950 0.129924 -0.02059 beta_tc_b 0.043950 1.000000 0.102870 0.31774 beta_hw_a 0.129924 0.102870 1.000000 -0.34881 beta_hw_b -0.020591 0.317737 -0.348805 1.00000 beta_ch_a 0.133066 0.386252 0.413242 -0.08857 beta_ch_b 0.096143 0.615117 -0.016156 0.42401 delta_a -0.124382 -0.388656 -0.106537 -0.14076 gamma_commute_a -0.037743 -0.029321 -0.147072 0.10307 gamma_car_av_a 0.005382 0.067362 -0.078085 0.15399 beta_ch_a beta_ch_b delta_a gamma_commute_a asc_1_a -0.004462 -0.11234 0.06404 0.06925 asc_1_b -0.086962 0.01199 0.03340 -0.07955 beta_tt_a 0.237357 -0.02399 -0.08514 -0.07107 beta_tt_b 0.302050 0.69608 -0.35974 -0.03521 beta_tc_a 0.133066 0.09614 -0.12438 -0.03774 beta_tc_b 0.386252 0.61512 -0.38866 -0.02932 beta_hw_a 0.413242 -0.01616 -0.10654 -0.14707 beta_hw_b -0.088568 0.42401 -0.14076 0.10307 beta_ch_a 1.000000 0.22437 -0.39488 -0.09795 beta_ch_b 0.224370 1.00000 -0.36330 -0.17720 delta_a -0.394877 -0.36330 1.00000 -0.24862 gamma_commute_a -0.097955 -0.17720 -0.24862 1.00000 gamma_car_av_a -0.026981 0.14388 -0.50968 -0.06655 gamma_car_av_a asc_1_a -0.065664 asc_1_b 0.056321 beta_tt_a -0.043673 beta_tt_b 0.097410 beta_tc_a 0.005382 beta_tc_b 0.067362 beta_hw_a -0.078085 beta_hw_b 0.153992 beta_ch_a -0.026981 beta_ch_b 0.143879 delta_a -0.509683 gamma_commute_a -0.066553 gamma_car_av_a 1.000000 Robust correlation matrix: asc_1_a asc_1_b beta_tt_a beta_tt_b asc_1_a 1.00000 -0.37736 -0.1084 0.03694 asc_1_b -0.37736 1.00000 0.2587 -0.37555 beta_tt_a -0.10839 0.25875 1.0000 -0.54765 beta_tt_b 0.03694 -0.37555 -0.5477 1.00000 beta_tc_a -0.05927 0.14640 0.6181 -0.21731 beta_tc_b 0.04808 -0.38038 -0.3104 0.87645 beta_hw_a -0.09464 0.06140 0.4551 -0.14310 beta_hw_b 0.01193 -0.08797 -0.4403 0.37690 beta_ch_a -0.06161 -0.14544 0.1580 0.29402 beta_ch_b -0.19209 0.06900 -0.3384 0.66106 delta_a 0.16377 0.07166 0.1607 -0.47239 gamma_commute_a 0.21263 -0.26643 -0.2794 0.15953 gamma_car_av_a -0.25332 0.18106 -0.2063 0.18238 beta_tc_a beta_tc_b beta_hw_a beta_hw_b asc_1_a -0.05927 0.04808 -0.09464 0.01193 asc_1_b 0.14640 -0.38038 0.06140 -0.08797 beta_tt_a 0.61814 -0.31044 0.45515 -0.44028 beta_tt_b -0.21731 0.87645 -0.14310 0.37690 beta_tc_a 1.00000 -0.13095 0.23371 -0.18079 beta_tc_b -0.13095 1.00000 0.08127 0.15355 beta_hw_a 0.23371 0.08127 1.00000 -0.59532 beta_hw_b -0.18079 0.15355 -0.59532 1.00000 beta_ch_a 0.07229 0.48032 0.50661 -0.25942 beta_ch_b -0.05633 0.46974 -0.16188 0.45355 delta_a 0.04002 -0.50372 -0.01702 -0.18948 gamma_commute_a -0.19702 0.13236 -0.37598 0.32168 gamma_car_av_a -0.09270 0.08057 -0.27229 0.36829 beta_ch_a beta_ch_b delta_a gamma_commute_a asc_1_a -0.06161 -0.19209 0.16377 0.21263 asc_1_b -0.14544 0.06900 0.07166 -0.26643 beta_tt_a 0.15802 -0.33840 0.16066 -0.27937 beta_tt_b 0.29402 0.66106 -0.47239 0.15953 beta_tc_a 0.07229 -0.05633 0.04002 -0.19702 beta_tc_b 0.48032 0.46974 -0.50372 0.13236 beta_hw_a 0.50661 -0.16188 -0.01702 -0.37598 beta_hw_b -0.25942 0.45355 -0.18948 0.32168 beta_ch_a 1.00000 0.14996 -0.49815 -0.08804 beta_ch_b 0.14996 1.00000 -0.43199 -0.13282 delta_a -0.49815 -0.43199 1.00000 -0.23940 gamma_commute_a -0.08804 -0.13282 -0.23940 1.00000 gamma_car_av_a -0.05561 0.35048 -0.51326 -0.03057 gamma_car_av_a asc_1_a -0.25332 asc_1_b 0.18106 beta_tt_a -0.20635 beta_tt_b 0.18238 beta_tc_a -0.09270 beta_tc_b 0.08057 beta_hw_a -0.27229 beta_hw_b 0.36829 beta_ch_a -0.05561 beta_ch_b 0.35048 delta_a -0.51326 gamma_commute_a -0.03057 gamma_car_av_a 1.00000 20 worst outliers in terms of lowest average per choice prediction: ID Avg prob per choice 15030 0.2347727 22580 0.3090737 14802 0.3265779 23205 0.3433656 20010 0.3448974 16489 0.3486538 22961 0.3596260 16617 0.3599557 18219 0.3704671 13863 0.3748212 15174 0.3791642 22278 0.3809632 76862 0.3845514 20100 0.3854213 16178 0.3976413 13214 0.4004894 17187 0.4007627 20323 0.4024990 82613 0.4025278 20063 0.4041930 Changes in parameter estimates from starting values: Initial Estimate Difference asc_1_a -0.08345 -0.08345 -1.066e-06 asc_1_b 0.06788 0.06788 6.599e-07 asc_2_a 0.00000 0.00000 0.000000 asc_2_b 0.00000 0.00000 0.000000 beta_tt_a -0.03678 -0.03678 3.644e-07 beta_tt_b -0.21233 -0.21237 -4.454e-05 beta_tc_a -0.04914 -0.04914 1.882e-06 beta_tc_b -0.78314 -0.78318 -3.626e-05 beta_hw_a -0.03414 -0.03414 3.123e-06 beta_hw_b -0.05479 -0.05480 -6.654e-06 beta_ch_a -0.61016 -0.61027 -1.1166e-04 beta_ch_b -2.64666 -2.64772 -0.001053 delta_a -0.22010 -0.22010 1.002e-06 gamma_commute_a -0.47158 -0.47158 -1.244e-06 gamma_car_av_a 0.61225 0.61224 -5.066e-06 delta_b 0.00000 0.00000 0.000000 gamma_commute_b 0.00000 0.00000 0.000000 gamma_car_av_b 0.00000 0.00000 0.000000 Settings and functions used in model definition: apollo_control -------------- Value modelName "EM_LC_with_covariates" modelDescr "LC model with class allocation model on Swiss route choice data, EM algorithm" indivID "ID" noValidation "TRUE" noDiagnostics "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 second derivative of LL (using numDeriv) Scaling in estimation --------------------- Value asc_1_a 0.08345146 asc_1_b 0.06787696 beta_tt_a 0.03678587 beta_tt_b 0.21233696 beta_tc_a 0.04913762 beta_tc_b 0.78313914 beta_hw_a 0.03414045 beta_hw_b 0.05479649 beta_ch_a 0.61016164 beta_ch_b 2.64666467 delta_a 0.22010244 gamma_commute_a 0.47157849 gamma_car_av_a 0.61224935 Scaling used in computing Hessian --------------------------------- Value asc_1_a 0.08345220 asc_1_b 0.06787739 beta_tt_a 0.03678235 beta_tt_b 0.21237460 beta_tc_a 0.04913805 beta_tc_b 0.78317654 beta_hw_a 0.03414147 beta_hw_b 0.05480036 beta_ch_a 0.61027230 beta_ch_b 2.64771766 delta_a 0.22010146 gamma_commute_a 0.47157970 gamma_car_av_a 0.61224432 apollo_lcPars --------------- function(apollo_beta, apollo_inputs){ lcpars = list() lcpars[["asc_1" ]] = list( asc_1_a, asc_1_b) lcpars[["asc_2" ]] = list( asc_2_a, asc_2_b) lcpars[["beta_tt"]] = list(beta_tt_a, beta_tt_b) lcpars[["beta_tc"]] = list(beta_tc_a, beta_tc_b) lcpars[["beta_hw"]] = list(beta_hw_a, beta_hw_b) lcpars[["beta_ch"]] = list(beta_ch_a, beta_ch_b) V=list() V[["class_a"]] = delta_a + gamma_commute_a*commute + gamma_car_av_a*car_availability V[["class_b"]] = delta_b + gamma_commute_b*commute + gamma_car_av_b*car_availability ### Settings for class allocation models classAlloc_settings = list( classes = c(class_a=1, class_b=2), 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:length(pi_values)){ ### Compute class-specific utilities V=list() V[["alt1"]] = asc_1[[s]] + beta_tc[[s]]*tc1 + beta_tt[[s]]*tt1 + beta_hw[[s]]*hw1 + beta_ch[[s]]*ch1 V[["alt2"]] = asc_2[[s]] + beta_tc[[s]]*tc2 + beta_tt[[s]]*tt2 + beta_hw[[s]]*hw2 + beta_ch[[s]]*ch2 mnl_settings$utilities = V mnl_settings$componentName = paste0("Class_",s) ### Compute within-class choice probabilities using MNL model P[[paste0("Class_",s)]] = apollo_mnl(mnl_settings, functionality) ### Take product across observation for same individual P[[paste0("Class_",s)]] = apollo_panelProd(P[[paste0("Class_",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) }