Professional Documents
Culture Documents
(LV 0000001540)
Session 11
16 January 2023
Interaction terms in
discrete choice analysis
Rolf Moeckel | Professor of Travel Behavior | Department of Mobility Systems Engineering | Technical University of Munich
Typical choice set
Typically, we calculate the utility of all alternatives. It is possible to use different equations for different
alternatives:
𝑢!"#$ = 𝛽%,!"#$ + 𝛽',!"#$ % 𝑐𝑜𝑠𝑡𝑠!"#$ + 𝛽(,!"#$ % 𝑡𝑟𝑎𝑣𝑒𝑙𝑡𝑖𝑚𝑒!"#$
𝑢)"* = 𝛽%,)"* + 𝛽',)"* % 𝑓𝑎𝑟𝑒)"* + 𝛽(,)"* % 𝑡𝑟𝑎𝑣𝑒𝑙𝑡𝑖𝑚𝑒)"* + 𝛽+,)"* % 𝑛𝑢𝑚𝑏𝑒𝑟𝑂𝑓𝑇𝑟𝑎𝑛𝑠𝑓𝑒𝑟𝑠)"*
𝑢,!-. = 𝛽%,,!-. + 𝛽',,!-. % 𝑡𝑟𝑎𝑣𝑒𝑙𝑡𝑖𝑚𝑒,!-. + 𝛽(,,!-. % 𝑠ℎ𝑎𝑟𝑒𝑂𝑓𝐶𝑜𝑣𝑒𝑟𝑒𝑑𝑊𝑎𝑙𝑘𝑤𝑎𝑦𝑠,!-.
Typically, the constant of the most frequent mode is set to 0 (i.e., leave out 𝛽%,!"#$ )
2
No-choice alternative
It is also possible to choose between activities and not doing an activity. For example, one might choose
to buy a car of type A, B or C, or not to buy a car at all.
𝑢/ = 𝛽%,/ + 𝛽' % 𝑝𝑟𝑖𝑐𝑒/ + 𝛽( % 𝑒𝑓𝑓𝑖𝑐𝑖𝑒𝑛𝑐𝑦/ + 𝛽+ % 𝑐𝑜𝑚𝑓𝑜𝑟𝑡/
𝑢0 = 𝛽%,0 + 𝛽' % 𝑝𝑟𝑖𝑐𝑒0 + 𝛽( % 𝑒𝑓𝑓𝑖𝑐𝑖𝑒𝑛𝑐𝑦0 + 𝛽+ % 𝑐𝑜𝑚𝑓𝑜𝑟𝑡0
𝑢1 = 𝛽%,1 + 𝛽' % 𝑝𝑟𝑖𝑐𝑒1 + 𝛽( % 𝑒𝑓𝑓𝑖𝑐𝑖𝑒𝑛𝑐𝑦1 + 𝛽+ % 𝑐𝑜𝑚𝑓𝑜𝑟𝑡1
𝑢2$1!3 = 0
3
Attribute units
The unit of an attribute is irrelevant. Imagine this utility function was used:
For example, measuring travel costs in Euros may result in a coefficient of 𝛽 = −0.5. Measuring costs in
Cents would result in a parameter of 𝛽 = −0.005.
As long as the same unit is used in model estimation and model application, the unit is irrelevant.
4
Attribute transformations
Transformations are relevant and sometimes desired to express a non-linear impact:
Raising to the power of: 𝛽' % 𝑝𝑟𝑖𝑐𝑒7 → 𝛽' % 𝑝𝑟𝑖𝑐𝑒7 8
Taking the log: 𝛽' % 𝑝𝑟𝑖𝑐𝑒7 → 𝛽' % 𝑙𝑜𝑔 𝑝𝑟𝑖𝑐𝑒7
937:6!
Normalizing by other variable: 𝛽' % 𝑝𝑟𝑖𝑐𝑒7 → 𝛽' % 72:$46
"#$%&"#'(
Interaction effect: 𝛽' % 𝑝𝑟𝑖𝑐𝑒7 → 𝛽' % 𝑝𝑟𝑖𝑐𝑒7 % 𝑠𝑒𝑥963*$2
The final term is called interaction term and describes the varying sensitivity of travel time for employed
and unemployed people.
6
Effect of interaction terms
𝑢)*+, = 𝛽- + 𝛽. % 𝑡𝑖𝑚𝑒)*+, + 𝑢)*+, = 𝛽- + 𝛽. % 𝑡𝑖𝑚𝑒)*+, + 𝛽/ % 𝑒𝑚𝑝𝑙𝑆𝑡𝑎𝑡 +
𝑢)*+, = 𝛽- + 𝛽. % 𝑡𝑖𝑚𝑒)*+,
𝛽/ % 𝑒𝑚𝑝𝑙𝑆𝑡𝑎𝑡 𝛽0 % 𝑡𝑖𝑚𝑒)*+, % 𝑒𝑚𝑝𝑙𝑆𝑡𝑎𝑡
unemployed
unemployed
Utility
Utility
Utility
employed
employed
7
Dummy coding
A categorical variable may be used to improve the model estimation.
Example: season (winter, spring, summer, fall)
Commonly, one option will be used as the base (such as winter), and dummies will be created for the other
seasons (such as, 𝑥*9372; , 𝑥*"4463 and 𝑥<!-- ).
Mathematically, it does not make a difference which alternative is set as the base alternative.
8
Selection of base is mathematically irrelevant
1
0.5
0
Winter Spring Summer Fall
-0.5
-1
-1.5
Winter as Base Spring as Base
9
Dummy and effect coding
Effect coding is very similar to dummy coding, but the base alternative is not coded as 0 but as -1. Example
for categorical variable Season:
0 0 0 1
Effect coding 1 0 0 0
-1 1 0 0
-1 0 1 0
-1 0 0 1
10
Dummy and effect coding example
𝑢𝑡𝑖𝑙𝑖𝑡𝑦123 = 𝑐𝑜𝑛𝑠𝑡𝑎𝑛𝑡123 + 𝛽. % 𝑡𝑟𝑎𝑣𝑒𝑙𝑡𝑖𝑚𝑒123 + 𝛽/ % 𝑡𝑟𝑎𝑣𝑒𝑙𝑐𝑜𝑠𝑡𝑠123 + 𝛽0 % 𝑥345678 + 𝛽9 % 𝑥32)),5 + 𝛽: % 𝑥;<==
−𝛽!"#$%&
Winter 0 0 0 0 -1 -1 -1 −𝛽!'(()#
−𝛽*+,,
11
Benefits of Effect Coding
𝑢𝑡𝑖𝑙𝑖𝑡𝑦123 = 𝑐𝑜𝑛𝑠𝑡𝑎𝑛𝑡123 + 𝛽. % 𝑡𝑟𝑎𝑣𝑒𝑙𝑡𝑖𝑚𝑒123 + 𝛽/ % 𝑡𝑟𝑎𝑣𝑒𝑙𝑐𝑜𝑠𝑡𝑠123 + 𝛽0 % 𝑥345678 + 𝛽9 % 𝑥32)),5 + 𝛽: % 𝑥;<== +
𝛽> % 𝑥345678 % 𝑥;,)<=, + 𝛽? % 𝑥32)),5 % 𝑥;,)<=, + 𝛽@ % 𝑥;<== % 𝑥;,)<=,
When interaction of two categorical variables are included, Effect Coding allows to account for interaction
in the base case:
Dummy Coding Effect Coding
Season 𝑥!"#$%& 𝑥!'(()# 𝑥*+,, Effect male Effect female 𝑥!"#$%& 𝑥!'(()# 𝑥*+,, Effect male Effect female
−𝛽!"#$%& C−𝛽!"#$%&
Winter 0 0 0 0 0 -1 -1 -1 −𝛽!'(()# − 𝛽!'(()# − 𝛽*+,, D
−𝛽*+,, B 𝛽*)(+,)
12
Benefit of effect coding: The diffference between males and females can be represented in the base season (here winter).
How to review estimation results?
mlogit(mode ~ ttime | income | 0, data = logit_data, weights =
• Are estimates significant (not necessary for the weight)
constants)? Non-significant variables should only
Coefficients :
be kept in exceptional cases (such as small case Estimate Std. Error z-value Pr(>|z|)
(Intercept):bike -6.1355e-01 1.0446e-01 -5.8736 4.265e-09 ***
number, Pr() nearly significant). (Intercept):transit -4.9014e-01 8.9619e-02 -5.4692 4.522e-08 ***
(Intercept):walk 6.0338e-02 1.4091e-01 0.4282 0.6685
• Does each parameter has the right sign (+ or -)? ttime -3.2904e-02 1.2587e-03 -26.1406 < 2.2e-16 ***
You need to be able to explain why each sign is income:bike -1.2539e-04 2.9830e-05 -4.2037 2.626e-05 ***
income:transit -1.8018e-04 2.6514e-05 -6.7955 1.079e-11 ***
plausible income:walk -1.7941e-04 4.0721e-05 -4.4059 1.054e-05 ***
Coefficients :
1
Estimate Std. Error z-value Pr(>|z|)
(Intercept):bike 1.6923e+00 3.8140e-01 4.4371 9.117e-06 ***
(Intercept):transit 3.2047e+00 2.5282e-01 12.6757 < 2.2e-16
0.5
(Intercept):walk 6.9057e+00 4.5583e-01 15.1499 < 2.2e-16 ***
I(income * bin_transit) -7.7728e-05 2.9894e-05 -2.6002 0.009318 **
I(income * bin_walk) -7.4863e-05 5.9186e-05 -1.2649 0.205917
log(Travel tiem)
I(ttime * bin_walk) -8.6132e-02 9.4329e-03 -12.2613 < 2.2e-16 *** 0
Log-Likelihood: -3455.2
McFadden R^2: 0.44936 -2
Likelihood ratio test : chisq = 5639.3 (p.value = < 2.22e-16) Travel time
14