22: MTC Motorized and Non-Motorized Nested Mode Choice

22: MTC Motorized and Non-Motorized Nested Mode Choice

import larch.numba as lx
m = lx.example(17)

For this example, we’re going to re-create model 22 from the Self Instructing Manual. (pp. 179)

motorized = m.graph.new_node(parameter='mu_motor', children=[1,2,3,4], name='Motorized')
nonmotorized = m.graph.new_node(parameter='mu_nonmotor', children=[5,6], name='Nonmotorized')
m.ordering = (
    ("CostbyInc","costbyincome",),
    ("TravelTime",".*time.*",".*dist.*", ),
    ("Household","hhinc.*","vehbywrk.*",),
    ("Zonal","wkcbd.*","wkempden.*",),
    ("ASCs","ASC.*",),
)
m.loglike()
-7309.600971749634
m.maximize_loglike()
/home/runner/work/larch/larch/larch/larch/model/optimization.py:308: UserWarning: slsqp may not play nicely with unbounded parameters
if you get poor results, consider setting global bounds with model.set_cap()
  warnings.warn( # infinite bounds # )
keyvalue
x
0
ASC_Bike -1.201
ASC_SR2 -1.325
ASC_SR3+ -2.506
ASC_Transit -0.404
ASC_Walk 0.345
costbyincome -0.039
hhinc#4 -0.004
hhinc#5 -0.010
hhinc#6 -0.006
motorized_ovtbydist -0.114
motorized_time -0.015
mu_motor 0.726
mu_nonmotor 0.769
nonmotorized_time -0.046
vehbywrk_Bike -0.735
vehbywrk_SR -0.226
vehbywrk_Transit -0.707
vehbywrk_Walk -0.764
wkcbd_Bike 0.408
wkcbd_SR2 0.193
wkcbd_SR3+ 0.781
wkcbd_Transit 0.921
wkcbd_Walk 0.114
wkempden_Bike 0.002
wkempden_SR2 0.001
wkempden_SR3+ 0.002
wkempden_Transit 0.002
wkempden_Walk 0.002
loglike-3441.672527117994
d_loglike
0
ASC_Bike 5.979e-05
ASC_SR2 -2.561e-03
ASC_SR3+ -6.798e-04
ASC_Transit -1.606e-03
ASC_Walk -6.126e-05
costbyincome -6.766e-03
hhinc#4 -1.077e-01
hhinc#5 1.052e-02
hhinc#6 -1.973e-02
motorized_ovtbydist -1.108e-02
motorized_time -7.640e-02
mu_motor -1.422e-02
mu_nonmotor -1.544e-04
nonmotorized_time -6.179e-03
vehbywrk_Bike -3.140e-05
vehbywrk_SR -5.988e-03
vehbywrk_Transit -1.010e-03
vehbywrk_Walk -1.431e-05
wkcbd_Bike 2.391e-04
wkcbd_SR2 4.213e-04
wkcbd_SR3+ -4.595e-04
wkcbd_Transit -6.164e-04
wkcbd_Walk -6.433e-04
wkempden_Bike 2.838e-02
wkempden_SR2 -2.895e-02
wkempden_SR3+ -3.320e-01
wkempden_Transit 5.577e-01
wkempden_Walk -1.504e-01
nit71
nfev195
njev71
status0
message'Optimization terminated successfully'
successTrue
elapsed_time0:00:01.524991
method'slsqp'
n_cases5029
iteration_number0
logloss0.6843651873370439
__verbose_repr__True
m.calculate_parameter_covariance()
m.parameter_summary()
    Value Std Err t Stat Signif Null Value
Category Parameter          
CostbyInc costbyincome -0.0386  0.0104 -3.72 *** 0.00
TravelTime motorized_time -0.0145  0.00387 -3.76 *** 0.00
nonmotorized_time -0.0462  0.00540 -8.56 *** 0.00
motorized_ovtbydist -0.114  0.0211 -5.39 *** 0.00
Household hhinc#4 -0.00393  0.00161 -2.44 * 0.00
hhinc#5 -0.0100  0.00465 -2.16 * 0.00
hhinc#6 -0.00621  0.00302 -2.05 * 0.00
vehbywrk_Bike -0.735  0.229 -3.21 ** 0.00
vehbywrk_SR -0.226  0.0651 -3.47 *** 0.00
vehbywrk_Transit -0.707  0.150 -4.72 *** 0.00
vehbywrk_Walk -0.764  0.163 -4.68 *** 0.00
Zonal wkcbd_Bike  0.408  0.328  1.24 0.00
wkcbd_SR2  0.193  0.0962  2.01 * 0.00
wkcbd_SR3+  0.781  0.200  3.91 *** 0.00
wkcbd_Transit  0.921  0.222  4.15 *** 0.00
wkcbd_Walk  0.114  0.236  0.48 0.00
wkempden_Bike  0.00167  0.00109  1.54 0.00
wkempden_SR2  0.00115  0.000354  3.24 ** 0.00
wkempden_SR3+  0.00164  0.000449  3.65 *** 0.00
wkempden_Transit  0.00224  0.000507  4.41 *** 0.00
wkempden_Walk  0.00217  0.000762  2.85 ** 0.00
ASCs ASC_Bike -1.20  0.417 -2.88 ** 0.00
ASC_SR2 -1.33  0.255 -5.20 *** 0.00
ASC_SR3+ -2.51  0.475 -5.28 *** 0.00
ASC_Transit -0.404  0.221 -1.82 0.00
ASC_Walk  0.345  0.358  0.97 0.00
Other mu_motor  0.726  0.135 -2.03 * 1.00
mu_nonmotor  0.769  0.179 -1.29 1.00