Model run by stephane.hess using Apollo 0.2.7 on R 4.0.5 for Darwin. www.ApolloChoiceModelling.com Model name : EM_LC_no_covariates Model description : LC model with constant class allocation probabilities on Swiss route choice data, EM algorithm Model run at : 2022-01-08 13:23:04 Estimation method : EM algorithm (bfgs) -> Maximum likelihood (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) : -1755.95 LL(0, whole model) : -2420.47 LL(C, whole model) : -2420.39 LL(final, whole model) : -1561.79 Rho-square (0) : 0.3548 Adj.Rho-square (0) : 0.3502 Rho-square (C) : 0.3547 Adj.Rho-square (C) : 0.3502 AIC : 3145.57 BIC : 3213.31 LL(0,Class_1) : -2420.47 LL(final,Class_1) : -1770.97 LL(0,Class_2) : -2420.47 LL(final,Class_2) : -2511.9 Estimated parameters : 11 Time taken (hh:mm:ss) : 00:00:35.88 pre-estimation : 00:00:1.54 estimation : 00:00:32.7 post-estimation : 00:00:1.63 Iterations : 46 (EM) & 7 (bfgs) Min abs eigenvalue of Hessian : 15.03279 Unconstrained optimisation. Estimates: Estimate s.e. t.rat.(0) Rob.s.e. Rob.t.rat.(0) asc_1_a -0.06758 0.064322 -1.0507 0.075041 -0.9006 asc_1_b 0.04111 0.110398 0.3724 0.133176 0.3087 asc_2_a 0.00000 NA NA NA NA asc_2_b 0.00000 NA NA NA NA beta_tt_a -0.03716 0.005255 -7.0726 0.008940 -4.1574 beta_tt_b -0.21772 0.025455 -8.5531 0.045253 -4.8112 beta_tc_a -0.05044 0.013041 -3.8677 0.013162 -3.8321 beta_tc_b -0.79771 0.084761 -9.4113 0.113992 -6.9980 beta_hw_a -0.03446 0.002993 -11.5153 0.004492 -7.6716 beta_hw_b -0.05553 0.005508 -10.0817 0.008078 -6.8743 beta_ch_a -0.62567 0.072958 -8.5757 0.102224 -6.1205 beta_ch_b -2.75555 0.227204 -12.1281 0.280485 -9.8242 delta_a -0.04493 0.174649 -0.2573 0.198481 -0.2264 delta_b 0.00000 NA NA NA NA Summary of class allocation for LC model component : Mean prob. Class_1 0.4888 Class_2 0.5112 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 beta_tc_a beta_tc_b beta_hw_a asc_1_a 0.004137 -0.001972 -2.003e-06 -1.425e-05 -2.311e-05 -6.826e-06 -1.398e-06 asc_1_b -0.001972 0.012188 5.315e-05 -4.7422e-04 6.703e-05 -0.001264 3.667e-06 beta_tt_a -2.003e-06 5.315e-05 2.761e-05 -2.619e-05 5.048e-05 -1.647e-05 4.399e-06 beta_tt_b -1.425e-05 -4.7422e-04 -2.619e-05 6.4796e-04 -1.804e-07 0.001937 -7.481e-07 beta_tc_a -2.311e-05 6.703e-05 5.048e-05 -1.804e-07 1.7007e-04 5.371e-05 5.025e-06 beta_tc_b -6.826e-06 -0.001264 -1.647e-05 0.001937 5.371e-05 0.007184 2.350e-05 beta_hw_a -1.398e-06 3.667e-06 4.399e-06 -7.481e-07 5.025e-06 2.350e-05 8.957e-06 beta_hw_b -3.688e-06 -1.944e-05 -4.468e-06 5.674e-05 -1.099e-06 1.5651e-04 -5.426e-06 beta_ch_a -1.2874e-04 -3.4329e-04 9.257e-05 5.4709e-04 1.3754e-04 0.002323 8.827e-05 beta_ch_b -0.001448 7.7278e-04 -1.407e-05 0.004092 3.2968e-04 0.012405 -6.436e-06 delta_a 9.0644e-04 -1.1396e-04 -1.6082e-04 -0.001685 -4.0841e-04 -0.006418 -1.2744e-04 beta_hw_b beta_ch_a beta_ch_b delta_a asc_1_a -3.688e-06 -1.2874e-04 -0.001448 9.0644e-04 asc_1_b -1.944e-05 -3.4329e-04 7.7278e-04 -1.1396e-04 beta_tt_a -4.468e-06 9.257e-05 -1.407e-05 -1.6082e-04 beta_tt_b 5.674e-05 5.4709e-04 0.004092 -0.001685 beta_tc_a -1.099e-06 1.3754e-04 3.2968e-04 -4.0841e-04 beta_tc_b 1.5651e-04 0.002323 0.012405 -0.006418 beta_hw_a -5.426e-06 8.827e-05 -6.436e-06 -1.2744e-04 beta_hw_b 3.034e-05 -2.912e-05 5.2970e-04 -2.963e-05 beta_ch_a -2.912e-05 0.005323 0.004243 -0.006921 beta_ch_b 5.2970e-04 0.004243 0.051622 -0.017905 delta_a -2.963e-05 -0.006921 -0.017905 0.030502 Robust covariance matrix: asc_1_a asc_1_b beta_tt_a beta_tt_b beta_tc_a beta_tc_b beta_hw_a asc_1_a 0.005631 -0.003580 -8.890e-05 2.0195e-04 -7.075e-05 4.9792e-04 -3.978e-05 asc_1_b -0.003580 0.017736 3.5219e-04 -0.002362 2.8409e-04 -0.005895 4.022e-05 beta_tt_a -8.890e-05 3.5219e-04 7.991e-05 -2.3565e-04 7.173e-05 -3.7314e-04 1.693e-05 beta_tt_b 2.0195e-04 -0.002362 -2.3565e-04 0.002048 -1.3040e-04 0.004595 -2.902e-05 beta_tc_a -7.075e-05 2.8409e-04 7.173e-05 -1.3040e-04 1.7324e-04 -2.1282e-04 1.245e-05 beta_tc_b 4.9792e-04 -0.005895 -3.7314e-04 0.004595 -2.1282e-04 0.012994 3.091e-05 beta_hw_a -3.978e-05 4.022e-05 1.693e-05 -2.902e-05 1.245e-05 3.091e-05 2.018e-05 beta_hw_b 2.228e-05 -9.076e-05 -3.029e-05 1.4382e-04 -1.669e-05 1.8089e-04 -1.989e-05 beta_ch_a -8.1403e-04 -0.001148 1.3347e-04 0.001267 1.0440e-04 0.005161 2.2875e-04 beta_ch_b -0.002673 8.4258e-04 -9.0249e-04 0.008851 -1.9711e-04 0.017422 -1.9144e-04 delta_a 0.002131 4.7929e-04 -1.0235e-04 -0.003167 -2.9622e-04 -0.010370 -3.0705e-04 beta_hw_b beta_ch_a beta_ch_b delta_a asc_1_a 2.228e-05 -8.1403e-04 -0.002673 0.002131 asc_1_b -9.076e-05 -0.001148 8.4258e-04 4.7929e-04 beta_tt_a -3.029e-05 1.3347e-04 -9.0249e-04 -1.0235e-04 beta_tt_b 1.4382e-04 0.001267 0.008851 -0.003167 beta_tc_a -1.669e-05 1.0440e-04 -1.9711e-04 -2.9622e-04 beta_tc_b 1.8089e-04 0.005161 0.017422 -0.010370 beta_hw_a -1.989e-05 2.2875e-04 -1.9144e-04 -3.0705e-04 beta_hw_b 6.526e-05 -1.8990e-04 0.001041 1.8797e-04 beta_ch_a -1.8990e-04 0.010450 0.006098 -0.013512 beta_ch_b 0.001041 0.006098 0.078672 -0.022865 delta_a 1.8797e-04 -0.013512 -0.022865 0.039395 Classical correlation matrix: asc_1_a asc_1_b beta_tt_a beta_tt_b beta_tc_a beta_tc_b beta_hw_a asc_1_a 1.000000 -0.277765 -0.005925 -0.008703 -0.02755 -0.001252 -0.007265 asc_1_b -0.277765 1.000000 0.091615 -0.168747 0.04656 -0.135064 0.011098 beta_tt_a -0.005925 0.091615 1.000000 -0.195806 0.73659 -0.036974 0.279736 beta_tt_b -0.008703 -0.168747 -0.195806 1.000000 -5.4331e-04 0.897875 -0.009820 beta_tc_a -0.027550 0.046556 0.736590 -5.4331e-04 1.00000 0.048586 0.128743 beta_tc_b -0.001252 -0.135064 -0.036974 0.897875 0.04859 1.000000 0.092638 beta_hw_a -0.007265 0.011098 0.279736 -0.009820 0.12874 0.092638 1.000000 beta_hw_b -0.010409 -0.031969 -0.154371 0.404637 -0.01530 0.335213 -0.329135 beta_ch_a -0.027434 -0.042620 0.241469 0.294586 0.14456 0.375606 0.404263 beta_ch_b -0.099056 0.030809 -0.011782 0.707569 0.11127 0.644161 -0.009466 delta_a 0.080690 -0.005911 -0.175236 -0.378980 -0.17932 -0.433514 -0.243805 beta_hw_b beta_ch_a beta_ch_b delta_a asc_1_a -0.01041 -0.02743 -0.099056 0.080690 asc_1_b -0.03197 -0.04262 0.030809 -0.005911 beta_tt_a -0.15437 0.24147 -0.011782 -0.175236 beta_tt_b 0.40464 0.29459 0.707569 -0.378980 beta_tc_a -0.01530 0.14456 0.111268 -0.179317 beta_tc_b 0.33521 0.37561 0.644161 -0.433514 beta_hw_a -0.32913 0.40426 -0.009466 -0.243805 beta_hw_b 1.00000 -0.07246 0.423245 -0.030802 beta_ch_a -0.07246 1.00000 0.255992 -0.543169 beta_ch_b 0.42325 0.25599 1.000000 -0.451224 delta_a -0.03080 -0.54317 -0.451224 1.000000 Robust correlation matrix: asc_1_a asc_1_b beta_tt_a beta_tt_b beta_tc_a beta_tc_b beta_hw_a asc_1_a 1.00000 -0.35823 -0.13253 0.05947 -0.07163 0.05821 -0.11801 asc_1_b -0.35823 1.00000 0.29583 -0.39185 0.16207 -0.38834 0.06723 beta_tt_a -0.13253 0.29583 1.00000 -0.58251 0.60960 -0.36617 0.42159 beta_tt_b 0.05947 -0.39185 -0.58251 1.00000 -0.21892 0.89082 -0.14276 beta_tc_a -0.07163 0.16207 0.60960 -0.21892 1.00000 -0.14184 0.21049 beta_tc_b 0.05821 -0.38834 -0.36617 0.89082 -0.14184 1.00000 0.06036 beta_hw_a -0.11801 0.06723 0.42159 -0.14276 0.21049 0.06036 1.00000 beta_hw_b 0.03676 -0.08436 -0.41942 0.39340 -0.15697 0.19643 -0.54801 beta_ch_a -0.10612 -0.08434 0.14605 0.27398 0.07759 0.44289 0.49811 beta_ch_b -0.12698 0.02256 -0.35993 0.69736 -0.05339 0.54489 -0.15193 delta_a 0.14310 0.01813 -0.05769 -0.35258 -0.11339 -0.45836 -0.34436 beta_hw_b beta_ch_a beta_ch_b delta_a asc_1_a 0.03676 -0.10612 -0.12698 0.14310 asc_1_b -0.08436 -0.08434 0.02256 0.01813 beta_tt_a -0.41942 0.14605 -0.35993 -0.05769 beta_tt_b 0.39340 0.27398 0.69736 -0.35258 beta_tc_a -0.15697 0.07759 -0.05339 -0.11339 beta_tc_b 0.19643 0.44289 0.54489 -0.45836 beta_hw_a -0.54801 0.49811 -0.15193 -0.34436 beta_hw_b 1.00000 -0.22996 0.45938 0.11723 beta_ch_a -0.22996 1.00000 0.21268 -0.66598 beta_ch_b 0.45938 0.21268 1.00000 -0.41071 delta_a 0.11723 -0.66598 -0.41071 1.00000 20 worst outliers in terms of lowest average per choice prediction: ID Avg prob per choice 15030 0.2279390 22580 0.3124634 20010 0.3355828 23205 0.3386220 14802 0.3396987 16489 0.3503249 16617 0.3506364 22961 0.3619349 18219 0.3706734 13863 0.3760391 15174 0.3795395 22278 0.3826177 13214 0.3863466 16178 0.3871016 76862 0.3880462 20100 0.3886062 20323 0.4042289 17187 0.4058862 20063 0.4068625 22820 0.4119426 Changes in parameter estimates from starting values: Initial Estimate Difference asc_1_a -0.06758 -0.06758 -1.568e-06 asc_1_b 0.04111 0.04111 2.886e-07 asc_2_a 0.00000 0.00000 0.000 asc_2_b 0.00000 0.00000 0.000 beta_tt_a -0.03717 -0.03716 1.240e-06 beta_tt_b -0.21768 -0.21772 -4.051e-05 beta_tc_a -0.05044 -0.05044 3.524e-06 beta_tc_b -0.79780 -0.79771 8.447e-05 beta_hw_a -0.03447 -0.03446 3.352e-06 beta_hw_b -0.05553 -0.05553 -3.244e-06 beta_ch_a -0.62562 -0.62567 -4.320e-05 beta_ch_b -2.75516 -2.75555 -3.8908e-04 delta_a -0.04493 -0.04493 -2.586e-08 delta_b 0.00000 0.00000 0.000 Settings and functions used in model definition: apollo_control -------------- Value modelName "EM_LC_no_covariates" modelDescr "LC model with constant class allocation probabilities 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" Hessian routines attempted -------------- numerical second derivative of LL (using numDeriv) Scaling in estimation -------------- Value asc_1_a 0.06757989 asc_1_b 0.04110949 beta_tt_a 0.03716527 beta_tt_b 0.21768587 beta_tc_a 0.05043967 beta_tc_b 0.79779536 beta_hw_a 0.03446291 beta_hw_b 0.05553232 beta_ch_a 0.62562520 beta_ch_b 2.75515805 delta_a 0.04493434 Scaling used in computing Hessian -------------- Value asc_1_a 0.06758046 asc_1_b 0.04110954 beta_tt_a 0.03716475 beta_tt_b 0.21771973 beta_tc_a 0.05043899 beta_tc_b 0.79771214 beta_hw_a 0.03446332 beta_hw_b 0.05553318 beta_ch_a 0.62566744 beta_ch_b 2.75554676 delta_a 0.04493435 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) lcpars[["pi_values"]] = list(class_a = 1/(1 + exp(delta_b - delta_a)), class_b = 1/(1 + exp(delta_a - delta_b))) 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) }