Model run by stephane.hess using Apollo 0.2.9 on R 4.0.5 for Darwin. www.ApolloChoiceModelling.com Model name : LC_with_covariates Model description : LC model with covariates in class allocation model on Swiss route choice data Model run at : 2023-05-11 08:11:15 Estimation method : bfgs Model diagnosis : successful convergence Optimisation diagnosis : Maximum found hessian properties : Negative definitive maximum eigenvalue : -6.573576 Number of individuals : 388 Number of rows in database : 3492 Number of modelled outcomes : 3492 Number of cores used : 3 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) : -1562.19 Rho-squared vs equal shares : 0.3546 Adj.Rho-squared vs equal shares : 0.3496 Rho-squared vs observed shares : 0.3546 Adj.Rho-squared vs observed shares : 0.3504 AIC : 3148.39 BIC : 3222.29 LL(0,Class_1) : -2420.47 LL(final,Class_1) : -1792.6 LL(0,Class_2) : -2420.47 LL(final,Class_2) : -2270.9 Estimated parameters : 12 Time taken (hh:mm:ss) : 00:00:7.03 pre-estimation : 00:00:4.61 estimation : 00:00:1.23 initial estimation : 00:00:1.13 estimation after rescaling : 00:00:0.1 post-estimation : 00:00:1.2 Iterations : 29 initial estimation : 28 estimation after rescaling : 1 Unconstrained optimisation. Estimates: Estimate s.e. t.rat.(0) Rob.s.e. Rob.t.rat.(0) asc_1 -0.04454 0.047893 -0.9300 0.052029 -0.8561 asc_2 0.00000 NA NA NA NA beta_tt_a -0.07446 0.008182 -9.1008 0.014436 -5.1583 beta_tt_b -0.09893 0.013415 -7.3746 0.028855 -3.4285 beta_tc_a -0.09501 0.016342 -5.8138 0.023365 -4.0663 beta_tc_b -0.52474 0.071664 -7.3222 0.146916 -3.5717 beta_hw_a -0.04017 0.004466 -8.9933 0.009636 -4.1683 beta_hw_b -0.04624 0.005996 -7.7115 0.012697 -3.6417 beta_ch_a -0.74666 0.100667 -7.4172 0.222420 -3.3570 beta_ch_b -2.08707 0.170881 -12.2136 0.274811 -7.5946 delta_a -0.21393 0.262199 -0.8159 0.420359 -0.5089 gamma_commute_a -0.22347 0.384182 -0.5817 0.492738 -0.4535 gamma_car_av_a 0.56154 0.305947 1.8354 0.376251 1.4925 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.4839 Class_2 0.5161 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 beta_tt_a beta_tt_b beta_tc_a beta_tc_b beta_hw_a asc_1 0.002294 6.513e-06 -8.717e-06 4.758e-06 -5.006e-05 -6.759e-06 beta_tt_a 6.513e-06 6.695e-05 -4.404e-05 1.0519e-04 -2.1879e-04 9.369e-06 beta_tt_b -8.717e-06 -4.404e-05 1.7996e-04 -6.815e-05 7.7072e-04 5.285e-06 beta_tc_a 4.758e-06 1.0519e-04 -6.815e-05 2.6706e-04 -2.7186e-04 7.431e-06 beta_tc_b -5.006e-05 -2.1879e-04 7.7072e-04 -2.7186e-04 0.005136 4.088e-05 beta_hw_a -6.759e-06 9.369e-06 5.285e-06 7.431e-06 4.088e-05 1.995e-05 beta_hw_b 1.370e-05 -6.070e-06 -7.842e-07 4.019e-07 1.000e-05 -1.757e-05 beta_ch_a -1.2105e-04 1.4880e-04 -2.929e-05 2.0138e-04 0.002121 2.1936e-04 beta_ch_b 3.1101e-04 -4.0361e-04 5.7701e-04 -1.7163e-04 0.004106 -2.3723e-04 delta_a 1.248e-05 3.2685e-04 -1.6519e-04 -7.049e-05 -0.006885 5.938e-06 gamma_commute_a 1.6584e-04 -3.7149e-04 4.8818e-04 -5.4386e-04 0.001682 -4.0967e-04 gamma_car_av_a 2.6807e-04 -1.9143e-04 -1.1859e-04 4.189e-05 7.2088e-04 -2.7429e-04 beta_hw_b beta_ch_a beta_ch_b delta_a gamma_commute_a gamma_car_av_a asc_1 1.370e-05 -1.2105e-04 3.1101e-04 1.248e-05 1.6584e-04 2.6807e-04 beta_tt_a -6.070e-06 1.4880e-04 -4.0361e-04 3.2685e-04 -3.7149e-04 -1.9143e-04 beta_tt_b -7.842e-07 -2.929e-05 5.7701e-04 -1.6519e-04 4.8818e-04 -1.1859e-04 beta_tc_a 4.019e-07 2.0138e-04 -1.7163e-04 -7.049e-05 -5.4386e-04 4.189e-05 beta_tc_b 1.000e-05 0.002121 0.004106 -0.006885 0.001682 7.2088e-04 beta_hw_a -1.757e-05 2.1936e-04 -2.3723e-04 5.938e-06 -4.0967e-04 -2.7429e-04 beta_hw_b 3.595e-05 -2.0583e-04 4.8807e-04 -1.4943e-04 5.4654e-04 4.3219e-04 beta_ch_a -2.0583e-04 0.010134 -0.001105 -0.011079 -0.009001 -0.002222 beta_ch_b 4.8807e-04 -0.001105 0.029200 -0.016876 -0.004985 0.012826 delta_a -1.4943e-04 -0.011079 -0.016876 0.068749 -0.015799 -0.041041 gamma_commute_a 5.4654e-04 -0.009001 -0.004985 -0.015799 0.147595 -0.001230 gamma_car_av_a 4.3219e-04 -0.002222 0.012826 -0.041041 -0.001230 0.093604 Robust covariance matrix: asc_1 beta_tt_a beta_tt_b beta_tc_a beta_tc_b beta_hw_a asc_1 0.002707 -7.006e-05 -6.349e-05 -5.912e-05 -3.5571e-04 -9.805e-05 beta_tt_a -7.006e-05 2.0839e-04 -2.4737e-04 2.7827e-04 -0.001020 1.636e-05 beta_tt_b -6.349e-05 -2.4737e-04 8.3263e-04 -3.9185e-04 0.003104 7.032e-05 beta_tc_a -5.912e-05 2.7827e-04 -3.9185e-04 5.4592e-04 -0.001360 -2.104e-06 beta_tc_b -3.5571e-04 -0.001020 0.003104 -0.001360 0.021584 6.2983e-04 beta_hw_a -9.805e-05 1.636e-05 7.032e-05 -2.104e-06 6.2983e-04 9.285e-05 beta_hw_b 1.2570e-04 -1.155e-05 -9.811e-05 2.289e-05 -7.5801e-04 -1.0821e-04 beta_ch_a -0.001439 6.9803e-04 -3.4258e-04 0.001029 0.015886 0.001432 beta_ch_b 0.002723 -0.001471 8.4688e-04 -7.5546e-04 -5.6614e-04 -0.001413 delta_a -5.9297e-04 8.9472e-04 9.1570e-04 -5.8525e-04 -0.029617 -4.4095e-04 gamma_commute_a 0.002591 -0.002380 0.002863 -0.003169 0.005702 -0.002386 gamma_car_av_a 0.001709 -4.9889e-04 -0.002607 6.3878e-04 -0.006902 -0.001876 beta_hw_b beta_ch_a beta_ch_b delta_a gamma_commute_a gamma_car_av_a asc_1 1.2570e-04 -0.001439 0.002723 -5.9297e-04 0.002591 0.001709 beta_tt_a -1.155e-05 6.9803e-04 -0.001471 8.9472e-04 -0.002380 -4.9889e-04 beta_tt_b -9.811e-05 -3.4258e-04 8.4688e-04 9.1570e-04 0.002863 -0.002607 beta_tc_a 2.289e-05 0.001029 -7.5546e-04 -5.8525e-04 -0.003169 6.3878e-04 beta_tc_b -7.5801e-04 0.015886 -5.6614e-04 -0.029617 0.005702 -0.006902 beta_hw_a -1.0821e-04 0.001432 -0.001413 -4.4095e-04 -0.002386 -0.001876 beta_hw_b 1.6122e-04 -0.001670 0.002137 1.8982e-04 0.003070 0.002632 beta_ch_a -0.001670 0.049471 -0.021707 -0.058648 -0.044054 -0.013405 beta_ch_b 0.002137 -0.021707 0.075521 -0.024399 0.020007 0.051392 delta_a 1.8982e-04 -0.058648 -0.024399 0.176702 -0.004345 -0.070800 gamma_commute_a 0.003070 -0.044054 0.020007 -0.004345 0.242790 0.029009 gamma_car_av_a 0.002632 -0.013405 0.051392 -0.070800 0.029009 0.141565 Classical correlation matrix: asc_1 beta_tt_a beta_tt_b beta_tc_a beta_tc_b beta_hw_a asc_1 1.000000 0.01662 -0.013567 0.006079 -0.01458 -0.031597 beta_tt_a 0.016621 1.00000 -0.401241 0.786730 -0.37313 0.256384 beta_tt_b -0.013567 -0.40124 1.000000 -0.310855 0.80169 0.088212 beta_tc_a 0.006079 0.78673 -0.310855 1.000000 -0.23213 0.101809 beta_tc_b -0.014585 -0.37313 0.801689 -0.232135 1.00000 0.127714 beta_hw_a -0.031597 0.25638 0.088212 0.101809 0.12771 1.000000 beta_hw_b 0.047708 -0.12371 -0.009749 0.004102 0.02328 -0.655972 beta_ch_a -0.025108 0.18065 -0.021688 0.122411 0.29404 0.487911 beta_ch_b 0.038001 -0.28867 0.251712 -0.061460 0.33531 -0.310841 delta_a 9.9361e-04 0.15235 -0.046963 -0.016452 -0.36641 0.005071 gamma_commute_a 0.009013 -0.11818 0.094722 -0.086626 0.06108 -0.238762 gamma_car_av_a 0.018295 -0.07647 -0.028895 0.008378 0.03288 -0.200741 beta_hw_b beta_ch_a beta_ch_b delta_a gamma_commute_a gamma_car_av_a asc_1 0.047708 -0.02511 0.03800 9.9361e-04 0.009013 0.018295 beta_tt_a -0.123715 0.18065 -0.28867 0.152351 -0.118179 -0.076472 beta_tt_b -0.009749 -0.02169 0.25171 -0.046963 0.094722 -0.028895 beta_tc_a 0.004102 0.12241 -0.06146 -0.016452 -0.086626 0.008378 beta_tc_b 0.023281 0.29404 0.33531 -0.366413 0.061081 0.032879 beta_hw_a -0.655972 0.48791 -0.31084 0.005071 -0.238762 -0.200741 beta_hw_b 1.000000 -0.34099 0.47634 -0.095046 0.237255 0.235590 beta_ch_a -0.340994 1.00000 -0.06426 -0.419741 -0.232747 -0.072156 beta_ch_b 0.476335 -0.06426 1.00000 -0.376661 -0.075931 0.245330 delta_a -0.095046 -0.41974 -0.37666 1.000000 -0.156838 -0.511611 gamma_commute_a 0.237255 -0.23275 -0.07593 -0.156838 1.000000 -0.010464 gamma_car_av_a 0.235590 -0.07216 0.24533 -0.511611 -0.010464 1.000000 Robust correlation matrix: asc_1 beta_tt_a beta_tt_b beta_tc_a beta_tc_b beta_hw_a asc_1 1.00000 -0.09328 -0.04229 -0.048634 -0.04653 -0.195584 beta_tt_a -0.09328 1.00000 -0.59386 0.825027 -0.48106 0.117644 beta_tt_b -0.04229 -0.59386 1.00000 -0.581214 0.73214 0.252911 beta_tc_a -0.04863 0.82503 -0.58121 1.000000 -0.39628 -0.009347 beta_tc_b -0.04653 -0.48106 0.73214 -0.396285 1.00000 0.444902 beta_hw_a -0.19558 0.11764 0.25291 -0.009347 0.44490 1.000000 beta_hw_b 0.19027 -0.06299 -0.26779 0.077152 -0.40635 -0.884480 beta_ch_a -0.12434 0.21740 -0.05338 0.197919 0.48615 0.668381 beta_ch_b 0.19045 -0.37068 0.10680 -0.117656 -0.01402 -0.533762 delta_a -0.02711 0.14744 0.07549 -0.059588 -0.47957 -0.108862 gamma_commute_a 0.10108 -0.33454 0.20138 -0.275227 0.07877 -0.502557 gamma_car_av_a 0.08729 -0.09185 -0.24016 0.072662 -0.12486 -0.517336 beta_hw_b beta_ch_a beta_ch_b delta_a gamma_commute_a gamma_car_av_a asc_1 0.19027 -0.12434 0.19045 -0.02711 0.10108 0.08729 beta_tt_a -0.06299 0.21740 -0.37068 0.14744 -0.33454 -0.09185 beta_tt_b -0.26779 -0.05338 0.10680 0.07549 0.20138 -0.24016 beta_tc_a 0.07715 0.19792 -0.11766 -0.05959 -0.27523 0.07266 beta_tc_b -0.40635 0.48615 -0.01402 -0.47957 0.07877 -0.12486 beta_hw_a -0.88448 0.66838 -0.53376 -0.10886 -0.50256 -0.51734 beta_hw_b 1.00000 -0.59145 0.61246 0.03556 0.49072 0.55103 beta_ch_a -0.59145 1.00000 -0.35514 -0.62728 -0.40198 -0.16018 beta_ch_b 0.61246 -0.35514 1.00000 -0.21121 0.14775 0.49704 delta_a 0.03556 -0.62728 -0.21121 1.00000 -0.02098 -0.44764 gamma_commute_a 0.49072 -0.40198 0.14775 -0.02098 1.00000 0.15647 gamma_car_av_a 0.55103 -0.16018 0.49704 -0.44764 0.15647 1.00000 20 worst outliers in terms of lowest average per choice prediction: ID Avg prob per choice 22580 0.2704667 23205 0.2994212 14802 0.3098105 16617 0.3184721 16489 0.3225753 15174 0.3365376 22961 0.3416780 16178 0.3437421 22278 0.3495944 18219 0.3528209 20010 0.3564596 20063 0.3588542 21922 0.3665817 76862 0.3699712 20100 0.3722227 21623 0.3746533 14074 0.3785452 13214 0.3838039 13863 0.4027314 17187 0.4030029 Changes in parameter estimates from starting values: Initial Estimate Difference asc_1 0.00000 -0.04454 -0.044542 asc_2 0.00000 0.00000 0.000000 beta_tt_a 0.00000 -0.07446 -0.074464 beta_tt_b 0.00000 -0.09893 -0.098929 beta_tc_a 0.00000 -0.09501 -0.095009 beta_tc_b 0.00000 -0.52474 -0.524741 beta_hw_a -0.03960 -0.04017 -5.6548e-04 beta_hw_b -0.04790 -0.04624 0.001661 beta_ch_a -0.76240 -0.74666 0.015737 beta_ch_b -2.17250 -2.08707 0.085428 delta_a 0.03290 -0.21393 -0.246832 gamma_commute_a 0.00000 -0.22347 -0.223474 gamma_car_av_a 0.00000 0.56154 0.561545 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 "LC_with_covariates" modelDescr "LC model with covariates in class allocation model on Swiss route choice data" indivID "ID" nCores "3" outputDirectory "output/" debug "FALSE" workInLogs "FALSE" seed "13" mixing "FALSE" HB "FALSE" noValidation "FALSE" noDiagnostics "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.04454234 beta_tt_a 0.07446431 beta_tt_b 0.09893118 beta_tc_a 0.09500883 beta_tc_b 0.52472765 beta_hw_a 0.04016482 beta_hw_b 0.04623820 beta_ch_a 0.74666824 beta_ch_b 2.08713788 delta_a 0.21393201 gamma_commute_a 0.22347420 gamma_car_av_a 0.56154484 Scaling used in computing Hessian --------------------------------- Value asc_1 0.04454235 beta_tt_a 0.07446386 beta_tt_b 0.09892908 beta_tc_a 0.09500903 beta_tc_b 0.52474078 beta_hw_a 0.04016548 beta_hw_b 0.04623883 beta_ch_a 0.74666307 beta_ch_b 2.08707159 delta_a 0.21393191 gamma_commute_a 0.22347418 gamma_car_av_a 0.56154473 apollo_lcPars --------------- function(apollo_beta, apollo_inputs){ lcpars = list() 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) ### Utilities of class allocation model 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:2){ ### 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 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) }