Model run using Apollo for R, version 0.2.3 on Darwin by stephane.hess www.ApolloChoiceModelling.com Model name : Apollo_example_20 Model description : LC model with class allocation model on Swiss route choice data Model run at : 2021-02-05 13:56: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 : 3 Model without mixing LL(start) : -1755.505 LL(0, whole model) : -2420.47 LL(final, whole model) : -1562.194 Rho-square (0) : 0.3546 Adj.Rho-square (0) : 0.3496 AIC : 3148.39 BIC : 3222.29 LL(0,Class_1) : -2420.47 LL(final,Class_1) : -1792.596 LL(0,Class_2) : -2420.47 LL(final,Class_2) : -2270.878 Estimated parameters : 12 Time taken (hh:mm:ss) : 00:00:26.35 pre-estimation : 00:00:5.83 estimation : 00:00:11.99 post-estimation : 00:00:8.53 Iterations : 28 Min abs eigenvalue of Hessian : 6.573721 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.1011 0.014435 -5.1584 beta_tt_b -0.09893 0.013415 -7.3747 0.028857 -3.4283 beta_tc_a -0.09501 0.016342 -5.8138 0.023365 -4.0662 beta_tc_b -0.52473 0.071649 -7.3236 0.146849 -3.5732 beta_hw_a -0.04016 0.004466 -8.9937 0.009634 -4.1689 beta_hw_b -0.04624 0.005996 -7.7117 0.012696 -3.6421 beta_ch_a -0.74667 0.100656 -7.4180 0.222350 -3.3581 beta_ch_b -2.08714 0.170884 -12.2137 0.274817 -7.5946 delta_a -0.21393 0.262168 -0.8160 0.420167 -0.5092 gamma_commute_a -0.22347 0.384183 -0.5817 0.492749 -0.4535 gamma_car_av_a 0.56154 0.305943 1.8355 0.376231 1.4926 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 LC 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.511e-06 -8.715e-06 4.756e-06 -5.003e-05 -6.759e-06 beta_tt_a 6.511e-06 6.694e-05 -4.404e-05 1.0519e-04 -2.1869e-04 9.369e-06 beta_tt_b -8.715e-06 -4.404e-05 1.7996e-04 -6.815e-05 7.7059e-04 5.282e-06 beta_tc_a 4.756e-06 1.0519e-04 -6.815e-05 2.6706e-04 -2.7177e-04 7.432e-06 beta_tc_b -5.003e-05 -2.1869e-04 7.7059e-04 -2.7177e-04 0.005134 4.086e-05 beta_hw_a -6.759e-06 9.369e-06 5.282e-06 7.432e-06 4.086e-05 1.994e-05 beta_hw_b 1.370e-05 -6.068e-06 -7.817e-07 4.016e-07 1.001e-05 -1.756e-05 beta_ch_a -1.2102e-04 1.4891e-04 -2.946e-05 2.0150e-04 0.002119 2.1933e-04 beta_ch_b 3.1104e-04 -4.0355e-04 5.7712e-04 -1.7159e-04 0.004105 -2.3716e-04 delta_a 1.238e-05 3.2649e-04 -1.6481e-04 -7.084e-05 -0.006879 5.932e-06 gamma_commute_a 1.6585e-04 -3.7144e-04 4.8808e-04 -5.4384e-04 0.001681 -4.0968e-04 gamma_car_av_a 2.6812e-04 -1.9132e-04 -1.1865e-04 4.198e-05 7.1962e-04 -2.7424e-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.2102e-04 3.1104e-04 1.238e-05 1.6585e-04 2.6812e-04 beta_tt_a -6.068e-06 1.4891e-04 -4.0355e-04 3.2649e-04 -3.7144e-04 -1.9132e-04 beta_tt_b -7.817e-07 -2.946e-05 5.7712e-04 -1.6481e-04 4.8808e-04 -1.1865e-04 beta_tc_a 4.016e-07 2.0150e-04 -1.7159e-04 -7.084e-05 -5.4384e-04 4.198e-05 beta_tc_b 1.001e-05 0.002119 0.004105 -0.006879 0.001681 7.1962e-04 beta_hw_a -1.756e-05 2.1933e-04 -2.3716e-04 5.932e-06 -4.0968e-04 -2.7424e-04 beta_hw_b 3.595e-05 -2.0581e-04 4.8796e-04 -1.4936e-04 5.4655e-04 4.3211e-04 beta_ch_a -2.0581e-04 0.010132 -0.001106 -0.011074 -0.009002 -0.002223 beta_ch_b 4.8796e-04 -0.001106 0.029201 -0.016874 -0.004988 0.012824 delta_a -1.4936e-04 -0.011074 -0.016874 0.068732 -0.015794 -0.041037 gamma_commute_a 5.4655e-04 -0.009002 -0.004988 -0.015794 0.147597 -0.001232 gamma_car_av_a 4.3211e-04 -0.002223 0.012824 -0.041037 -0.001232 0.093601 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.008e-05 -6.346e-05 -5.915e-05 -3.5540e-04 -9.804e-05 beta_tt_a -7.008e-05 2.0838e-04 -2.4741e-04 2.7828e-04 -0.001020 1.638e-05 beta_tt_b -6.346e-05 -2.4741e-04 8.3272e-04 -3.9191e-04 0.003103 7.026e-05 beta_tc_a -5.915e-05 2.7828e-04 -3.9191e-04 5.4594e-04 -0.001360 -2.077e-06 beta_tc_b -3.5540e-04 -0.001020 0.003103 -0.001360 0.021565 6.2928e-04 beta_hw_a -9.804e-05 1.638e-05 7.026e-05 -2.077e-06 6.2928e-04 9.282e-05 beta_hw_b 1.2567e-04 -1.156e-05 -9.805e-05 2.286e-05 -7.5745e-04 -1.0818e-04 beta_ch_a -0.001439 6.9922e-04 -3.4470e-04 0.001030 0.015859 0.001432 beta_ch_b 0.002723 -0.001471 8.4869e-04 -7.5607e-04 -5.6223e-04 -0.001413 delta_a -5.9353e-04 8.9212e-04 9.1898e-04 -5.8759e-04 -0.029561 -4.4005e-04 gamma_commute_a 0.002592 -0.002380 0.002863 -0.003169 0.005701 -0.002386 gamma_car_av_a 0.001709 -4.9834e-04 -0.002607 6.3909e-04 -0.006907 -0.001875 beta_hw_b beta_ch_a beta_ch_b delta_a gamma_commute_a gamma_car_av_a asc_1 1.2567e-04 -0.001439 0.002723 -5.9353e-04 0.002592 0.001709 beta_tt_a -1.156e-05 6.9922e-04 -0.001471 8.9212e-04 -0.002380 -4.9834e-04 beta_tt_b -9.805e-05 -3.4470e-04 8.4869e-04 9.1898e-04 0.002863 -0.002607 beta_tc_a 2.286e-05 0.001030 -7.5607e-04 -5.8759e-04 -0.003169 6.3909e-04 beta_tc_b -7.5745e-04 0.015859 -5.6223e-04 -0.029561 0.005701 -0.006907 beta_hw_a -1.0818e-04 0.001432 -0.001413 -4.4005e-04 -0.002386 -0.001875 beta_hw_b 1.6118e-04 -0.001670 0.002136 1.8908e-04 0.003070 0.002632 beta_ch_a -0.001670 0.049440 -0.021706 -0.058581 -0.044058 -0.013408 beta_ch_b 0.002136 -0.021706 0.075524 -0.024391 0.019994 0.051380 delta_a 1.8908e-04 -0.058581 -0.024391 0.176540 -0.004328 -0.070775 gamma_commute_a 0.003070 -0.044058 0.019994 -0.004328 0.242801 0.028999 gamma_car_av_a 0.002632 -0.013408 0.051380 -0.070775 0.028999 0.141550 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.01661 -0.013565 0.006076 -0.01458 -0.031599 beta_tt_a 0.016615 1.00000 -0.401248 0.786738 -0.37305 0.256408 beta_tt_b -0.013565 -0.40125 1.000000 -0.310859 0.80172 0.088159 beta_tc_a 0.006076 0.78674 -0.310859 1.000000 -0.23211 0.101834 beta_tc_b -0.014581 -0.37305 0.801723 -0.232106 1.00000 0.127684 beta_hw_a -0.031599 0.25641 0.088159 0.101834 0.12768 1.000000 beta_hw_b 0.047712 -0.12369 -0.009718 0.004099 0.02329 -0.655937 beta_ch_a -0.025105 0.18081 -0.021818 0.122501 0.29384 0.487928 beta_ch_b 0.038005 -0.28863 0.251750 -0.061445 0.33531 -0.310771 delta_a 9.8577e-04 0.15221 -0.046862 -0.016534 -0.36622 0.005066 gamma_commute_a 0.009014 -0.11817 0.094703 -0.086623 0.06106 -0.238780 gamma_car_av_a 0.018299 -0.07643 -0.028910 0.008397 0.03283 -0.200720 beta_hw_b beta_ch_a beta_ch_b delta_a gamma_commute_a gamma_car_av_a asc_1 0.047712 -0.02510 0.03800 9.8577e-04 0.009014 0.018299 beta_tt_a -0.123694 0.18081 -0.28863 0.152210 -0.118169 -0.076431 beta_tt_b -0.009718 -0.02182 0.25175 -0.046862 0.094703 -0.028910 beta_tc_a 0.004099 0.12250 -0.06145 -0.016534 -0.086623 0.008397 beta_tc_b 0.023293 0.29384 0.33531 -0.366217 0.061056 0.032829 beta_hw_a -0.655937 0.48793 -0.31077 0.005066 -0.238780 -0.200720 beta_hw_b 1.000000 -0.34102 0.47625 -0.095017 0.237271 0.235561 beta_ch_a -0.341017 1.00000 -0.06427 -0.419639 -0.232800 -0.072180 beta_ch_b 0.476246 -0.06427 1.00000 -0.376644 -0.075984 0.245295 delta_a -0.095017 -0.41964 -0.37664 1.000000 -0.156813 -0.511627 gamma_commute_a 0.237271 -0.23280 -0.07598 -0.156813 1.000000 -0.010479 gamma_car_av_a 0.235561 -0.07218 0.24529 -0.511627 -0.010479 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.09330 -0.04226 -0.048654 -0.04651 -0.195574 beta_tt_a -0.09330 1.00000 -0.59392 0.825051 -0.48099 0.117787 beta_tt_b -0.04226 -0.59392 1.00000 -0.581251 0.73223 0.252726 beta_tc_a -0.04865 0.82505 -0.58125 1.000000 -0.39630 -0.009226 beta_tc_b -0.04651 -0.48099 0.73223 -0.396302 1.00000 0.444783 beta_hw_a -0.19557 0.11779 0.25273 -0.009226 0.44478 1.000000 beta_hw_b 0.19026 -0.06308 -0.26763 0.077062 -0.40629 -0.884453 beta_ch_a -0.12435 0.21784 -0.05372 0.198222 0.48570 0.668381 beta_ch_b 0.19043 -0.37075 0.10702 -0.117746 -0.01393 -0.533662 delta_a -0.02715 0.14709 0.07579 -0.059852 -0.47910 -0.108706 gamma_commute_a 0.10109 -0.33454 0.20138 -0.275240 0.07878 -0.502612 gamma_car_av_a 0.08728 -0.09176 -0.24016 0.072700 -0.12501 -0.517335 beta_hw_b beta_ch_a beta_ch_b delta_a gamma_commute_a gamma_car_av_a asc_1 0.19026 -0.12435 0.19043 -0.02715 0.10109 0.08728 beta_tt_a -0.06308 0.21784 -0.37075 0.14709 -0.33454 -0.09176 beta_tt_b -0.26763 -0.05372 0.10702 0.07579 0.20138 -0.24016 beta_tc_a 0.07706 0.19822 -0.11775 -0.05985 -0.27524 0.07270 beta_tc_b -0.40629 0.48570 -0.01393 -0.47910 0.07878 -0.12501 beta_hw_a -0.88445 0.66838 -0.53366 -0.10871 -0.50261 -0.51734 beta_hw_b 1.00000 -0.59146 0.61235 0.03545 0.49076 0.55101 beta_ch_a -0.59146 1.00000 -0.35522 -0.62705 -0.40213 -0.16027 beta_ch_b 0.61235 -0.35522 1.00000 -0.21123 0.14765 0.49693 delta_a 0.03545 -0.62705 -0.21123 1.00000 -0.02090 -0.44772 gamma_commute_a 0.49076 -0.40213 0.14765 -0.02090 1.00000 0.15643 gamma_car_av_a 0.55101 -0.16027 0.49693 -0.44772 0.15643 1.00000 20 worst outliers in terms of lowest average per choice prediction: ID Avg prob per choice 22580 0.2704689 23205 0.2994223 14802 0.3098078 16617 0.3184483 16489 0.3225765 15174 0.3365382 22961 0.3416793 16178 0.3437416 22278 0.3495924 18219 0.3528147 20010 0.3564388 20063 0.3588394 21922 0.3665762 76862 0.3699728 20100 0.3722228 21623 0.3746531 14074 0.3785641 13214 0.3838056 13863 0.4027229 17187 0.4029851 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.098931 beta_tc_a 0.00000 -0.09501 -0.095009 beta_tc_b 0.00000 -0.52473 -0.524728 beta_hw_a -0.03960 -0.04016 -5.6482e-04 beta_hw_b -0.04790 -0.04624 0.001662 beta_ch_a -0.76240 -0.74667 0.015732 beta_ch_b -2.17250 -2.08714 0.085362 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 "Apollo_example_20" modelDescr "LC model with class allocation model on Swiss route choice data" indivID "ID" nCores "3" debug "FALSE" workInLogs "FALSE" seed "13" mixing "FALSE" HB "FALSE" noValidation "FALSE" noDiagnostics "FALSE" panelData "TRUE" analyticGrad "TRUE" Hessian routines attempted -------------- numerical second derivative of LL (using numDeriv) Scaling used in computing Hessian -------------- 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.74666823 beta_ch_b 2.08713788 delta_a 0.21393202 gamma_commute_a 0.22347421 gamma_car_av_a 0.56154485 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) 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 mnl_settings = list( alternatives = c(class_a=1, class_b=2), avail = 1, choiceVar = NA, V = V ) lcpars[["pi_values"]] = apollo_mnl(mnl_settings, functionality="raw") 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 for(s in 1:length(pi_values)){ ### 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("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)