You are on page 1of 14

Travel Behavior

(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

𝑢2$1!3 is called the no-choice alternative.

3
Attribute units
The unit of an attribute is irrelevant. Imagine this utility function was used:

𝑢𝑡𝑖𝑙𝑖𝑡𝑦4$56 = 𝑐𝑜𝑛𝑠𝑡𝑎𝑛𝑡4$56 + 𝛽 % 𝑡𝑟𝑎𝑣𝑒𝑙𝑐𝑜𝑠𝑡𝑠4$56

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

Example: above 7.000 EUR


Above 5,000 €, income does barely affect
6,000 to 7,000 EUR
5,000 to 6,000 EUR car owernship. The impact of income is
4,000 to 5,000 EUR
3,000 to 4,000 EUR non-linear, a transformation is likely to
2,000 to 3,000 EUR
1,500 to 2,000 EUR improve the estimate.
900 to 1,500 EUR
500 to 900 EUR
under 500 EUR
0% 20% 40% 60% 80% 100%
1 Auto 2 Autos 3 Autos 4 Autos or more 5
Interaction terms
As in multiple regression, interaction terms can be included in discrete choice analysis. Example:
𝑢7,. = 𝛽% + 𝛽' % 𝑡𝑖𝑚𝑒7 + 𝛽( % 𝑒𝑚𝑝𝑙𝑜𝑦𝑒𝑑. + 𝛽+ % 𝑡𝑖𝑚𝑒7 % 𝑒𝑚𝑝𝑙𝑜𝑦𝑒𝑑.

𝑢7,. = Utility of option i for person k Interaction Term

𝛽%, 𝛽', 𝛽(, 𝛽+= Coefficients


𝑡𝑖𝑚𝑒7 = Travel time of option i
𝑒𝑚𝑝𝑙𝑜𝑦𝑒𝑑. = Employment status of person k (0 = unemployed, 1 = employed)

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

Travel Time Travel Time Travel Time

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 𝑥<!-- ).

𝑢𝑡𝑖𝑙𝑖𝑡𝑦)"* = 𝑐𝑜𝑛𝑠𝑡𝑎𝑛𝑡)"* + 𝛽' % 𝑡𝑟𝑎𝑣𝑒𝑙𝑡𝑖𝑚𝑒)"* + 𝛽( % 𝑡𝑟𝑎𝑣𝑒𝑙𝑐𝑜𝑠𝑡𝑠)"* +


𝛽+ % 𝑥*9372; + 𝛽= % 𝑥*"4463 + 𝛽> % 𝑥<!--

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:

Winter Spring Summer Fall


Dummy coding 0 0 0 0
0 1 0 0
0 0 1 0 Base case

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 + 𝛽: % 𝑥;<==

Dummy Coding Effect Coding

Season 𝑥!"#$%& 𝑥!'(()# 𝑥*+,, Result 𝑥!"#$%& 𝑥!'(()# 𝑥*+,, Result

Spring 1 0 0 𝛽!"#$%& 1 0 0 𝛽!"#$%&

Summer 0 1 0 𝛽!'(()# 0 1 0 𝛽!'(()#

Fall 0 0 1 𝛽*+,, 0 0 1 𝛽*+,,

−𝛽!"#$%&
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

Spring 1 0 0 𝛽!"#$%& 𝛽!"#$%& B 𝛽*)(+,) 1 0 0 𝛽!"#$%& 𝛽!"#$%& B 𝛽*)(+,)

Summer 0 1 0 𝛽!'(()# 𝛽!'(()# B 𝛽*)(+,) 0 1 0 𝛽!'(()# 𝛽!'(()# B 𝛽*)(+,)

Fall 0 0 1 𝛽*+,, 𝛽*+,, B 𝛽*)(+,) 0 0 1 𝛽*+,, 𝛽*+,, B 𝛽*)(+,)

−𝛽!"#$%& 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 ***

• Are the dimensions reasonable (example on the


𝑢!"#$,& = 0 + −3.2904𝑒 − 02 L 𝑡𝑡𝑖𝑚𝑒 + 0 L 𝑖𝑛𝑐𝑜𝑚𝑒&
right: Is it plausible that income has a stronger
𝑢'()*,& = −6.1355𝑒 − 01 + −3.2904𝑒 − 02 L 𝑡𝑡𝑖𝑚𝑒 + −1.2539𝑒 − 04 L 𝑖𝑛𝑐𝑜𝑚𝑒&
impact on transit use than on bike use?) 𝑢#+!&,(#,& = −4.9014𝑒 − 01 + −3.2904𝑒 − 02 L 𝑡𝑡𝑖𝑚𝑒 + −1.8018𝑒 − 04 L 𝑖𝑛𝑐𝑜𝑚𝑒&
𝑢-!.),& = 6.0338𝑒 − 02 + −3.2904𝑒 − 02 L 𝑡𝑡𝑖𝑚𝑒 + −1.7941𝑒 − 04 L 𝑖𝑛𝑐𝑜𝑚𝑒&
• If interaction terms or transformations are used,
can you explain each of them?
Famous modeler Bill Davidson: “If you cannot explain it, you cannot use it.”
13
What is odd in this estimation? Find five reasons to reject it.
Frequencies of alternatives:choice
auto bike transit walk Log transformation
0.703444 0.101722 0.138500 0.056334 1.5

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

I(ttime * bin_auto) -1.1566e-01 4.3744e-03 -19.6898 < 2.2e-16 *** 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30


I(ttime * bin_transit) -1.5029e-01 4.3744e-03 -19.6898 < 2.2e-16 ***
auto_avail:bike -3.2475e+00 1.8178e-01 -17.8651 < 2.2e-16 *** -0.5
auto_avail:transit 0.7574e+00 1.4701e-01 -25.5593 < 2.2e-16 ***
auto_avail:walk -3.4219e+00 3.0178e-01 -11.3389 < 2.2e-16 ***
log(ttime):transit 1.9446e+00 7.1030e-02 27.3770 < 2.2e-16 *** -1
--
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
-1.5

Log-Likelihood: -3455.2
McFadden R^2: 0.44936 -2
Likelihood ratio test : chisq = 5639.3 (p.value = < 2.22e-16) Travel time

14

You might also like